|
|
@@ -94,8 +94,7 @@
|
|
|
|
|
|
if (typeof(res.data.access_token) != 'undefined') {
|
|
|
// 获取到应用有效凭证,保存到页面变量中
|
|
|
- // this.access_token = res.data.access_token
|
|
|
- this.access_token = this.userinfo.access_token
|
|
|
+ this.access_token = res.data.access_token
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
title: '获取凭证失败',
|
|
|
@@ -104,6 +103,77 @@
|
|
|
}
|
|
|
},
|
|
|
/**
|
|
|
+ * 组合地址,发起支付
|
|
|
+ */
|
|
|
+ async jsapi() {
|
|
|
+ const res = await this.$myRequest({
|
|
|
+ host: 'wecard',
|
|
|
+ url: '/cgi-bin/pay/app/mppay',
|
|
|
+ method: 'POST',
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/json'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ 'access_token': this.access_token,
|
|
|
+ 'sub_appid': this.userinfo.sub_appid,
|
|
|
+ 'user_id': this.userinfo.card_number,
|
|
|
+ 'order_id': this.order_id = get_order_id(),
|
|
|
+ 'amount': this.amount * 100
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ console.log(res.data)
|
|
|
+ console.log('access_token:', this.access_token)
|
|
|
+ console.log('sub_appid:', this.userinfo.sub_appid)
|
|
|
+ console.log('card_number:', this.userinfo.card_number)
|
|
|
+ console.log('order_id:', this.order_id)
|
|
|
+ console.log('amount:', this.amount)
|
|
|
+ if (res.data.code == 0) {
|
|
|
+ this.pay_info = res.data.data.pay_info
|
|
|
+ // 发起支付
|
|
|
+ this.pay_amount()
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ icon: 'none',
|
|
|
+ title: res.data.message,
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 调起支付
|
|
|
+ pay_amount() {
|
|
|
+ var OpenMidas = require("@/static/openMidas.js") // 引入小程序目录下的SDK文件
|
|
|
+
|
|
|
+ // 设置支付配置
|
|
|
+ wx['OpenMidasConfig'] = {
|
|
|
+ apiCommonConf: {
|
|
|
+ version: "weixiao"
|
|
|
+ },
|
|
|
+ cgiDomain: {
|
|
|
+ test: "midas.weixiao.qq.com/api", // 私有化参数联系微卡客服进行获取
|
|
|
+ },
|
|
|
+ webDomain: "https://midas.weixiao.qq.com/h5",// 私有化参数联系微卡客服进行获取
|
|
|
+ sandboxWebDomain: "https://midas.weixiao.qq.com/h5"// 私有化参数联系微卡客服进行获取
|
|
|
+ }
|
|
|
+
|
|
|
+ var payInfo = this.pay_info; // 请求mppay接口返回的数据
|
|
|
+ var appMetaData = "app=test&version=1.1"; // 自定义回调数据
|
|
|
+
|
|
|
+ OpenMidas.init("test");
|
|
|
+ OpenMidas.pay(
|
|
|
+ payInfo,
|
|
|
+ function(resultCode, innerCode, resultMsg, appMetaData) {
|
|
|
+ console.log(resultCode); // 支付响应状态码
|
|
|
+ console.log(innerCode); // 支付响应内部错误码
|
|
|
+ console.log(resultMsg); // 支付响应说明
|
|
|
+ console.log(appMetaData); // 自定义回调数据
|
|
|
+
|
|
|
+ // todo:处理业务逻辑
|
|
|
+ },
|
|
|
+ appMetaData
|
|
|
+ )
|
|
|
+ },
|
|
|
+ /**
|
|
|
* 输入充值金额
|
|
|
*/
|
|
|
onInput(e) {
|
|
|
@@ -173,80 +243,6 @@
|
|
|
})
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 组合地址,发起支付
|
|
|
- */
|
|
|
- async jsapi() {
|
|
|
- const res = await this.$myRequest({
|
|
|
- host: 'wecard',
|
|
|
- url: '/cgi-bin/pay/app/mppay',
|
|
|
- method: 'POST',
|
|
|
- header: {
|
|
|
- 'content-type': 'application/json'
|
|
|
- },
|
|
|
- data: {
|
|
|
- 'access_token': this.access_token,
|
|
|
- 'sub_appid': this.userinfo.sub_appid,
|
|
|
- 'user_id': this.userinfo.card_number,
|
|
|
- 'order_id': this.order_id = get_order_id(),
|
|
|
- 'amount': this.amount
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- console.log(res)
|
|
|
- console.log(this.access_token)
|
|
|
- console.log(this.userinfo.sub_appid)
|
|
|
- console.log(this.userinfo.card_number)
|
|
|
- console.log(this.order_id)
|
|
|
- console.log(this.amount)
|
|
|
- if (res.data.code == 0) {
|
|
|
- this.pay_info = res.data.data.pay_info
|
|
|
- // 发起支付
|
|
|
- this.pay_amount()
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- icon: 'none',
|
|
|
- title: res.data.message,
|
|
|
- duration: 3000
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- // 调起支付
|
|
|
- pay_amount() {
|
|
|
- var OpenMidas = require("@/static/openMidas.js"); // 引入小程序目录下的SDK文件
|
|
|
-
|
|
|
- // 设置支付配置
|
|
|
- OpenMidas['OpenMidasConfig'] = {
|
|
|
- apiCommonConf: {
|
|
|
- version: "weixiao"
|
|
|
- },
|
|
|
- cgiDomain: {
|
|
|
- // release: "midas.weixiao.qq.com/api", // 私有化参数联系微卡客服进行获取
|
|
|
- test: "midas.weixiao.qq.com/api", // 私有化参数联系微卡客服进行获取
|
|
|
- },
|
|
|
- webDomain: "https://midas.weixiao.qq.com/h5", // 私有化参数联系微卡客服进行获取
|
|
|
- sandboxWebDomain: "https://midas.weixiao.qq.com/h5" // 私有化参数联系微卡客服进行获取
|
|
|
- }
|
|
|
-
|
|
|
- var payInfo = this.pay_info; // 请求mppay接口返回的数据
|
|
|
- var appMetaData = "app=test&version=1.1"; // 自定义回调数据
|
|
|
-
|
|
|
- // OpenMidas.init("release");
|
|
|
- OpenMidas.init("test");
|
|
|
- OpenMidas.pay(
|
|
|
- payInfo,
|
|
|
- function(resultCode, innerCode, resultMsg, appMetaData) {
|
|
|
- console.log(resultCode); // 支付响应状态码
|
|
|
- console.log(innerCode); // 支付响应内部错误码
|
|
|
- console.log(resultMsg); // 支付响应说明
|
|
|
- console.log(appMetaData); // 自定义回调数据
|
|
|
-
|
|
|
- // todo:处理业务逻辑
|
|
|
- },
|
|
|
- appMetaData
|
|
|
- );
|
|
|
- },
|
|
|
/**
|
|
|
* 拨打电话
|
|
|
*/
|
|
|
@@ -277,7 +273,7 @@
|
|
|
// 小于4位数,前补0
|
|
|
// millisecond = millisecond < 1000 ? '00' + millisecond : millisecond
|
|
|
// 小于4位数,前补随机数
|
|
|
- millisecond = millisecond < 1000 ? Math.floor(Math.random() * 999 + 1000) + millisecond : millisecond
|
|
|
+ millisecond = millisecond < 1000 ? Math.floor(Math.random() * 99 + 100) + millisecond : millisecond
|
|
|
|
|
|
return `${year}${month}${day}${hour}${minute}${second}${millisecond}`
|
|
|
}
|