|
@@ -48,8 +48,13 @@ import AddDiscount from './add-discount'
|
|
|
/** 保留两位小数向上取整 */
|
|
|
export const numberToTwoUp = (num: number | string) => {
|
|
|
num = Number(num)
|
|
|
+ return Math.ceil(Number((num * 100).toFixed(1))) / 100
|
|
|
+}
|
|
|
|
|
|
- return Math.ceil(num * 100) / 100
|
|
|
+/** 保留两位小数向下取整 */
|
|
|
+export const numberToTwoDown = (num: number | string) => {
|
|
|
+ num = Number(num)
|
|
|
+ return Math.floor(Number((num * 100).toFixed(1))) / 100
|
|
|
}
|
|
|
|
|
|
export default defineComponent({
|
|
@@ -63,7 +68,7 @@ export default defineComponent({
|
|
|
dialogBtnText: '确定',
|
|
|
dialogType: 'back' as 'back' | 'refresh',
|
|
|
orderType: query.orderType as string,
|
|
|
- orderGoodsType: [],
|
|
|
+ orderGoodsType: [] as any[],
|
|
|
recomUserId: query.recomUserId, // 推荐人id
|
|
|
activityId: query.activityId, // 活动编号
|
|
|
id: query.id,
|
|
@@ -117,7 +122,7 @@ export default defineComponent({
|
|
|
},
|
|
|
countDiscountPrice() {
|
|
|
const orderObject = orderStatus.orderObject
|
|
|
- return orderObject.couponAmount || numberToTwoUp(orderObject.couponDiscountPrice + orderObject.discountCardPrice + orderObject.discountCardPrice)
|
|
|
+ return orderObject.couponAmount || numberToTwoDown(orderObject.couponDiscountPrice + orderObject.discountPrice + orderObject.discountCardPrice)
|
|
|
}
|
|
|
},
|
|
|
async mounted() {
|
|
@@ -166,6 +171,7 @@ export default defineComponent({
|
|
|
|
|
|
this.orderAmount = orderStatus.orderObject.actualPrice || 0
|
|
|
this.orderPrice = orderStatus.orderObject.actualPrice || 0
|
|
|
+ console.log(this.orderAmount, this.orderPrice, 'orderPrice')
|
|
|
|
|
|
this.disabledCoupon = orderStatus.orderObject.orderNo ? true : false
|
|
|
this.dataLoading = false
|
|
@@ -637,12 +643,14 @@ export default defineComponent({
|
|
|
vipType: string
|
|
|
}) => {
|
|
|
// 畅学卡变更状态时需要重新选择优惠券
|
|
|
+ // debugger
|
|
|
orderStatus.orderObject.couponId = ''
|
|
|
orderStatus.orderObject.couponDiscountPrice = 0
|
|
|
// 是否选中畅学卡
|
|
|
const index = this.selectGoods?.findIndex(
|
|
|
(child: any) => child.id === item.id
|
|
|
)
|
|
|
+ const tempType = this.orderGoodsType
|
|
|
if (item.checked) {
|
|
|
orderStatus.orderObject.discountCardPrice = Number(
|
|
|
item.discountPrice
|
|
@@ -655,15 +663,34 @@ export default defineComponent({
|
|
|
num: 1,
|
|
|
id: item.id
|
|
|
})
|
|
|
+ const typeIndex = tempType.findIndex((child: any) => child === item.vipType)
|
|
|
+ if(typeIndex === -1) {
|
|
|
+ tempType.push(item.vipType)
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
orderStatus.orderObject.discountCardPrice = 0
|
|
|
if (index !== -1) {
|
|
|
this.selectGoods.splice(index, 1)
|
|
|
this.orderAmount = this.orderAmount - item.salePrice
|
|
|
+
|
|
|
+ const typeIndex = tempType.findIndex((child: any) => child === item.vipType)
|
|
|
+ if(typeIndex !== -1) {
|
|
|
+ tempType.splice(typeIndex, 1)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ this.orderGoodsType = tempType
|
|
|
|
|
|
+ console.log(item, this.orderAmount, '-----------------', Number(this.orderAmount) -
|
|
|
+ Number(item.discountPrice) -
|
|
|
+ Number(orderStatus.orderObject.couponDiscountPrice))
|
|
|
+ // 更新优惠券列表
|
|
|
+ const useCouponRef: any = this.$refs.useCouponRef
|
|
|
+ if(useCouponRef) {
|
|
|
+ console.log(useCouponRef, 'useCouponRef')
|
|
|
+ useCouponRef.resetCouponList()
|
|
|
+ }
|
|
|
this.orderPrice = Number(
|
|
|
numberToTwoUp(
|
|
|
Number(this.orderAmount) -
|
|
@@ -671,6 +698,7 @@ export default defineComponent({
|
|
|
Number(orderStatus.orderObject.couponDiscountPrice)
|
|
|
)
|
|
|
)
|
|
|
+ this.$forceUpdate()
|
|
|
}}
|
|
|
/>
|
|
|
) : (
|
|
@@ -700,6 +728,7 @@ export default defineComponent({
|
|
|
{/* 优惠券使用 */}
|
|
|
{!this.dataLoading && (
|
|
|
<UseCoupon
|
|
|
+ ref="useCouponRef"
|
|
|
couponId={orderStatus.orderObject.couponId}
|
|
|
discountPrice={orderStatus.orderObject.discountPrice}
|
|
|
orderType={this.orderType}
|