Commit f3019583 by wenyang

APP内支持微信支付功能

parent a12c02f6
......@@ -50,7 +50,7 @@
</view>
</view>
<!-- #ifdef APP-PLUS -->
<!-- <view class="paymentItem" @click="selectPaymentMethod(1)">
<view class="paymentItem" @click="selectPaymentMethod(1)">
<view>
<i class="iconfont icon-py_weixinzhifu"></i>
<text>微信支付</text>
......@@ -58,7 +58,7 @@
<view class="selectRadio" :class="{'actived':paymentMethod===1}">
<i class="iconfont icon-duihao"></i>
</view>
</view> -->
</view>
<!-- #endif -->
</view>
<!-- 底部 -->
......@@ -247,8 +247,53 @@
// #ifdef APP-PLUS
param.paymentType = 1;
api.unifiedPay(param).then(res => {
console.log(res)
//console.log(res)
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
// #ifdef H5
......@@ -257,7 +302,6 @@
if (this.deviceType == 3) {
let _this = this
param.isPayOrAuth = 1;
// } else {
api.wxAuthorize(param).then((res) => {
_this.paymentBtnDisabled = false;
if (res['success']) {
......@@ -269,16 +313,12 @@
} else {
window.location.href = res['data']['paymentForm']['action'];
}
}
})
// }
} else {
//微信二维码支付
//微信二维码支付或者微信H5支付
}
// #endif
} else if (this.paymentMethod == 2) {
// APP:支付宝app支付
// #ifdef APP-PLUS
......@@ -309,7 +349,6 @@
url: `/pages/orderStatus/orderStatus?orderId=${this.orderId}&fileId=${this.fileId}&orderStatus=2&userId=${this.userId}&isRedirect=1`
})
}
} else {
uni.showModal({
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