支付联调

This commit is contained in:
duan
2024-05-24 09:28:14 +08:00
parent dd5adf82b8
commit 7cea9eb628
21 changed files with 254 additions and 170 deletions

View File

@@ -183,7 +183,7 @@
<script>
import webSocketUtils from '@/common/js/websocket.js'
import payPassword from './components/payPassword.vue'
import payPassword from '@/components/payPassword.vue'
export default {
components: {
payPassword
@@ -207,14 +207,19 @@
orderInfo: '',
// 可用优惠券数据
couponAmount: 0,
// 输入支付密码
// 输入支付密码 123
passwordArr: [],
ispws: false
ispws: false,
numValue: 0
};
},
onUnload() {
uni.$off('getMessage')
// uni.showToast({
// title: this.radiovalue1 + '-110',
// duration:5000
// })
},
onLoad(e) {
// 获取用户信息
@@ -232,6 +237,7 @@
// 获取可用优惠券数量
this.getcoupon()
this.vipId = uni.cache.get('userInfo').id
},
onShow() {
@@ -279,6 +285,7 @@ async loginwxuserInfo() {
}
},
getMessage(msg) {
if (msg.status != 'success') {
uni.showToast({
title: msg.msg,
@@ -339,7 +346,7 @@ async loginwxuserInfo() {
},
// 去结算
showpopupclick() {
if (this.numValue == 0) {
let data = { //定义socket数据传参
"skuId": '',
"num": '', //数量
@@ -352,10 +359,11 @@ async loginwxuserInfo() {
"userId": uni.cache.get('userInfo').id,
// tableId:uni.cache.get('tableCode')
}
console.log(data)
this.numValue = 1
uni.$u.debounce(this.socketSendMsg(data), 500)
} else {
this.showpopupclickdd()
}
},
// 去充值
goRecharge() {
@@ -365,6 +373,8 @@ async loginwxuserInfo() {
},
async showpopupclickdd(i) {
console.log(this.radiovalue1, '调试121')
if (this.radiovalue1 == 1) {
let res = await this.api.payorderPay({
orderId: this.listinfoid
@@ -403,16 +413,14 @@ async loginwxuserInfo() {
// });
},
fail: (err) => {
setTimeout(() => {
uni.showToast({
icon: 'none',
title: '支付失败'
})
uni.hideLoading()
}, 2000)
uni.redirectTo({
url: '/pages/order/order_detail?orderId=' + this.listinfoid
});
// uni.redirectTo({
// url: '/pages/order/order_detail?orderId=' + this.listinfoid
// });
},
complete: (data) => {
console.log(data, '成功与否')
@@ -444,22 +452,23 @@ async loginwxuserInfo() {
memberId: this.amountVIP.id,
pwd: pwd
})
console.log(res, '是否支付成功')
if (res.code == 0) {
uni.showToast({
icon: 'none',
title: '支付成功',
success: () => {
setTimeout(()=>{
setTimeout(res => {
uni.redirectTo({
url: '/pages/order/order_detail?orderId=' + this.listinfoid
url: '/pages/order/successful?orderId=' + this
.listinfoid + '&orderInfo=' + JSON.stringify(
this.orderInfo)
});
},2000)
}, 1000)
}
})
}
if(res.data==1){
} else if (res.data == 1) {
setTimeout(() => {
// 去充值
this.goRecharge()

View File

@@ -49,7 +49,7 @@
</view>
<!-- 支付方式 -->
<view class="payType" v-if="false">
<view class="payType">
<view class="">
支付方式
</view>
@@ -77,12 +77,14 @@
</view>
</u-radio>
</u-radio-group>
<view style="font-weight: 400;font-size: 24rpx;color: #333333;">
会员卡余额${{ amount}} <text style="font-weight: 500;font-size: 28rpx;color: #FF4C11;"
<view style="font-weight: 400;font-size: 24rpx;color: #333333;margin-left: 60rpx;">
会员卡余额{{ amountVIP.amount}} <text
style="font-weight: 500;font-size: 28rpx;margin-left: 16rpx;color: #FF4C11;"
@click="goRecharge">去充值</text>
</view>
</view>
</view>
<view class="placeBottom">
<view class="">
<text style="font-size: 24rpx;font-weight: bold;"> 合计 </text><text
@@ -94,11 +96,16 @@
</view>
<button class="btnStyle" @click="sumbitFrom">提交订单</button>
</view>
<payPassword ref="payPwd" @accountPayevent="accountPayevent" v-show="ispws"></payPassword>
</view>
</template>
<script>
import payPassword from '@/components/payPassword.vue'
export default {
components: {
payPassword
},
onLoad(e) {
this.getInfo(e.id)
this.orderIds = e.id
@@ -112,12 +119,55 @@
radiovalue1: '1',
amount: 0,
orderIds: null,
vipId:null
vipId: null,
ispws: false,
amountVIP: null,
}
},
methods: {
async getAount() {
let res = await this.api.shopUserInfo({
// shopId:店铺ID
"shopId":this.info.shopId,
"userId": uni.cache.get('userInfo').id
})
if (res.code == 0) {
this.amountVIP = res.data
}
},
// 余额支付
async accountPayevent(pwd) {
this.ispws = false
let res = await this.api.accountPay({
orderId: this.listinfoid,
memberId: this.amountVIP.id,
pwd: pwd
})
if (res.code == 0) {
uni.showToast({
icon: 'none',
title: '支付成功',
success: () => {
setTimeout(res => {
uni.redirectTo({
url: '/pages/order/successful?orderId=' + this
.listinfoid + '&orderInfo=' + JSON.stringify(
this.orderInfo)
});
}, 1000)
}
})
} else if (res.data == 1) {
setTimeout(() => {
// 去充值
this.goRecharge()
}, 2000)
}
},
goRecharge() {
// uni.pro.to
uni.pro.navigateTo('/pages/member/index', {
shopId_id: uni.cache.get('shopUser')
})
},
async sumbitFrom() {
// radiovalue1:为1的时候微信支付,为2是会员卡,需要输入支付密码
@@ -135,12 +185,29 @@
this.payEvent(res.data.id)
}
} else {
let res = await this.api.accountPay({
orderId: this.orderIds,
memberId:this.vipId
// let res = await this.api.accountPay({
// orderId: this.orderIds,
// memberId:this.vipId
// })
// if (res.code == 0) {
// }
// 先判断是否设置支付密码。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();
})
if (res.code == 0) {
}
}
},
async payEvent(id) {
@@ -184,6 +251,8 @@
})
if (res.code == 0) {
this.info = res.data
// 获取余额
this.getAount()
}
}
}
@@ -296,6 +365,12 @@
>view:last-child {
margin-top: 32rpx;
}
.dfs {
display: flex;
align-items: center;
}
}
.placeBottom {

View File

@@ -94,17 +94,17 @@
if(KeyInfo.keyCode === 8 && this.keyIndex > -1){
this.keyIndex--;
}
this.$emit('KeyInfo',KeyInfo);
// 不是删除键
if(KeyInfo.keyCode != 8){
if(this.passwrdType == 'pay' && this.keyIndex >= 5){
console.log('支付键盘');
console.log(this.keyIndex,'支付键盘');
if( this.keyIndex = 4){
this.keyIndex = -1;
return;
}
this.keyIndex++;
}
KeyInfo.index = this.keyIndex;
this.$emit('KeyInfo',KeyInfo);
}
}
}