|
|
@@ -41,6 +41,9 @@
|
|
|
order_id: '', // 订单号
|
|
|
pay_info: '', // 支付参数。将此参数透传给支付 SDK 发起支付
|
|
|
access_token: '',
|
|
|
+ sub_appid: '',
|
|
|
+ card_number: '',
|
|
|
+ user_name: '',
|
|
|
test: getApp().globalData.test
|
|
|
};
|
|
|
},
|
|
|
@@ -72,6 +75,9 @@
|
|
|
console.log(e)
|
|
|
}
|
|
|
|
|
|
+ this.sub_appid = this.userinfo.sub_appid
|
|
|
+ this.card_number = this.userinfo.card_number
|
|
|
+ this.user_name = this.userinfo.name
|
|
|
// 获取应用有效凭证
|
|
|
this.get_valid_credentials()
|
|
|
},
|
|
|
@@ -119,25 +125,19 @@
|
|
|
},
|
|
|
data: {
|
|
|
'access_token': this.access_token,
|
|
|
- 'sub_appid': this.userinfo.sub_appid,
|
|
|
- 'user_id': this.userinfo.card_number,
|
|
|
+ 'sub_appid': this.sub_appid,
|
|
|
+ 'user_id': this.card_number,
|
|
|
'order_id': this.order_id = get_order_id('shuifei'),
|
|
|
'amount': this.amount * 100,
|
|
|
'order_type': 1,
|
|
|
- 'callback_url': ''
|
|
|
+ // 'callback_url': 'http://x3ys5i.natappfree.cc'
|
|
|
+ 'callback_url': this.$code_base_url + '/HotWater/wxpayrecharge.action'
|
|
|
}
|
|
|
})
|
|
|
- if (res.statusCode == 200) {
|
|
|
- this.pay_info = res.data.data.pay_info
|
|
|
- // 发起支付
|
|
|
- this.pay_amount()
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: res.data.message,
|
|
|
- duration: 3000
|
|
|
- })
|
|
|
- }
|
|
|
+
|
|
|
+ this.pay_info = res.data.data.pay_info
|
|
|
+ // 发起支付
|
|
|
+ this.pay_amount()
|
|
|
},
|
|
|
// 调起支付
|
|
|
pay_amount() {
|
|
|
@@ -156,20 +156,27 @@
|
|
|
}
|
|
|
|
|
|
var payInfo = this.pay_info; // 请求mppay接口返回的数据
|
|
|
- var appMetaData = "app=test&version=1.1"; // 自定义回调数据
|
|
|
+ // var appMetaData = "card_number=" + this.card_number + "&user_name=" + this.user_name + "&account=" + this
|
|
|
+ // .amount; // 自定义回调数据
|
|
|
|
|
|
OpenMidas.init("test");
|
|
|
OpenMidas.pay(
|
|
|
payInfo,
|
|
|
- function(resultCode, innerCode, resultMsg, appMetaData) {
|
|
|
+ // function(resultCode, innerCode, resultMsg, appMetaData) {
|
|
|
+ function(resultCode, innerCode, resultMsg) {
|
|
|
console.log(resultCode); // 支付响应状态码
|
|
|
console.log(innerCode); // 支付响应内部错误码
|
|
|
console.log(resultMsg); // 支付响应说明
|
|
|
console.log(appMetaData); // 自定义回调数据
|
|
|
|
|
|
// todo:处理业务逻辑
|
|
|
- },
|
|
|
- appMetaData
|
|
|
+ uni.showToast({
|
|
|
+ title: resultMsg,
|
|
|
+ icon: 'success'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // },
|
|
|
+ // appMetaData
|
|
|
)
|
|
|
},
|
|
|
/**
|
|
|
@@ -179,7 +186,7 @@
|
|
|
if (this.test) {
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
const v = e.detail.value
|
|
|
this.amount = 10
|
|
|
|
|
|
@@ -240,7 +247,7 @@
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
if (this.amount < 10 || this.amount > 100) {
|
|
|
@@ -291,17 +298,17 @@
|
|
|
let minute = date.getMinutes()
|
|
|
let second = date.getSeconds()
|
|
|
let millisecond = date.getMilliseconds()
|
|
|
- let len_mill = millisecond.length
|
|
|
+ let len_mill = millisecond.toString().length
|
|
|
|
|
|
month = month > 9 ? month : '0' + month
|
|
|
day = day > 9 ? day : '0' + day
|
|
|
second = second > 9 ? second : '0' + second
|
|
|
if (len_mill == 1) {
|
|
|
- millisecond = '000' + millisecond
|
|
|
+ millisecond = (Math.floor(Math.random() * 9000) + 10000).toString() + millisecond
|
|
|
} else if (len_mill == 2) {
|
|
|
- millisecond = '00'
|
|
|
+ millisecond = (Math.floor(Math.random() * 900) + 1000).toString() + millisecond
|
|
|
} else if (len_mill == 3) {
|
|
|
- millisecond = '0' + millisecond
|
|
|
+ millisecond = (Math.floor(Math.random() * 900) + 100).toString() + millisecond
|
|
|
}
|
|
|
|
|
|
return `${head}${year}${month}${day}${hour}${minute}${second}${millisecond}`
|