Task:订单提交页面优化/ 提交订单前,若在商品详情页选择了优惠券,则提交订单页面删除该按钮

This commit is contained in:
linxi
2025-01-15 18:16:01 +08:00
parent 46b858b700
commit f19ac9ad42
3 changed files with 42 additions and 13 deletions
+17 -1
View File
@@ -4,7 +4,7 @@
<view class="popup-title bold tc v12-justify-between">
<text></text>
<text>优惠详情</text>
<u-icon name="close" color="#666" size="14" @click="close"></u-icon>
<u-icon name="close" color="#666" size="14" @click.stop="close"></u-icon>
</view>
<SubSection
:current="current"
@@ -125,6 +125,10 @@ export default {
currentPrice: {
default: 0,
type: Number
},
id: {
type: Number,
default: 0
}
},
data() {
@@ -137,6 +141,17 @@ export default {
},
}
},
watch: {
id: {
immediate: true,
handler(value) {
console.log('couponId', value);
if(value) {
this.selectCoupon(value)
}
}
}
},
computed: {
list() {
const temp = this.current === 0 ? this.twoList['usable'] : this.twoList['unusable']
@@ -197,6 +212,7 @@ export default {
if (this.current === 1) return
uni.setStorageSync('couponId', this.couponId)
this.$emit('change', this.selectItem || {})
this.$emit('ok', this.couponId)
}
}
}
+14 -7
View File
@@ -109,7 +109,7 @@
</view>
</view>
<view class="v12-justify-between v12-align-center">
<view class="v12-mr-2" @click="changeCoupons" v-if="couponList.usable.length !== 0">
<view class="v12-mr-2" @click="changeCoupons" v-if="couponList.usable.length !== 0 && !hasCoupon">
<text class="v12-dark-text v12-font-24" >{{ couponList.usable.length === 0 ? '无' : '去选择' }}</text>
<text class="iconfont icon-jiantou v12-font-24 v12-dark-text"></text>
</view>
@@ -251,7 +251,9 @@
v-if="couponList.usable.length > 0"
:two-list="couponList"
@change="changeCoupons"
@close="close"
:currentPrice="force2Decimal(orderPrice.totalPrice)"
:id="couponId"
@max="couponMax"
:show-tab="false"
/>
@@ -372,7 +374,8 @@ export default {
maxPoints: 0,
pageKeyId: Object.freeze('orderConfirm'),
total: 0,
couponTitle: ''
couponTitle: '',
hasCoupon: false,
};
},
computed: mapGetters(["userInfo", "storeItems"]),
@@ -383,9 +386,9 @@ export default {
shipping_type() {
this.computedPrice('shipping_type');
},
couponId() {
this.couponIndex = this.couponList['usable']?.findIndex(item => item.id === this.couponId)
this.computedPrice('couponId')
async couponId(value) {
this.couponIndex = this.couponList['usable']?.findIndex(item => item.id === value)
await this.computedPrice('couponId')
}
},
onLoad() {
@@ -400,10 +403,11 @@ export default {
if (that.$yroute.query.lotteryRecordId !== undefined) {
that.lotteryRecordId = that.$yroute.query.lotteryRecordId
}
that.getCartInfo()
that.hasCoupon = that.$yroute.query.couponId !== ''
},
onShow() {
const _this = this
_this.getCartInfo()
//获取用户信息
_this.$store.dispatch("getUser", true)
const chooseAddress = uni.getStorageSync('chooseAddress') || {}
@@ -433,7 +437,7 @@ export default {
isNullOrEmpty,
couponMax(e) {
this.couponTitle = e.couponTitle
this.couponId = uni.getStorageSync('couponId') || 0
this.couponId = this.$yroute.query.couponId || uni.getStorageSync('couponId') || 0
},
showStoreList() {
this.$store.commit("get_to", "orders");
@@ -785,6 +789,9 @@ export default {
that.$refs.payPwdPop.close();//关闭支付密码弹窗
});
},
close() {
this.show = !this.show
},
// v9-2
changeCoupons(item) {
if(!item) return
+11 -5
View File
@@ -57,7 +57,7 @@
<view
v-if="attr.productSelect.earnPoints"
:class="couponListLimit2ToShow.length > 0 ? 'earn-points' : ''"
class="value value2 v12-font-24 v12-primary-text"
class="value value2 v12-font-24 v12-primary-text v12-mb-2"
>
预计获得{{ attr.productSelect.earnPoints }}积分
</view>
@@ -183,7 +183,7 @@
<!-- v9 优惠券开始 -->
<u-popup :show="show" :round="10" mode="bottom" closeOnClickOverlay @close="changeCoupons()">
<CouponsPopup :two-list="couponList" @change="changeCoupons" @close="changeCoupons()" :showTab="false" :currentPrice="storeInfo.price" />
<CouponsPopup :two-list="couponList" @ok="setCoupon" @change="changeCoupons" @close="changeCoupons()" :showTab="false" :currentPrice="storeInfo.price" />
</u-popup>
<!-- v9 优惠券结束 -->
@@ -618,7 +618,8 @@ export default {
isFavorite: false,
pageKeyId: '',
couponListLimit2ToShow: [],
qualifications: []
qualifications: [],
couponId: null
}
},
computed: mapGetters(['isLogin', 'location', 'userInfo']),
@@ -1383,11 +1384,13 @@ export default {
postCartAdd(q).then(function (res) {
that.isOpen = false
that.attr.cartAttr = false
console.log( that.couponId)
if (news) {
that.$yrouter.push({
path: "/pages/order/OrderSubmission/index",
query: {
id: res.data.cartId
id: res.data.cartId,
couponId: that.couponId
}
})
} else {
@@ -1438,9 +1441,12 @@ export default {
this.posters = false
},
// v9-2
changeCoupons() {
changeCoupons(e) {
this.show = !this.show
},
setCoupon(couponId) {
this.couponId = couponId
},
async checkFavorite() {
const res = await checkProduct(this.id, this.uniqueId)
if (res.success) this.isFavorite = res.data.hasFavorite