diff --git a/api/business/member.js b/api/business/member.js index 0a3f334..4d700de 100644 --- a/api/business/member.js +++ b/api/business/member.js @@ -176,7 +176,6 @@ export function prepayment(data) { params: data }) } - export function saveOrder(data) { return request({ url: '/member/order/uniSaveOrder', diff --git a/pages/mine/coupon/my-coupon.vue b/pages/mine/coupon/my-coupon.vue index f205c6b..0e3f530 100644 --- a/pages/mine/coupon/my-coupon.vue +++ b/pages/mine/coupon/my-coupon.vue @@ -30,7 +30,9 @@ - + + + 购买 @@ -95,12 +97,16 @@ import { getToken } from '@/utils/auth' + import { + getConfigByCode + } from '@/api/system/config.js' export default { components: { navigationBarVue }, data() { return { + payType: 'h5', globalConfig: getApp().globalData.config, menus: ['急招券', '购买记录'], menuIndex: 0, @@ -124,6 +130,7 @@ }, onLoad(option) { this.menuIndex = option.index || 0 + this.getConfigKey() this.initCoupon(); this.initOrder() //获取url中的search @@ -162,6 +169,13 @@ } }, methods: { + getConfigKey() { + getConfigByCode('payType').then(res => { + if (res.msg) { + this.payType = res.msg + } + }) + }, initMyCoupon() { getMemberCoupon().then(res => { this.coupon = res.data @@ -257,7 +271,8 @@ if (res.code == 200) { //吊起支付 let payData = { - orderNo: res.data.orderNo + orderNo: res.data.orderNo, + type: that.payType } prepayment(payData).then(paymentData => { that.wxpay(paymentData) @@ -312,16 +327,47 @@ }, // 检测支付环境中的 WeixinJSBridge wxpay(data) { - if (typeof WeixinJSBridge == "undefined") { - if (document.addEventListener) { - document.addEventListener('WeixinJSBridgeReady', onBridgeReady(data), false); - } else if (document.attachEvent) { - document.attachEvent('WeixinJSBridgeReady', onBridgeReady(data)); - document.attachEvent('onWeixinJSBridgeReady', onBridgeReady(data)); + if (this.payType == 'h5') { + if (typeof WeixinJSBridge == "undefined") { + if (document.addEventListener) { + document.addEventListener('WeixinJSBridgeReady', onBridgeReady(data), false); + } else if (document.attachEvent) { + document.attachEvent('WeixinJSBridgeReady', onBridgeReady(data)); + document.attachEvent('onWeixinJSBridgeReady', onBridgeReady(data)); + } + } else { + this.onBridgeReady(data); } } else { - this.onBridgeReady(data); + console.log(data, 381); + uni.requestPayment({ + provider: 'wxpay', // 支付提供商 + timeStamp: data.timeStamp + '', // 时间戳 + nonceStr: data.nonceStr, // 随机字符串 + appId: data.appId, + package: data.packageVal, // 统一下单接口返回的prepay_id参数值 + signType: data.signType, // 签名算法 + paySign: data.paySign, // 签名 + success: (res) => { + // 支付成功回调 + uni.showToast({ + title: "支付成功", + icon: "success", + duration: 2000 + + }) + }, + fail: (err) => { + console.log(err, 160); + // 支付失败回调 + uni.showToast({ + title: "支付失败,请联系管理员!", + icon: "none" + }) + } + }); } + }, onBridgeReady(data) { diff --git a/pages/mine/member/member-card.vue b/pages/mine/member/member-card.vue index aae2a4f..3fc145b 100644 --- a/pages/mine/member/member-card.vue +++ b/pages/mine/member/member-card.vue @@ -33,9 +33,9 @@ - + - + 立即开通 @@ -77,6 +77,9 @@