|
|
|
@ -40,14 +40,14 @@ |
|
|
|
|
</view> |
|
|
|
|
<view class="count"> |
|
|
|
|
<view class="button flex flex-center" :class="{ |
|
|
|
|
disabled: number === 1, |
|
|
|
|
}" @click="setNum(false)"> |
|
|
|
|
disabled: item.cart_num === 1, |
|
|
|
|
}" @click="setNum(item, false)"> |
|
|
|
|
- |
|
|
|
|
</view> |
|
|
|
|
<input v-model.number="number" type="number" readonly /> |
|
|
|
|
<input v-model.number="item.cart_num" type="number" readonly /> |
|
|
|
|
<view class="button flex flex-center" :class="{ |
|
|
|
|
disabled: number === item.productInfo.stock, |
|
|
|
|
}" @click="setNum(true)"> |
|
|
|
|
disabled: item.cart_num === item.productInfo.stock, |
|
|
|
|
}" @click="setNum(item, true)"> |
|
|
|
|
+ |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
@ -81,7 +81,7 @@ |
|
|
|
|
共{{ number }}件,合计: |
|
|
|
|
<view class="money"><text>¥</text>{{ total }}</view> |
|
|
|
|
</view> |
|
|
|
|
<view v-if="useGold" class="message-ft">抵扣减:¥{{ diko }}</view> |
|
|
|
|
<!-- <view v-if="useGold" class="message-ft">抵扣减:¥{{ diko }}</view> --> |
|
|
|
|
</view> |
|
|
|
|
<view class="submit-btn flex flex-center" @click="pay">立即结算</view> |
|
|
|
|
</view> |
|
|
|
@ -189,10 +189,11 @@ |
|
|
|
|
if (!this.cartInfo || !this.cartInfo.length) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
this.totals = this.$util.Mul( |
|
|
|
|
this.cartInfo[0].productInfo[this.level ? "vip_price" : "price"], |
|
|
|
|
this.number |
|
|
|
|
); |
|
|
|
|
let sum = 0; |
|
|
|
|
this.cartInfo.length > 0 && this.cartInfo.forEach(v => { |
|
|
|
|
sum += Number(v.cart_num) * Number(this.level ? v.productInfo.vip_price : v.productInfo.price); |
|
|
|
|
}); |
|
|
|
|
this.totals = sum; |
|
|
|
|
this.totals = this.$util.Add(this.totals, this.postages); |
|
|
|
|
this.totals = this.$util.Sub( |
|
|
|
|
this.totals, |
|
|
|
@ -207,16 +208,18 @@ |
|
|
|
|
if (!this.cartInfo || !this.cartInfo.length) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if ( |
|
|
|
|
this.cartInfo[0].productInfo.is_postage || |
|
|
|
|
(this.cartInfo[0].productInfo.free_shipping > 0 && |
|
|
|
|
this.cartInfo[0].productInfo.free_shipping <= this.number) |
|
|
|
|
) { |
|
|
|
|
this.postages = 0; |
|
|
|
|
return "包邮"; |
|
|
|
|
} |
|
|
|
|
this.postages = this.cartInfo[0].productInfo.postage; |
|
|
|
|
return "¥" + this.postages; |
|
|
|
|
let sumPostages = 0; |
|
|
|
|
this.cartInfo.forEach(v => { |
|
|
|
|
if ( |
|
|
|
|
!v.productInfo.is_postage && |
|
|
|
|
(v.productInfo.free_shipping === 0 || |
|
|
|
|
v.productInfo.free_shipping >= v.cart_num) |
|
|
|
|
) { |
|
|
|
|
sumPostages += Number(v.productInfo.postage); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
this.postages = sumPostages; |
|
|
|
|
return this.postages === 0 ? '包邮' : `¥${this.postages}`; |
|
|
|
|
}, |
|
|
|
|
diko() { |
|
|
|
|
if (!this.cartInfo || !this.cartInfo.length) { |
|
|
|
@ -240,20 +243,32 @@ |
|
|
|
|
this.popupShow = false; |
|
|
|
|
this.subscribeTemplate(); |
|
|
|
|
}, |
|
|
|
|
cartInfo: { |
|
|
|
|
deep: true, |
|
|
|
|
handler() { |
|
|
|
|
let total = 0; |
|
|
|
|
if (this.cartInfo && this.cartInfo.length > 0) { |
|
|
|
|
this.cartInfo.forEach(v => { |
|
|
|
|
total += Number(v.cart_num || 0); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
this.number = total; |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
handlePickAddress(id) { |
|
|
|
|
this.addressChecked = id; |
|
|
|
|
this.popupShow = false; |
|
|
|
|
}, |
|
|
|
|
setNum(type) { |
|
|
|
|
setNum(item, type) { |
|
|
|
|
if (type) { |
|
|
|
|
// add |
|
|
|
|
|
|
|
|
|
this.number++; |
|
|
|
|
} else if (!type && this.number > 1) { |
|
|
|
|
item.cart_num++; |
|
|
|
|
} else if (!type && item.cart_num > 1) { |
|
|
|
|
// sub |
|
|
|
|
this.number--; |
|
|
|
|
item.cart_num--; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
async getData() { |
|
|
|
@ -269,8 +284,14 @@ |
|
|
|
|
key: data.orderKey, |
|
|
|
|
mark: "", |
|
|
|
|
}, |
|
|
|
|
number: data.cartInfo ? data.cartInfo[0].cart_num : 1, |
|
|
|
|
}); |
|
|
|
|
let total = 0; |
|
|
|
|
if (data.cartInfo && data.cartInfo.length > 0) { |
|
|
|
|
data.cartInfo.forEach(v => { |
|
|
|
|
total += Number(v.cart_num || 0); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
this.number = total; |
|
|
|
|
} catch (err) { |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
this.$util.showMsg(err.msg); |
|
|
|
@ -311,8 +332,12 @@ |
|
|
|
|
}, |
|
|
|
|
async getOrderPrice(n) { |
|
|
|
|
uni.showLoading({ mask: true }); |
|
|
|
|
const numArr = []; |
|
|
|
|
this.cartInfo.forEach(v => { |
|
|
|
|
numArr.push(v.cart_num); |
|
|
|
|
}); |
|
|
|
|
try { |
|
|
|
|
const { data } = await getOrderPrice(this.cartId, this.number); |
|
|
|
|
const { data } = await getOrderPrice(this.cartId, numArr.join(',')); |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
|
|
|
|
|
if (n) { |
|
|
|
|