Fix:3982 【商城小程序】送礼页面优惠券改为选填模式
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
class="coupons__cover"
|
class="coupons__cover"
|
||||||
mode="widthFix"
|
mode="widthFix"
|
||||||
/>
|
/>
|
||||||
<view @click="selectCoupon" class="check-radio" :class="{'v12-primary': data.checked}">
|
<view @click="selectCoupon" class="check-radio" :class="{'v12-primary': data.checked}" v-if="showRadio">
|
||||||
<radio
|
<radio
|
||||||
v-if="radioModel && data.status === 0"
|
v-if="radioModel && data.status === 0"
|
||||||
:value="data.id"
|
:value="data.id"
|
||||||
@@ -50,6 +50,10 @@
|
|||||||
export default {
|
export default {
|
||||||
name: "Coupons",
|
name: "Coupons",
|
||||||
props: {
|
props: {
|
||||||
|
showRadio: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
data: {
|
data: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {
|
default: () => {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
@change="changeNav"
|
@change="changeNav"
|
||||||
v-if="showTab"
|
v-if="showTab"
|
||||||
/>
|
/>
|
||||||
<view class="v12-radius-20 v12-white v12-align-center v12-justify-around v12-pa-3" v-else>
|
<view class="v12-radius-20 v12-white v12-align-center v12-justify-around v12-pa-3" v-if="!showTab && showRadio">
|
||||||
<view class="">
|
<view class="">
|
||||||
<view class="v12-text-center v12-font-28">
|
<view class="v12-text-center v12-font-28">
|
||||||
券后价
|
券后价
|
||||||
@@ -61,6 +61,7 @@
|
|||||||
<view class="larg-one v12-mb-3">
|
<view class="larg-one v12-mb-3">
|
||||||
<Coupons
|
<Coupons
|
||||||
:data="largOne"
|
:data="largOne"
|
||||||
|
:showRadio="showRadio"
|
||||||
:radio-model="current === 0"
|
:radio-model="current === 0"
|
||||||
@change="selectCoupon"
|
@change="selectCoupon"
|
||||||
/>
|
/>
|
||||||
@@ -75,6 +76,7 @@
|
|||||||
>
|
>
|
||||||
<Coupons
|
<Coupons
|
||||||
:data="item"
|
:data="item"
|
||||||
|
:showRadio="showRadio"
|
||||||
:radio-model="current === 0"
|
:radio-model="current === 0"
|
||||||
@change="selectCoupon"
|
@change="selectCoupon"
|
||||||
v-if="index !== maxIndex"
|
v-if="index !== maxIndex"
|
||||||
@@ -93,7 +95,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<button disabled></button>
|
<button disabled></button>
|
||||||
<view
|
<view
|
||||||
v-if="current === 0"
|
v-if="current === 0 && showRadio"
|
||||||
:class="{ 'btn-disabled': current === 1 }"
|
:class="{ 'btn-disabled': current === 1 }"
|
||||||
class="btn-done bold flex jc-center ai-center v12-primary"
|
class="btn-done bold flex jc-center ai-center v12-primary"
|
||||||
@click="setCoupon"
|
@click="setCoupon"
|
||||||
@@ -111,6 +113,10 @@ export default {
|
|||||||
name: 'CouponsPopup',
|
name: 'CouponsPopup',
|
||||||
components: { SubSection, Coupons },
|
components: { SubSection, Coupons },
|
||||||
props: {
|
props: {
|
||||||
|
showRadio: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
twoList: {
|
twoList: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: {
|
default: {
|
||||||
|
|||||||
@@ -380,7 +380,7 @@ export default {
|
|||||||
unusable: [],
|
unusable: [],
|
||||||
usable: []
|
usable: []
|
||||||
},
|
},
|
||||||
couponId: uni.getStorageSync('couponId') || 0,
|
couponId: null,
|
||||||
couponIndex: -1,
|
couponIndex: -1,
|
||||||
show: false,
|
show: false,
|
||||||
// 是否使用积分开关
|
// 是否使用积分开关
|
||||||
@@ -449,8 +449,8 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
isNullOrEmpty,
|
isNullOrEmpty,
|
||||||
couponMax(e) {
|
couponMax(e) {
|
||||||
this.couponTitle = e.couponTitle
|
// this.couponTitle = e.couponTitle
|
||||||
this.couponId = this.$yroute.query.couponId || uni.getStorageSync('couponId') || 0
|
// this.couponId = this.$yroute.query.couponId || uni.getStorageSync('couponId') || 0
|
||||||
},
|
},
|
||||||
showStoreList() {
|
showStoreList() {
|
||||||
this.$store.commit("get_to", "orders")
|
this.$store.commit("get_to", "orders")
|
||||||
@@ -464,7 +464,11 @@ export default {
|
|||||||
usePointsCheckChange(e) {
|
usePointsCheckChange(e) {
|
||||||
this.computedPrice()
|
this.computedPrice()
|
||||||
},
|
},
|
||||||
// 计算订单金额
|
|
||||||
|
/**
|
||||||
|
* 计算订单金额
|
||||||
|
* @param {*} f 有值时 couponId不取默认值
|
||||||
|
*/
|
||||||
computedPrice(f) {
|
computedPrice(f) {
|
||||||
postOrderComputed(this.orderGroupInfo.orderKey, {
|
postOrderComputed(this.orderGroupInfo.orderKey, {
|
||||||
addressId: this.addressInfo.id,
|
addressId: this.addressInfo.id,
|
||||||
@@ -473,6 +477,10 @@ export default {
|
|||||||
usePoints: this.usePointsCheck ? 1 : 0,
|
usePoints: this.usePointsCheck ? 1 : 0,
|
||||||
shipping_type: parseInt(this.shipping_type) + 1
|
shipping_type: parseInt(this.shipping_type) + 1
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
|
this.couponList = res.data.result.couponList
|
||||||
|
if(!f) {
|
||||||
|
this.couponId = res.data.result.defaultCouponId
|
||||||
|
}
|
||||||
const data = res.data;
|
const data = res.data;
|
||||||
if (data.status === "EXTEND_ORDER") {
|
if (data.status === "EXTEND_ORDER") {
|
||||||
this.$yrouter.replace({
|
this.$yrouter.replace({
|
||||||
@@ -797,8 +805,17 @@ export default {
|
|||||||
if(!item) return
|
if(!item) return
|
||||||
if (this.couponList.usable.length === 0) return
|
if (this.couponList.usable.length === 0) return
|
||||||
this.show = !this.show
|
this.show = !this.show
|
||||||
this.couponId = uni.getStorageSync('couponId') || 0
|
if(!item.id) {
|
||||||
|
this.couponId = 0
|
||||||
|
this.couponTitle = ''
|
||||||
|
this.computedPrice(1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.couponId = item.id
|
||||||
this.couponTitle = item.couponTitle
|
this.couponTitle = item.couponTitle
|
||||||
|
this.computedPrice(1)
|
||||||
|
// this.couponId = uni.getStorageSync('couponId') || 0
|
||||||
|
// this.couponTitle = item.couponTitle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -208,6 +208,7 @@
|
|||||||
@change="changeCoupons"
|
@change="changeCoupons"
|
||||||
@close="changeCoupons()"
|
@close="changeCoupons()"
|
||||||
:showTab="false"
|
:showTab="false"
|
||||||
|
:showRadio="false"
|
||||||
:currentPrice="storeInfo.price" />
|
:currentPrice="storeInfo.price" />
|
||||||
</u-popup>
|
</u-popup>
|
||||||
<!-- v9 优惠券结束 -->
|
<!-- v9 优惠券结束 -->
|
||||||
@@ -1458,7 +1459,6 @@ export default {
|
|||||||
path: "/pages/order/OrderSubmission/index",
|
path: "/pages/order/OrderSubmission/index",
|
||||||
query: {
|
query: {
|
||||||
id: res.data.cartId,
|
id: res.data.cartId,
|
||||||
couponId: that.couponId, // 优惠券ID
|
|
||||||
discount: that.storeInfo.discount,
|
discount: that.storeInfo.discount,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -1467,7 +1467,8 @@ export default {
|
|||||||
if(news === 2) {
|
if(news === 2) {
|
||||||
const coupId = that.couponId ? that.couponId : (that.couponList.usable[0] && that.couponList.usable[0].id || '')
|
const coupId = that.couponId ? that.couponId : (that.couponList.usable[0] && that.couponList.usable[0].id || '')
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pkg_user/views/gift/gift?cartId=' + res.data.cartId + '&couponId=' + coupId + (that.storeInfo.discount ? '&discount=' + that.storeInfo.discount : '')
|
// + '&couponId=' + coupId
|
||||||
|
url: '/pkg_user/views/gift/gift?cartId=' + res.data.cartId + (that.storeInfo.discount ? '&discount=' + that.storeInfo.discount : '')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if(news === 0) {
|
if(news === 0) {
|
||||||
|
|||||||
@@ -106,14 +106,14 @@
|
|||||||
<view class="price-wrap">
|
<view class="price-wrap">
|
||||||
<view class="v12-font-28 v12-dark-text v12-font-bold">价格明细</view>
|
<view class="v12-font-28 v12-dark-text v12-font-bold">价格明细</view>
|
||||||
<view class="v12-justify-between v12-align-center v12-font-28 v12-mt-1">
|
<view class="v12-justify-between v12-align-center v12-font-28 v12-mt-1">
|
||||||
<view>商品总价:</view>
|
<view class="v12-font-24 v12-dark-text">商品总价:</view>
|
||||||
<view>
|
<view>
|
||||||
<text class="v12-dark-text v12-font-22">¥</text>
|
<text class="v12-dark-text v12-font-22">¥</text>
|
||||||
<text class="v12-dark-text v12-font-30">{{ computedResult.totalPrice }}</text>
|
<text class="v12-dark-text v12-font-30">{{ computedResult.totalPrice }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="v12-justify-between v12-align-center v12-font-28 v12-mt-1">
|
<view class="v12-justify-between v12-align-center v12-font-28 v12-mt-1">
|
||||||
<view>平台折扣:</view>
|
<view class="v12-font-24 v12-dark-text">平台折扣:</view>
|
||||||
<view>
|
<view>
|
||||||
-
|
-
|
||||||
<text class="v12-dark-text v12-font-22">¥</text>
|
<text class="v12-dark-text v12-font-22">¥</text>
|
||||||
@@ -121,11 +121,20 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="v12-justify-between v12-align-center v12-font-28 v12-mt-1">
|
<view class="v12-justify-between v12-align-center v12-font-28 v12-mt-1">
|
||||||
<view>优惠券:</view>
|
<view class="v12-font-24 v12-dark-text v12-align-center">
|
||||||
<view>
|
<view class="">
|
||||||
|
优惠券:
|
||||||
|
</view>
|
||||||
|
<view class="v12-align-center v12-ml-1" v-if="couponTitle">
|
||||||
|
<view class="v12-primary-text v12-primary-border v12-font-22 v12-radius-6 v12-px-1">券</view>
|
||||||
|
<view class="v12-primary-text v12-primary-border v12-font-22 v12-radius-6 v12-px-1">{{ couponTitle }}</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view @click="showCouponsPopup()" class="v12-dark-text v12-font-30">
|
||||||
-
|
-
|
||||||
<text class="v12-dark-text v12-font-22">¥</text>
|
<text class="v12-dark-text v12-font-22">¥</text>
|
||||||
<text class="v12-dark-text v12-font-30">{{ computedResult.couponPrice }}</text>
|
<text class="v12-dark-text v12-font-30">{{ computedResult.couponPrice }}</text>
|
||||||
|
<text class="iconfont icon-jiantou v12-font-24 v12-dark-text"></text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<u-divider></u-divider>
|
<u-divider></u-divider>
|
||||||
@@ -178,6 +187,22 @@
|
|||||||
:show.sync="showPayPicker"
|
:show.sync="showPayPicker"
|
||||||
@confirm="onPayConfirm"
|
@confirm="onPayConfirm"
|
||||||
/>
|
/>
|
||||||
|
<u-popup
|
||||||
|
:show="showPopup"
|
||||||
|
:round="10"
|
||||||
|
mode="bottom"
|
||||||
|
close-on-click-overlay
|
||||||
|
@close="changeCoupons"
|
||||||
|
>
|
||||||
|
<CouponsPopup
|
||||||
|
v-if="couponList.usable && couponList.usable.length > 0"
|
||||||
|
:two-list="couponList"
|
||||||
|
@change="changeCoupons"
|
||||||
|
@close="close"
|
||||||
|
:id="couponId"
|
||||||
|
:show-tab="false"
|
||||||
|
/>
|
||||||
|
</u-popup>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -189,12 +214,14 @@ import {mapGetters} from "vuex";
|
|||||||
import giftTips from './components/giftTips.vue'
|
import giftTips from './components/giftTips.vue'
|
||||||
import CoverPicker from './components/CoverPicker.vue'
|
import CoverPicker from './components/CoverPicker.vue'
|
||||||
import PayPicker from './components/PayPicker.vue';
|
import PayPicker from './components/PayPicker.vue';
|
||||||
|
import CouponsPopup from "@/components/CouponsPopup.vue"
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
giftTips,
|
giftTips,
|
||||||
CoverPicker,
|
CoverPicker,
|
||||||
PayPicker,
|
PayPicker,
|
||||||
passkeyborad
|
passkeyborad,
|
||||||
|
CouponsPopup
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -227,11 +254,24 @@ export default {
|
|||||||
defaultIndex:0,
|
defaultIndex:0,
|
||||||
discount: null,
|
discount: null,
|
||||||
computedResult: {},
|
computedResult: {},
|
||||||
|
couponList: {
|
||||||
|
unusable: [],
|
||||||
|
usable: []
|
||||||
|
},
|
||||||
|
couponTitle: '',
|
||||||
|
showPopup: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
async couponId(value) {
|
||||||
|
this.couponIndex = this.couponList['usable']?.findIndex(item => item.id === +value)
|
||||||
|
this.couponTitle = this.couponList['usable']?.[this.couponIndex]?.couponTitle
|
||||||
|
await this.computedPrice(this.goodsInfo.cartNum, 1)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(opts) {
|
onLoad(opts) {
|
||||||
this.cartId = opts.cartId
|
this.cartId = opts.cartId
|
||||||
this.couponId = opts.couponId
|
// this.couponId = opts.couponId || 0
|
||||||
this.discount = opts.discount
|
this.discount = opts.discount
|
||||||
this.getGift()
|
this.getGift()
|
||||||
},
|
},
|
||||||
@@ -256,6 +296,26 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
showCouponsPopup() {
|
||||||
|
this.showPopup = !this.showPopup
|
||||||
|
},
|
||||||
|
close() {
|
||||||
|
this.showPopup = !this.showPopup
|
||||||
|
},
|
||||||
|
changeCoupons(item) {
|
||||||
|
if(!item) return
|
||||||
|
if (this.couponList.usable && this.couponList.usable.length === 0) return
|
||||||
|
this.showPopup = !this.showPopup
|
||||||
|
if(!item.id) {
|
||||||
|
this.couponId = 0
|
||||||
|
this.couponTitle = ''
|
||||||
|
this.computedPrice(this.goodsInfo.cartNum, 1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.couponId = item.id
|
||||||
|
this.couponTitle = item.couponTitle
|
||||||
|
this.computedPrice(this.goodsInfo.cartNum, 1)
|
||||||
|
},
|
||||||
makeAgain() {
|
makeAgain() {
|
||||||
const params = {
|
const params = {
|
||||||
orderId: this.orderId,
|
orderId: this.orderId,
|
||||||
@@ -290,7 +350,12 @@ export default {
|
|||||||
},10)
|
},10)
|
||||||
this.$forceUpdate()
|
this.$forceUpdate()
|
||||||
},
|
},
|
||||||
computedPrice(num) {
|
/**
|
||||||
|
* 计算价格
|
||||||
|
* @param {Number} num 数量
|
||||||
|
* @param {Boolean} f 有值时 couponId不取默认值
|
||||||
|
*/
|
||||||
|
computedPrice(num, f) {
|
||||||
const params = {
|
const params = {
|
||||||
cartId: this.cartId,
|
cartId: this.cartId,
|
||||||
couponId: this.couponId,
|
couponId: this.couponId,
|
||||||
@@ -300,6 +365,11 @@ export default {
|
|||||||
params.discount = this.discount
|
params.discount = this.discount
|
||||||
}
|
}
|
||||||
getGiftCardSendOrderAmount(this.orderKey, params).then(res => {
|
getGiftCardSendOrderAmount(this.orderKey, params).then(res => {
|
||||||
|
this.couponList = res.data.result.couponList
|
||||||
|
if(!f) {
|
||||||
|
this.couponId = res.data.result.defaultCouponId || 0
|
||||||
|
this.$forceUpdate()
|
||||||
|
}
|
||||||
this.payPrice = res.data.result.payPrice
|
this.payPrice = res.data.result.payPrice
|
||||||
this.computedResult = res.data.result
|
this.computedResult = res.data.result
|
||||||
this.$forceUpdate()
|
this.$forceUpdate()
|
||||||
@@ -335,10 +405,9 @@ export default {
|
|||||||
this.selectedCover = res.data.specialGiftCardTemplate.cover
|
this.selectedCover = res.data.specialGiftCardTemplate.cover
|
||||||
this.giftImage = res.data.specialGiftCardTemplate.image
|
this.giftImage = res.data.specialGiftCardTemplate.image
|
||||||
this.defaultIndex = this.coverList.findIndex(item => item.id === this.templateId)
|
this.defaultIndex = this.coverList.findIndex(item => item.id === this.templateId)
|
||||||
console.log(this.defaultIndex, 'defaultIndex');
|
// if(!this.couponId) {
|
||||||
if(!this.couponId) {
|
// this.couponId = res.data.couponList.usable[0] && res.data.couponList.usable[0].id || ''
|
||||||
this.couponId = res.data.couponList.usable[0] && res.data.couponList.usable[0].id || ''
|
// }
|
||||||
}
|
|
||||||
this.computedPrice(this.goodsInfo.cartNum)
|
this.computedPrice(this.goodsInfo.cartNum)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -460,17 +529,17 @@ export default {
|
|||||||
}
|
}
|
||||||
}) .catch(err => {
|
}) .catch(err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title:err.msg,
|
title:err.msg,
|
||||||
icon: "none",
|
icon: "none",
|
||||||
duration: 2000
|
duration: 2000
|
||||||
});
|
});
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.isShowPayPwdPop = false;
|
this.isShowPayPwdPop = false;
|
||||||
this.$refs.payPwdPop.clear();//清空支付密码
|
this.$refs.payPwdPop.clear();//清空支付密码
|
||||||
this.$refs.payPwdPop.close();//关闭支付密码弹窗
|
this.$refs.payPwdPop.close();//关闭支付密码弹窗
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user