Feat(订单):使用积分逻辑调整

This commit is contained in:
lifizer
2024-04-22 16:18:47 +08:00
parent 82bff005c4
commit c0bf4ed2c9
3 changed files with 78 additions and 17 deletions
+1 -1
View File
@@ -3423,7 +3423,7 @@ page {
.order-details .wrapper .item .conter {
color: #868686;
width: 5*100rpx;
width: 4.5*100rpx;
text-align: right;
}
+68 -15
View File
@@ -171,7 +171,24 @@
<view class="money">-{{ force2Decimal(orderPrice.deductionPrice) }}</view>
</view>
</view>
<view class="coupon-cell">
<view class="flex jc-between ai-center">
<view class="title">积分抵扣</view>
<view class="flex ai-center">
<u-switch
v-model="usePointsCheck"
size="20"
@change="usePointsCheckChange"
/>
</view>
</view>
<view v-if="usePointsCheck" class="flex jc-between ai-center points-cell">
<view>积分{{ orderPrice.usedPoints }}</view>
<view class="flex ai-center">
-{{ force2Decimal(orderPrice.deductionPrice) }}
</view>
</view>
</view>
<view class="coupon-cell flex jc-between ai-center" @click="changeCoupons">
<view class="title">优惠券</view>
<view class="flex ai-center">
@@ -204,23 +221,27 @@
<view class="footer acea-row row-between-wrapper" style="height: 80rpx;">
<view style="margin-left: 30rpx;">
<text style="color: #000000;font-size: 24rpx;font-weight: bold;">合计:</text>
<text class="" style="color: #FF564A;font-size: 28rpx;font-weight: bold;">{{
force2Decimal(orderPrice.payPrice)
}}
<text class="" style="color: #FF564A;font-size: 28rpx;font-weight: bold;">
{{ force2Decimal(orderPrice.payPrice) }}
</text>
</view>
<view class="settlement acea-row row-middle row-center" @click="subscribePay">立即结算</view>
</view>
<AddressWindow
@checked="changeAddress"
@redirect="addressRedirect"
v-model="showAddress"
:checked="addressInfo.id"
ref="mychild"
></AddressWindow>
<passkeyborad :money="orderPrice.payPrice" showMoney :show="isShowPayPwdPop" ref='payPwdPop' @close="pwdPopClose"
@finish="pwdPopFinish"></passkeyborad>
v-model="showAddress"
ref="mychild"
:checked="addressInfo.id"
@checked="changeAddress"
@redirect="addressRedirect"
/>
<passkeyborad
ref='payPwdPop'
showMoney
:money="orderPrice.payPrice"
:show="isShowPayPwdPop"
@close="pwdPopClose"
@finish="pwdPopFinish"
/>
</view>
</template>
@@ -288,7 +309,15 @@ export default {
},
couponId: uni.getStorageSync('couponId') || 0,
couponIndex: -1,
show: false
show: false,
// 是否使用积分开关
usePointsCheck: false,
// 要使用的积分数量(传0为不使用积分,目前需求是默认使用最大可使用的积分,所以只要传大于0的数值都会变为自动使用最大可用积分)
usePointsNumber: 0,
// 订单是否可以使用积分
canUsePoints: false,
// 订单最大可使用积分数量
maxPoints: 0
};
},
computed: mapGetters(["userInfo", "storeItems"]),
@@ -344,13 +373,17 @@ export default {
force2Decimal(value) {
return this.$force2Decimal(value);
},
usePointsCheckChange(e) {
this.computedPrice()
},
// 计算订单金额
computedPrice(f) {
console.log(f)
let shipping_type = this.shipping_type;
postOrderComputed(this.orderGroupInfo.orderKey, {
addressId: this.addressInfo.id,
useIntegral: this.useIntegral ? 1 : 0,
couponId: this.couponId || 0,
usePoints: this.usePointsCheck ? 1 : 0,
shipping_type: parseInt(shipping_type) + 1
}).then(res => {
const data = res.data;
@@ -363,6 +396,11 @@ export default {
});
} else {
this.orderPrice = data.result;
if (this.usePointsCheck) {
this.usePointsNumber = data.result.usedPoints
} else {
this.usePointsNumber = 0
}
}
});
},
@@ -391,6 +429,16 @@ export default {
item.checked = false
}
})
uni.removeStorageSync('couponId')
} else {
uni.removeStorageSync('couponId')
}
_this.canUsePoints = data.canUsePoints
_this.maxPoints = data.maxPoints
// 如果允许使用积分,则默认开启
if (data.canUsePoints) {
_this.usePointsCheck = true
_this.usePointsNumber = data.maxPoints
}
_this.addressInfo = data.addressInfo || {}
_this.systemStore = data.systemStore || {}
@@ -534,6 +582,7 @@ export default {
addressId: this.addressInfo.id,
useIntegral: this.useIntegral ? 1 : 0,
couponId: this.couponId || 0,
usePoints: this.usePointsNumber || 0,
payType: this.active,
pinkId: this.pinkId,
seckillId: this.orderGroupInfo.seckill_id,
@@ -826,4 +875,8 @@ export default {
background-color: #FFFFFF;
font-size: 24rpx;
}
.points-cell {
padding: 20rpx 0 0 0;
color: #999;
}
</style>
+9 -1
View File
@@ -68,6 +68,7 @@
</view>
</view>
<view v-else class="lottery">
<image :src="webUrl + '/points-lottery.png'" class="img" />
<view class="one-t title">
{{ item.title }}
</view>
@@ -312,9 +313,16 @@ export default {
}
.lottery {
display: flex;
align-items: center;
padding: 20rpx;
.img {
display: block;
width: 62rpx;
height: 62rpx;
margin: 0 20rpx 0 0;
}
.title {
width: calc(100% - 160rpx);
flex: 1;
}
}
.number {