扫码支付
This commit is contained in:
@@ -176,12 +176,18 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 支付密码 -->
|
||||
<payPassword ref="payPwd" @accountPayevent="accountPayevent" v-show="ispws"></payPassword>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import webSocketUtils from '@/common/js/websocket.js'
|
||||
import payPassword from './components/payPassword.vue'
|
||||
export default {
|
||||
components: {
|
||||
payPassword
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
height: '',
|
||||
@@ -200,7 +206,10 @@
|
||||
vipId: null,
|
||||
orderInfo: '',
|
||||
// 可用优惠券数据
|
||||
couponAmount: 0
|
||||
couponAmount: 0,
|
||||
// 输入支付密码
|
||||
passwordArr: [],
|
||||
ispws: false
|
||||
};
|
||||
},
|
||||
|
||||
@@ -208,6 +217,8 @@
|
||||
uni.$off('getMessage')
|
||||
},
|
||||
onLoad(e) {
|
||||
// 获取用户信息
|
||||
this.loginwxuserInfo()
|
||||
// console.log(e, 140)
|
||||
let res = JSON.parse(e.tableId)
|
||||
this.listinfo.detailList = res
|
||||
@@ -239,6 +250,14 @@
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
async loginwxuserInfo() {
|
||||
let res = await this.api.loginwxuserInfo({
|
||||
userId: uni.cache.get('userInfo').id
|
||||
})
|
||||
if (res.code == 0) {
|
||||
uni.cache.set('userInfo', res.data);
|
||||
}
|
||||
},
|
||||
async getcoupon() {
|
||||
let res = await this.api.userCoupon({
|
||||
"orderNum": this.listinfo.amount,
|
||||
@@ -344,45 +363,19 @@
|
||||
shopId_id: uni.cache.get('shopUser')
|
||||
})
|
||||
},
|
||||
// 余额支付
|
||||
async accountPayevent(id) {
|
||||
console.log(this.amountVIP, '会员信息')
|
||||
|
||||
let res = await this.api.accountPay({
|
||||
orderId: id,
|
||||
memberId: this.vipId
|
||||
})
|
||||
console.log(res, '调试12')
|
||||
if (res) {
|
||||
this.ispayPws()
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
this.goRecharge()
|
||||
}, 1000)
|
||||
}
|
||||
},
|
||||
// 是否有支付密码
|
||||
ispayPws() {
|
||||
// 先判断是否设置支付密码。0是没设置。没设置的情况下跳转到设置页面。有的话输入支付密码
|
||||
if (this.amountVIP.isPwd == 0) {
|
||||
uni.pro.navigateTo('/pages/user/repairpassword', {
|
||||
shopId_id: uni.cache.get('shopUser')
|
||||
})
|
||||
} else {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
async showpopupclickdd(i) {
|
||||
let res = await this.api.payorderPay({
|
||||
orderId: this.listinfoid
|
||||
}) //判断是否支付成功
|
||||
if (res.code == 0) {
|
||||
uni.showLoading({
|
||||
title: '加载中',
|
||||
mask: true
|
||||
})
|
||||
// #ifdef MP-WEIXIN
|
||||
if (this.radiovalue1 == 1) {
|
||||
if (this.radiovalue1 == 1) {
|
||||
let res = await this.api.payorderPay({
|
||||
orderId: this.listinfoid
|
||||
}) //判断是否支付成功
|
||||
if (res.code == 0) {
|
||||
// uni.showLoading({
|
||||
// title: '加载中',
|
||||
// mask: true
|
||||
// })
|
||||
// #ifdef MP-WEIXIN
|
||||
// 微信支付还是余额支付
|
||||
uni.requestPayment({
|
||||
provider: 'wxpay', //支付类型-固定值
|
||||
partnerid: res.data.appId, // 微信支付商户号
|
||||
@@ -395,7 +388,7 @@
|
||||
uni.showToast({
|
||||
title: "支付成功"
|
||||
})
|
||||
uni.cache.set('shopUser','')//删除shopUser
|
||||
uni.cache.set('shopUser', '') //删除shopUser
|
||||
this.paymodfiyOrderInfo()
|
||||
setTimeout(res => {
|
||||
uni.redirectTo({
|
||||
@@ -425,25 +418,61 @@
|
||||
console.log(data, '成功与否')
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 判断是否有绑定支付密码
|
||||
let isVip = uni.cache.get('userInfo').isPwd
|
||||
console.log(isVip,'调试 123')
|
||||
if (isVip == 0) {
|
||||
uni.pro.navigateTo('/pages/user/repairpassword', {
|
||||
shopId_id: uni.cache.get('shopUser')
|
||||
})
|
||||
} else {
|
||||
this.accountPayevent(this.listinfoid)
|
||||
}
|
||||
// #endif
|
||||
}
|
||||
} else {
|
||||
// 判断是否有绑定支付密码
|
||||
// 先判断是否设置支付密码。0是没设置。没设置的情况下跳转到设置页面。有的话输入支付密码
|
||||
let isVip = uni.cache.get('userInfo').isPwd
|
||||
if (isVip == 0) {
|
||||
uni.pro.navigateTo('/pages/user/repairpassword', {
|
||||
// shopId_id: uni.cache.get('shopUser')
|
||||
})
|
||||
} else {
|
||||
this.ispws = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs.payPwd.onPayUp();
|
||||
})
|
||||
}
|
||||
|
||||
// #endif
|
||||
}
|
||||
},
|
||||
// 余额支付
|
||||
async accountPayevent(pwd) {
|
||||
this.ispws = false
|
||||
let res = await this.api.accountPay({
|
||||
orderId: this.listinfoid,
|
||||
memberId: this.amountVIP.id,
|
||||
pwd: pwd
|
||||
})
|
||||
console.log(res, '是否支付成功')
|
||||
if(res.code ==0){
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '支付成功',
|
||||
success:()=>{
|
||||
setTimeout(()=>{
|
||||
uni.redirectTo({
|
||||
url: '/pages/order/order_detail?orderId=' + this.listinfoid
|
||||
});
|
||||
},2000)
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
if(res.data==1){
|
||||
setTimeout(() => {
|
||||
// 去充值
|
||||
this.goRecharge()
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
clickselect(b) {
|
||||
this.pay_type = b
|
||||
},
|
||||
|
||||
},
|
||||
mounted() {
|
||||
//#ifdef MP-WEIXIN || H5
|
||||
|
||||
Reference in New Issue
Block a user