优惠券:重构是否领取检查方式
parent
78da791d4c
commit
1ff0b665b6
|
@ -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");
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<view class='item acea-row row-center-wrapper' v-for="(item,index) in coupon.list"
|
||||
@click="getCouponUser(index, item.id)" :key='index'>
|
||||
<!-- 金额 -->
|
||||
<view class='money acea-row row-column row-center-wrapper' :class='item.takeStatus?"moneyGray":""'>
|
||||
<view class='money acea-row row-column row-center-wrapper' :class='item.canTake ? "" : "moneyGray"'>
|
||||
<view>¥
|
||||
<text v-if="item.discountType === 1" class='num'>{{ fen2yuan(item.discountPrice) }}</text>
|
||||
<text v-else class='num'>{{ (item.discountPercent / 10.0).toFixed(1) }} 折</text>
|
||||
|
@ -33,8 +33,8 @@
|
|||
<view v-else>
|
||||
{{ formatDate(item.validStartTime) + " - " + formatDate(item.validEndTime) }}
|
||||
</view>
|
||||
<view class='bnt gray' v-if="item.takeStatus">{{item.use_title || '已领取'}}</view>
|
||||
<view class='bnt bg-color' v-else>{{coupon.statusTile || '立即领取'}}</view>
|
||||
<view class='bnt bg-color' v-if="item.canTake">{{coupon.statusTile || '立即领取'}}</view>
|
||||
<view class='bnt gray' v-else>{{item.use_title || '已领取'}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -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: "领取成功"
|
||||
|
|
|
@ -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);
|
||||
})
|
||||
},
|
||||
/**
|
||||
|
|
|
@ -97,16 +97,16 @@
|
|||
</navigator>
|
||||
</view>
|
||||
<view class="listBox acea-row">
|
||||
<view class="list" :class='item.takeStatus ? "listHui" : "listActive" '
|
||||
<view class="list" :class='item.canTake ? "listActive" : "listHui"'
|
||||
v-for="(item, index) in couponList" :key="index">
|
||||
<view class="tit line1" :class='item.takeStatus ? "pricehui" : "titActive" '>{{ item.name }}</view>
|
||||
<view class="price" :class='item.takeStatus ? "pricehui" : "icon-color" '>
|
||||
<view class="tit line1" :class='item.canTake ? "titActive" : "pricehui"'>{{ item.name }}</view>
|
||||
<view class="price" :class='item.canTake ? "icon-color" : "pricehui"'>
|
||||
<text v-if="item.discountType === 1">{{ fen2yuan(item.discountPrice) }} 元</text>
|
||||
<text v-else>{{ (item.discountPercent / 10.0).toFixed(1) }} 折</text>
|
||||
</view>
|
||||
<view class="ling" v-if="!item.takeStatus" :class='item.takeStatus ? "pricehui" : "icon-color" '
|
||||
<view class="ling icon-color" v-if="item.canTake"
|
||||
@click="getCoupon(item.id,index)">领取</view>
|
||||
<view class="ling" v-else :class='item.takeStatus ? "pricehui fonthui" : "icon-color" '>已领取</view>
|
||||
<view class="ling pricehui fonthui" v-else>已领取</view>
|
||||
<view class="priceM">满{{ fen2yuan(item.usePrice) }}元可用</view>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -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: '领取成功'
|
||||
});
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<view style="height: 106rpx;"></view>
|
||||
<view class='coupon-list' v-if="couponsList.length">
|
||||
<view class='item acea-row row-center-wrapper' v-for="(item,index) in couponsList" :key="index">
|
||||
<view class='money' :class='item.takeStatus ? "moneyGray" : "" '>
|
||||
<view class='money' :class='item.canTake ? "" : "moneyGray"'>
|
||||
<view>¥
|
||||
<text v-if="item.discountType === 1" class='num'>{{ fen2yuan(item.discountPrice) }}</text>
|
||||
<text v-else class='num'>{{ (item.discountPercent / 10.0).toFixed(1) }} 折</text>
|
||||
|
@ -18,11 +18,11 @@
|
|||
</view>
|
||||
<view class='text'>
|
||||
<view class='condition line2'>
|
||||
<span class='line-title' :class='(item.takeStatus)?"gray":""'
|
||||
<span class='line-title' :class='item.canTake ? "" : "gray"'
|
||||
v-if='type === 1'>通用</span>
|
||||
<span class='line-title' :class='(item.takeStatus)?"gray":""'
|
||||
<span class='line-title' :class='item.canTake ? "" : "gray"'
|
||||
v-else-if='type === 3'>品类</span>
|
||||
<span class='line-title' :class='(item.takeStatus)?"gray":""' v-else>商品</span>
|
||||
<span class='line-title' :class='item.canTake ? "" : "gray"' v-else>商品</span>
|
||||
<span>{{item.name}}</span>
|
||||
</view>
|
||||
<view class='data acea-row row-between-wrapper'>
|
||||
|
@ -30,8 +30,8 @@
|
|||
<view v-else>
|
||||
{{ formatDate(item.validStartTime) + " - " + formatDate(item.validEndTime) }}
|
||||
</view>
|
||||
<view class='bnt gray' v-if="item.takeStatus">已领取</view>
|
||||
<view class='bnt bg-color' v-else @click='getCoupon(item.id, index)'>立即领取</view>
|
||||
<view class='bnt bg-color' v-if="item.canTake" @click='getCoupon(item.id, index)'>立即领取</view>
|
||||
<view class='bnt gray' v-else>已领取</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -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: '领取成功'
|
||||
|
|
Loading…
Reference in New Issue