优化代码

This commit is contained in:
duan
2024-05-27 16:58:04 +08:00
parent d67ab4d9b6
commit 91d22d5e7d
9 changed files with 521 additions and 28 deletions

View File

@@ -49,7 +49,7 @@
</view>
<!-- 支付方式 -->
<view class="payType" >
<view class="payType">
<view class="">
支付方式
</view>
@@ -65,7 +65,8 @@
</text>
</view>
</u-radio>
<view style="margin: 22rpx 0;width: 100%;height: 2rpx;background-color: #E5E5E5;" v-if="info.isUseVip==1"> </view>
<view style="margin: 22rpx 0;width: 100%;height: 2rpx;background-color: #E5E5E5;"
v-if="info.isUseVip==1"> </view>
<u-radio activeColor="#ffd158" name="2" v-if="info.isUseVip==1">
<view class="dfs">
<image style="width:44rpx;height:44rpx"
@@ -76,7 +77,8 @@
</view>
</u-radio>
</u-radio-group>
<view style="font-weight: 400;font-size: 24rpx;color: #333333;margin-left: 60rpx;" v-if="info.isUseVip==1">
<view style="font-weight: 400;font-size: 24rpx;color: #333333;margin-left: 60rpx;"
v-if="info.isUseVip==1">
会员卡余额{{ amountVIP.amount}} <text
style="font-weight: 500;font-size: 28rpx;margin-left: 16rpx;color: #FF4C11;"
@click="goRecharge">去充值</text>
@@ -94,7 +96,7 @@
<view class="">
{{Quantity}} 已优惠{{calculateEvent(info.save) }}
</view>
<button class="btnStyle" @click="sumbitFroms">提交订单</button>
<button class="btnStyle" @click="fangdouevent">提交订单</button>
</view>
<payPassword ref="payPwd" @accountPayevent="accountPayevent" v-show="ispws"></payPassword>
</view>
@@ -108,8 +110,6 @@
},
onLoad(e) {
this.getInfo(e.id)
this.orderIds = e.id
this.amount = uni.cache.get('userInfo').amount
this.vipId = uni.cache.get('userInfo').id
@@ -136,7 +136,7 @@
})
if (res.code == 0) {
this.amountVIP = res.data
}
},
// 余额支付
@@ -149,9 +149,9 @@
})
if (res.code == 0) {
let orderInfo = {
createdAt:this.listinfoid.createTime,
orderNo:this.listinfoid.orderNo,
orderAmount:this.calculateEvent(this.info.salePrice)
createdAt: this.listinfoid.createTime,
orderNo: this.listinfoid.orderNo,
orderAmount: this.calculateEvent(this.info.salePrice)
}
uni.showToast({
icon: 'none',
@@ -160,7 +160,8 @@
setTimeout(res => {
uni.redirectTo({
url: '/pages/order/successful?orderId=' + this
.listinfoid.id + '&orderInfo=' + JSON.stringify(orderInfo)
.listinfoid.id + '&orderInfo=' + JSON.stringify(
orderInfo)
});
}, 1000)
}
@@ -173,16 +174,17 @@
}
},
calculateEvent(d) {
return (d * 1000 * this.Quantity)/1000
return (d * 1000 * this.Quantity) / 1000
},
goRecharge() {
uni.pro.navigateTo('/pages/member/index', {
shopId_id: this.info.shopId
})
},
// 防抖
sumbitFroms(){
uni.$u.throttle(this.sumbitFrom, 500)
fangdouevent() {
this.$u.debounce(() => {
this.sumbitFrom()
}, 1000)
},
async sumbitFrom() {
let payMoney = this.info.salePrice * this.Quantity
@@ -201,7 +203,7 @@
this.payEvent(res.data.id)
} else {
// 先判断是否设置支付密码。0是没设置。没设置的情况下跳转到设置页面。有的话输入支付密码
let isVip = uni.cache.get('userInfo').isPwd
let isVip = uni.cache.get('userInfo').isPwd
if (isVip == 0) {
uni.pro.navigateTo('/pages/user/repairpassword', {
shopId_id: uni.cache.get('shopUser')