From 1ff0b665b65b5cdf13f7c10c608b078cb47db4b3 Mon Sep 17 00:00:00 2001 From: owen Date: Sat, 30 Sep 2023 22:05:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8=EF=BC=9A=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E6=98=AF=E5=90=A6=E9=A2=86=E5=8F=96=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/promotion/coupon.js | 8 ++++++++ components/couponListWindow/index.vue | 12 ++++++------ pages/goods_details/index.vue | 4 ++-- pages/index/index.vue | 17 +++++++++-------- pages/users/user_get_coupon/index.vue | 14 +++++++------- 5 files changed, 32 insertions(+), 23 deletions(-) diff --git a/api/promotion/coupon.js b/api/promotion/coupon.js index bee13ad6..fc97a375 100644 --- a/api/promotion/coupon.js +++ b/api/promotion/coupon.js @@ -1,5 +1,6 @@ import request from "@/utils/request.js"; +// 领取优惠券 export function takeCoupon(templateId) { return request.post("app-api/promotion/coupon/take", { templateId @@ -11,14 +12,21 @@ export function getMatchCouponList(data) { return request.get("app-api/promotion/coupon/match-list", data); } +// 获得用户优惠劵列表 export function getCouponPage(data) { return request.get("app-api/promotion/coupon/page", data); } +// 获得优惠劵模板分页 export function getCouponTemplatePage(data) { return request.get("app-api/promotion/coupon-template/page", data); } +// 获得优惠劵模板列表 +export function getCouponTemplateList(data) { + return request.get("app-api/promotion/coupon-template/list", data); +} + // 获得未使用的优惠劵数量 export function getUnusedCouponCount() { return request.get("app-api/promotion/coupon/get-unused-count"); diff --git a/components/couponListWindow/index.vue b/components/couponListWindow/index.vue index 272de737..0f53d2be 100644 --- a/components/couponListWindow/index.vue +++ b/components/couponListWindow/index.vue @@ -11,7 +11,7 @@ - + {{ fen2yuan(item.discountPrice) }} {{ (item.discountPercent / 10.0).toFixed(1) }} 折 @@ -33,8 +33,8 @@ {{ formatDate(item.validStartTime) + " - " + formatDate(item.validEndTime) }} - {{item.use_title || '已领取'}} - {{coupon.statusTile || '立即领取'}} + {{coupon.statusTile || '立即领取'}} + {{item.use_title || '已领取'}} @@ -88,11 +88,11 @@ getCouponUser: function(index, id) { // 领取优惠劵时,如果已经领取,则直接跳过 let list = this.coupon.list; - if (list[index].takeStatus && this.openType === 0) { - return; - } switch (this.openType) { case 0: // 领取优惠券 + if (!list[index].canTake) { + return; + } CouponApi.takeCoupon(id).then(res => { this.$util.Tips({ title: "领取成功" diff --git a/pages/goods_details/index.vue b/pages/goods_details/index.vue index f507036d..1463c620 100644 --- a/pages/goods_details/index.vue +++ b/pages/goods_details/index.vue @@ -819,8 +819,8 @@ * 获取优惠券 */ getCouponList(useType) { - CouponApi.getCouponTemplatePage({spuId: this.id, productScope: useType}).then(res => { - this.$set(this.coupon, 'list', res.data.list); + CouponApi.getCouponTemplateList({spuId: this.id, productScope: useType, count: 10}).then(res => { + this.$set(this.coupon, 'list', res.data); }) }, /** diff --git a/pages/index/index.vue b/pages/index/index.vue index e658c242..36ad0e41 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -97,16 +97,16 @@ - - {{ item.name }} - + {{ item.name }} + {{ fen2yuan(item.discountPrice) }} 元 {{ (item.discountPercent / 10.0).toFixed(1) }} 折 - 领取 - 已领取 + 已领取 满{{ fen2yuan(item.usePrice) }}元可用 @@ -184,6 +184,7 @@ import * as DecorateApi from '@/api/promotion/decorate.js'; import * as ProductUtil from '@/utils/product.js'; import * as Util from '@/utils/util.js'; + export default { computed: mapGetters(['isLogin', 'uid']), components: { @@ -381,8 +382,8 @@ * 获得优惠劵列表 */ getcouponList() { - CouponApi.getCouponTemplatePage({pageSize: 2}).then(res => { - this.$set(this, 'couponList', res.data.list); + CouponApi.getCouponTemplateList({ count: 2 }).then(res => { + this.$set(this, 'couponList', res.data); }).catch(err => { return this.$util.Tips({ title: err @@ -395,7 +396,7 @@ getCoupon: function(id, index) { CouponApi.takeCoupon(id).then(res => { // 设置已领取,即不能再领取 - this.$set(this.couponList[index], 'takeStatus', res.data !== true); + this.$set(this.couponList[index], 'canTake', res.data !== true); this.$util.Tips({ title: '领取成功' }); diff --git a/pages/users/user_get_coupon/index.vue b/pages/users/user_get_coupon/index.vue index d29ed35a..af918259 100644 --- a/pages/users/user_get_coupon/index.vue +++ b/pages/users/user_get_coupon/index.vue @@ -9,7 +9,7 @@ - + {{ fen2yuan(item.discountPrice) }} {{ (item.discountPercent / 10.0).toFixed(1) }} 折 @@ -18,11 +18,11 @@ - 通用 - 品类 - 商品 + 商品 {{item.name}} @@ -30,8 +30,8 @@ {{ formatDate(item.validStartTime) + " - " + formatDate(item.validEndTime) }} - 已领取 - 立即领取 + 立即领取 + 已领取 @@ -112,7 +112,7 @@ // 领取优惠券 CouponApi.takeCoupon(id).then(res => { // 设置已领取,即不能再领取 - this.couponsList[index].takeStatus = res.data !== true; + this.couponsList[index].canTake = res.data; this.$set(this, 'couponsList', this.couponsList); this.$util.Tips({ title: '领取成功'