diff --git a/pages/index/index.vue b/pages/index/index.vue index 893f313f..fcd41fab 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -83,6 +83,7 @@ + @@ -94,12 +95,17 @@ - - {{item.name}} - {{item.money?Number(item.money):''}} - 领取 - 已领取 - 满{{item.minPrice?Number(item.minPrice):''}}元可用 + + {{ item.name }} + + {{ fen2yuan(item.discountPrice) }} 元 + {{ (item.discountPercent / 10.0).toFixed(1) }} 折 + + 领取 + 已领取 + 满{{ fen2yuan(item.usePrice) }}元可用 @@ -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 + }); + }) + }, + // ========== 精品推荐 =========== /** * 首发新品切换