diff --git a/api/order.js b/api/order.js index 29beff4..49cb8fd 100644 --- a/api/order.js +++ b/api/order.js @@ -9,6 +9,14 @@ // +---------------------------------------------------------------------- import request from "@/utils/request.js"; +/** + * 校验支付密码是否正确 + * @param numType + */ +export function verifyPwd(data) { + return request.post("order/verifyPwd", data); +} + /** * 上传对公账户凭证 * @param numType boolean true 购物车数量,false=购物车产品数量 diff --git a/components/payPwd/index.vue b/components/payPwd/index.vue new file mode 100644 index 0000000..fdf46c7 --- /dev/null +++ b/components/payPwd/index.vue @@ -0,0 +1,92 @@ + + + + + + \ No newline at end of file diff --git a/components/payment/index.vue b/components/payment/index.vue index 280bfa8..c4e609c 100644 --- a/components/payment/index.vue +++ b/components/payment/index.vue @@ -4,8 +4,8 @@ 选择付款方式 - + @@ -20,6 +20,12 @@ + + + + + + @@ -36,9 +42,16 @@ import { orderPay, integralOrderPay, - presellOrderPay + presellOrderPay, + verifyPwd } from '@/api/order.js'; + import payPwd from "@/components/payPwd/index.vue"; + import popups from "@/components/popups/index.vue"; export default { + components: { + payPwd, + popups + }, props: { payMode: { type: Array, @@ -73,12 +86,10 @@ }, data() { return { - + type: '' }; }, - mounted:function(){ - - }, + methods: { close: function() { this.$emit('onChangeFun', { @@ -106,13 +117,15 @@ // #endif } else if (paytype == 'balance') { type = 'balance'; - }else if(paytype == 'alipay'){ + } else if (paytype == 'alipay') { // #ifndef MP type = 'alipay'; // #endif // #ifdef MP type = 'alipayQr'; // #endif + } else if (paytype == 'public') { + type = 'public'; } if (!that.order_id) return that.$util.Tips({ title: '请选择要支付的订单' @@ -120,14 +133,72 @@ if (paytype == 'balance' && parseFloat(number) < parseFloat(that.totalPrice)) return that.$util.Tips({ title: '余额不足!' }); - uni.showLoading({ - title: '支付中' + + this.type = type; + + if (paytype == 'balance' || paytype == 'merBalance') { + this.$refs.popups.handleOpen(); + } else { + uni.showLoading({ + title: '订单支付中' + }); + this.trueOrderPay(); + } + }, + + // 输入密码回调 + handleConfirm(e) { + // 验证密码是否正确 + verifyPwd({ + withdrawal_pwd: e + }).then(res => { + // 密码是否有效 状态码判断 + const code = res.data.code; + + if (code == 100) { //密码正确 + uni.showLoading({ + title: '订单支付中', + mask: true + }); + this.trueOrderPay(); + } else { + this.$refs.payPwd.handleOpen(code); + } + }).catch(err => { + console.log(err) + }) + }, + + handleClear() {}, + handleChange() {}, + + // 弹框左边按钮 101 未设置密码 102 忘记密码 都去设置密码 + handleLeft(code) { + uni.navigateTo({ + url: "/pages/users/user_modify_pwd/index?type=payPwd" }); - let orderApi = that.order_type === 1 ? presellOrderPay : that.order_type === 2 ? integralOrderPay : orderPay + this.$refs.payPwd.handleClose(); + }, + + // 弹框右边按钮 取消 重试 + handleRight(code) { + if (code == 101) { //取消 + this.$refs.payPwd.handleClose(code); + } else { + this.$refs.payPwd.handleClose(); + this.$refs.popups.handleOpen(); + } + }, + + trueOrderPay() { + let that = this; + let orderApi = that.order_type === 1 ? presellOrderPay : that.order_type === 2 ? integralOrderPay : + orderPay orderApi(that.order_id, { - type: type, + type: that.type, // #ifdef H5 - return_url: that.returnUrl!=='' ? 'http://'+window.location.host+that.returnUrl : 'http://'+window.location.host+'/pages/users/order_list/index', + return_url: that.returnUrl !== '' ? 'http://' + window.location.host + that.returnUrl : + 'http://' + window.location.host + '/pages/users/order_list/index', // #endif }).then(res => { let status = res.data.status, @@ -135,7 +206,7 @@ jsConfig = res.data.result.config, callback_key = res.data.result.pay_key, goPages = that.returnUrl ? that.returnUrl : '/pages/users/order_list/index'; - switch (status) { + switch (status) { case 'ORDER_EXIST': case 'EXTEND_ORDER': case 'PAY_ERROR': @@ -146,13 +217,13 @@ }); return that.$util.Tips({ title: res.message - }); + }); break; case 'success': uni.hideLoading(); this.$emit('onChangeFun', { action: 'payClose' - }); + }); return that.$util.Tips({ title: '支付成功', icon: 'success' @@ -166,20 +237,21 @@ uni.hideLoading(); this.$emit('onChangeFun', { action: 'payClose' - }); + }); uni.navigateTo({ - url: '/pages/order_pay_back/index?keyCode='+callback_key+'&url='+jsConfig, - }) - return - break; - // #ifndef MP + url: '/pages/order_pay_back/index?keyCode=' + callback_key + '&url=' + + jsConfig, + }) + return + break; + // #ifndef MP case "wechat": case "weixin": case "weixinApp": jsConfig.timeStamp = jsConfig.timestamp; // #ifndef APP-PLUS - that.$wechat.pay(jsConfig).then(res => { - console.log('测试支付数据无效的success:'+res.data) + that.$wechat.pay(jsConfig).then(res => { + console.log('测试支付数据无效的success:' + res.data) this.$emit('onChangeFun', { action: 'payClose' }); @@ -187,34 +259,34 @@ return that.$util.Tips({ title: '支付成功', icon: 'success' - }, { + }, { tab: 5, url: goPages + 'status=1' }); }).catch(res => { - console.log('测试支付数据无效的catch:'+res.data) - if (res.errMsg == 'chooseWXPay:cancel'){ - if(that.isCall){ + console.log('测试支付数据无效的catch:' + res.data) + if (res.errMsg == 'chooseWXPay:cancel') { + if (that.isCall) { return that.$util.Tips({ title: '取消支付' }); - }else{ + } else { return that.$util.Tips({ title: '取消支付' - }, { + }, { tab: 5, url: goPages + '?status=0' }); } - } + } }) // #endif // #ifdef APP-PLUS - let mp_pay_name='' - if(uni.requestOrderPayment){ - mp_pay_name='requestOrderPayment' - }else{ - mp_pay_name='requestPayment' + let mp_pay_name = '' + if (uni.requestOrderPayment) { + mp_pay_name = 'requestOrderPayment' + } else { + mp_pay_name = 'requestPayment' } uni[mp_pay_name]({ provider: 'wxpay', @@ -226,20 +298,20 @@ return that.$util.Tips({ title: '支付成功', icon: 'success' - }, { + }, { tab: 5, url: goPages + 'status=1' }); }, fail: (e) => { - if(that.isCall){ + if (that.isCall) { return that.$util.Tips({ title: '取消支付' }); - }else{ + } else { return that.$util.Tips({ title: '取消支付' - }, { + }, { tab: 5, url: goPages + '?status=0' }); @@ -251,16 +323,16 @@ }); // #endif break; - // #endif - // #ifdef MP + // #endif + // #ifdef MP case "routine": jsConfig.timeStamp = jsConfig.timestamp; that.toPay = true; - let mp_pay_name='' - if(uni.requestOrderPayment){ - mp_pay_name='requestOrderPayment' - }else{ - mp_pay_name='requestPayment' + let mp_pay_name = '' + if (uni.requestOrderPayment) { + mp_pay_name = 'requestOrderPayment' + } else { + mp_pay_name = 'requestPayment' } uni[mp_pay_name]({ ...jsConfig, @@ -269,19 +341,20 @@ that.$emit('onChangeFun', { action: 'payClose' }); - if (that.BargainId || that.combinationId || that.pinkId || that.seckillId) + if (that.BargainId || that.combinationId || that.pinkId || that + .seckillId) return that.$util.Tips({ title: '支付成功', icon: 'success' - }, { + }, { tab: 5, url: goPages + '?status=1' }); - + return that.$util.Tips({ title: '支付成功', icon: 'success' - }, { + }, { tab: 5, url: goPages + '?status=1' }); @@ -296,7 +369,7 @@ }); }, complete: function(e) { - uni.hideLoading(); + uni.hideLoading(); //关闭当前页面跳转至订单状态 if (res.errMsg == 'requestPayment:cancel') return that.$util.Tips({ title: '取消支付' @@ -307,7 +380,7 @@ }, }) break; - // #endif + // #endif case "balance": uni.hideLoading(); that.$emit('onChangeFun', { @@ -318,9 +391,19 @@ title: res.message }); break; - // #ifdef H5 + // #ifdef H5 + case "public": + uni.hideLoading(); + that.$emit('onChangeFun', { + action: 'payClose' + }); + //余额不足 + return that.$util.Tips({ + title: "下单成功,请上传付款凭证!" + }); + break; case 'h5': - let host = window.location.protocol+"//"+window.location.host; + let host = window.location.protocol + "//" + window.location.host; let url = `${host}/pages/order_pay_status/index?order_id=${orderId}` let eUrl = encodeURIComponent(url) let jsurl = jsConfig.mweb_url || jsConfig.h5_url @@ -329,9 +412,9 @@ location.href = locations; }, 100); break; - // #endif - - // #ifdef APP-PLUS + // #endif + + // #ifdef APP-PLUS case 'alipayApp': uni.requestPayment({ provider: 'alipay', @@ -343,11 +426,11 @@ return that.$util.Tips({ title: '支付成功', icon: 'success' - }, { + }, { tab: 5, url: goPages + 'status=1' }); - + }, fail: (e) => { return that.$util.Tips({ @@ -358,8 +441,8 @@ uni.hideLoading(); }, }); - break; - // #endif + break; + // #endif } }).catch(err => { uni.hideLoading(); @@ -463,4 +546,4 @@ font-size: 0.3rpx; color: #999; } - + \ No newline at end of file diff --git a/components/popups/index.vue b/components/popups/index.vue index cd3a3aa..7368a9b 100644 --- a/components/popups/index.vue +++ b/components/popups/index.vue @@ -1,37 +1,80 @@ - \ No newline at end of file diff --git a/mixins/password.js b/mixins/password.js new file mode 100644 index 0000000..e69de29 diff --git a/pages/payment/get_payment.vue b/pages/payment/get_payment.vue index 8638768..5db7432 100644 --- a/pages/payment/get_payment.vue +++ b/pages/payment/get_payment.vue @@ -63,9 +63,9 @@ -