支付联调

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

View File

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

View File

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