【首页】

1. 接入优惠劵的逻辑
pull/1/MERGE
YunaiV 2023-06-25 21:01:34 +08:00
parent 4c0704b5cd
commit e58e910951
1 changed files with 44 additions and 36 deletions

View File

@ -83,6 +83,7 @@
</navigator>
</block>
</view>
<!-- 优惠券 -->
<view class="couponIndex" v-if="couponList.length>0">
<view class="acea-row" style="height: 100%;">
@ -94,12 +95,17 @@
</navigator>
</view>
<view class="listBox acea-row">
<view class="list" :class='item.isUse ? "listHui" : "listActive" ' v-for="(item, index) in couponList.slice(0,2)" :key="index">
<view class="tit line1" :class='item.isUse ? "pricehui" : "titActive" '>{{item.name}}</view>
<view class="price" :class='item.isUse ? "pricehui" : "icon-color" '>{{item.money?Number(item.money):''}}<text class="yuan"></text></view>
<view class="ling" v-if="!item.isUse" :class='item.isUse ? "pricehui" : "icon-color" ' @click="getCoupon(item.id,index)"></view>
<view class="ling" v-else :class='item.isUse ? "pricehui fonthui" : "icon-color" '>已领取</view>
<view class="priceM">{{item.minPrice?Number(item.minPrice):''}}元可用</view>
<view class="list" :class='item.takeStatus ? "listHui" : "listActive" '
v-for="(item, index) in couponList.slice(0,2)" :key="index">
<view class="tit line1" :class='item.takeStatus ? "pricehui" : "titActive" '>{{ item.name }}</view>
<view class="price" :class='item.takeStatus ? "pricehui" : "icon-color" '>
<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" '
@click="getCoupon(item.id,index)">领取</view>
<view class="ling" v-else :class='item.takeStatus ? "pricehui fonthui" : "icon-color" '>已领取</view>
<view class="priceM">{{ fen2yuan(item.usePrice) }}元可用</view>
</view>
</view>
</view>
@ -176,12 +182,11 @@
import tabNav from '@/components/tabNav.vue'
import countDown from '@/components/countDown';
import recommend from '@/components/recommend';
import {
silenceBindingSpread
} from '@/utils';
import { silenceBindingSpread } from '@/utils';
import Loading from '@/components/Loading/index.vue';
import * as ProductSpuApi from '@/api/product/spu.js';
import * as PromotionActivityApi from '@/api/promotion/activity.js';
import * as CouponApi from '@/api/promotion/coupon.js';
import * as ProductUtil from '@/utils/product.js';
import * as Util from '@/utils/util.js';
const arrTemp = ["beforePay", "afterPay", "refundApply", "beforeRecharge", "createBargain", "pink"];
@ -270,20 +275,6 @@
})
},
methods: {
getCoupon: function(id, index) {
let that = this;
//
setCouponReceive(id).then(function(res) {
that.$set(that.couponList[index], 'isUse', true);
that.$util.Tips({
title: '领取成功'
});
}, function(res) {
return that.$util.Tips({
title: res
});
})
},
// scroll-view
scroll(e) {
this.scrollLeft = e.detail.scrollLeft;
@ -333,19 +324,7 @@
this.getcouponList();
})
},
getcouponList() {
let that = this;
getCoupons({
page: 1,
limit: 6
}).then(res => {
that.$set(that, "couponList", res.data);
}).catch(err => {
return this.$util.Tips({
title: err
});
});
},
shareApi: function() {
getShare().then(res => {
this.$set(this, 'configApi', res.data);
@ -369,6 +348,35 @@
}
},
// ========== ===========
/**
* 获得优惠劵列表
*/
getcouponList() {
CouponApi.getCouponTemplateList().then(res => {
this.$set(this, 'couponList', res.data);
}).catch(err => {
return this.$util.Tips({
title: err
});
});
},
/**
* 领取优惠劵
*/
getCoupon: function(id, index) {
CouponApi.takeCoupon(id).then(res => {
this.$set(this.couponList[index], 'takeStatus', true);
this.$util.Tips({
title: '领取成功'
});
}).catch(err => {
return this.$util.Tips({
title: err
});
})
},
// ========== ===========
/**
* 首发新品切换