Commit f3019583 by wenyang

APP内支持微信支付功能

parent a12c02f6
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</view> </view>
</view> </view>
<!-- #ifdef APP-PLUS --> <!-- #ifdef APP-PLUS -->
<!-- <view class="paymentItem" @click="selectPaymentMethod(1)"> <view class="paymentItem" @click="selectPaymentMethod(1)">
<view> <view>
<i class="iconfont icon-py_weixinzhifu"></i> <i class="iconfont icon-py_weixinzhifu"></i>
<text>微信支付</text> <text>微信支付</text>
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
<view class="selectRadio" :class="{'actived':paymentMethod===1}"> <view class="selectRadio" :class="{'actived':paymentMethod===1}">
<i class="iconfont icon-duihao"></i> <i class="iconfont icon-duihao"></i>
</view> </view>
</view> --> </view>
<!-- #endif --> <!-- #endif -->
</view> </view>
<!-- 底部 --> <!-- 底部 -->
...@@ -247,8 +247,53 @@ ...@@ -247,8 +247,53 @@
// #ifdef APP-PLUS // #ifdef APP-PLUS
param.paymentType = 1; param.paymentType = 1;
api.unifiedPay(param).then(res => { api.unifiedPay(param).then(res => {
console.log(res) //console.log(res)
this.paymentBtnDisabled = false; this.paymentBtnDisabled = false;
if (res['success']) {
const prepayId = res['data']['prepayId'];//统一下单订单号 如果为空,代表0元订单支付成功
if(prepayId){
const orderInfoParam = {
"appid": res['data']['appid'], // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
"noncestr": res['data']['noncestr'], // 随机字符串
"package": res['data']['packAge'], // 固定值
"partnerid": res['data']['partnerid'], // 微信支付商户号
"prepayid": prepayId, // 统一下单订单号
"timestamp": res['data']['timeStamp'], // 时间戳(单位:秒)
"sign": res['data']['sign'] // 签名,这里用的 MD5/RSA 签名
}
let _this = this
uni.requestPayment({
provider: 'wxpay',
orderInfo: orderInfoParam,
success: function(resp) {
uni.navigateTo({
url: `/pages/orderStatus/orderStatus?orderId=${_this.orderId}&fileId=${_this.fileId}&orderStatus=2&userId=${_this.userId}&isRedirect=1`
})
},
fail: function(err) {
//console.log('fail:' + JSON.stringify(err));
uni.navigateTo({
url: `/pages/orderStatus/orderStatus?orderId=${_this.orderId}&fileId=${_this.fileId}&orderStatus=1&userId=${_this.userId}&isRedirect=1`
})
}
});
}else {
uni.navigateTo({
url: `/pages/orderStatus/orderStatus?orderId=${this.orderId}&fileId=${this.fileId}&orderStatus=2&userId=${this.userId}&isRedirect=1`
})
}
} else {
uni.showModal({
content: res['message'],
success: function(res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
}
}) })
// #endif // #endif
// #ifdef H5 // #ifdef H5
...@@ -257,7 +302,6 @@ ...@@ -257,7 +302,6 @@
if (this.deviceType == 3) { if (this.deviceType == 3) {
let _this = this let _this = this
param.isPayOrAuth = 1; param.isPayOrAuth = 1;
// } else {
api.wxAuthorize(param).then((res) => { api.wxAuthorize(param).then((res) => {
_this.paymentBtnDisabled = false; _this.paymentBtnDisabled = false;
if (res['success']) { if (res['success']) {
...@@ -269,16 +313,12 @@ ...@@ -269,16 +313,12 @@
} else { } else {
window.location.href = res['data']['paymentForm']['action']; window.location.href = res['data']['paymentForm']['action'];
} }
} }
}) })
// }
} else { } else {
//微信二维码支付 //微信二维码支付或者微信H5支付
} }
// #endif // #endif
} else if (this.paymentMethod == 2) { } else if (this.paymentMethod == 2) {
// APP:支付宝app支付 // APP:支付宝app支付
// #ifdef APP-PLUS // #ifdef APP-PLUS
...@@ -309,7 +349,6 @@ ...@@ -309,7 +349,6 @@
url: `/pages/orderStatus/orderStatus?orderId=${this.orderId}&fileId=${this.fileId}&orderStatus=2&userId=${this.userId}&isRedirect=1` url: `/pages/orderStatus/orderStatus?orderId=${this.orderId}&fileId=${this.fileId}&orderStatus=2&userId=${this.userId}&isRedirect=1`
}) })
} }
} else { } else {
uni.showModal({ uni.showModal({
content: res['message'], content: res['message'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment