支付联调

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

@@ -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,14 +96,19 @@
</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
this.orderIds = e.id
this.amount = uni.cache.get('userInfo').amount
this.vipId = uni.cache.get('userInfo').id
},
@@ -111,13 +118,56 @@
Quantity: 1,
radiovalue1: '1',
amount: 0,
orderIds:null,
vipId:null
orderIds: 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是会员卡,需要输入支付密码
@@ -134,13 +184,30 @@
// 调用支付接口
this.payEvent(res.data.id)
}
}else{
let res = await this.api.accountPay({
orderId: this.orderIds,
memberId:this.vipId
})
if (res.code == 0) {
} else {
// 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();
})
}
}
},
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 {