|
|
|
@ -6,7 +6,7 @@ |
|
|
|
<view class="suspension" hover-class="lf-opacity" @click="$url('/pages/coupon/index/index')">我的优惠券</view> |
|
|
|
</view> |
|
|
|
<view class="coupon-wrap"> |
|
|
|
<view class="coupon-box" v-for="i of 3"> |
|
|
|
<view class="coupon-box" v-for="(item,index) of coupon_list" :key="index"> |
|
|
|
<view class="coupon-card lf-m-b-30"> |
|
|
|
<view class="coupon-circle-top"> |
|
|
|
<view class="coupon-circle1"></view> |
|
|
|
@ -16,19 +16,19 @@ |
|
|
|
</view> |
|
|
|
<view class="coupon-radius"> |
|
|
|
<view class="coupon-left"> |
|
|
|
<view class="lf-color-white"> |
|
|
|
<view class="lf-color-white" v-if="item.action_type.type == 'cash'"> |
|
|
|
<text class="lf-font-24">¥</text> |
|
|
|
<text class="lf-font-70 lf-color-white lf-font-bold">200</text> |
|
|
|
<text class="lf-font-70 lf-color-white lf-font-bold">{{item.action_type.value}}</text> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="coupon-right"> |
|
|
|
<view class="lf-font-32 lf-font-bold lf-color-white">满1200减200</view> |
|
|
|
<view class="lf-font-24 lf-color-white">有效期2021.09.09-2021-09.15</view> |
|
|
|
<view class="lf-font-32 lf-font-bold lf-color-white">{{item.title}}</view> |
|
|
|
<view class="lf-font-24 lf-color-white">有效期{{item.starts_at}}~{{item.ends_at}}</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="coupon-receive" @click="receive">立即领取</view> |
|
|
|
<block v-if="i == 2"> |
|
|
|
<view class="coupon-receive" @click="receive(item.code)">立即领取</view> |
|
|
|
<block v-if="item.ifpast"> |
|
|
|
<view class="coupon-opacity"></view> |
|
|
|
<view class="coupon-end"> |
|
|
|
<view>抢光了</view> |
|
|
|
@ -44,15 +44,65 @@ |
|
|
|
export default { |
|
|
|
data(){ |
|
|
|
return { |
|
|
|
|
|
|
|
coupon_list: [] |
|
|
|
} |
|
|
|
}, |
|
|
|
onLoad(){ |
|
|
|
|
|
|
|
this.getCouponsList(); |
|
|
|
}, |
|
|
|
onPullDownRefresh() { |
|
|
|
this.getCouponsList(); |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
receive(){ |
|
|
|
this.$msg('领取成功') |
|
|
|
receive(code){ |
|
|
|
this.$http.post({ |
|
|
|
api: 'api/coupon/convert', |
|
|
|
data: { |
|
|
|
coupon_code: code |
|
|
|
}, |
|
|
|
header: { |
|
|
|
Authorization: this.$cookieStorage.get('user_token') |
|
|
|
} |
|
|
|
}).then(res => { |
|
|
|
if(res.data.code == 200) { |
|
|
|
this.$msg('领取成功'); |
|
|
|
this.getCouponsList(); |
|
|
|
}else { |
|
|
|
this.$msg(JSON.stringify(res.data.message)); |
|
|
|
} |
|
|
|
}).catch(err => { |
|
|
|
console.log("====", err); |
|
|
|
}) |
|
|
|
}, |
|
|
|
compareDate(val) { |
|
|
|
var nowTime = new Date(new Date().toLocaleDateString()).getTime(); |
|
|
|
let oldTime = new Date(new Date(val).toLocaleDateString()).getTime(); |
|
|
|
if(nowTime>oldTime) { |
|
|
|
return true; |
|
|
|
}else { |
|
|
|
return false; |
|
|
|
} |
|
|
|
}, |
|
|
|
//获取优惠券列表 |
|
|
|
getCouponsList() { |
|
|
|
this.$http.get({ |
|
|
|
api: 'api/coupons/list', |
|
|
|
header: { |
|
|
|
Authorization: this.$cookieStorage.get('user_token') |
|
|
|
} |
|
|
|
}).then(res => { |
|
|
|
this.coupon_list = res.data.data; |
|
|
|
this.coupon_list.forEach((item,index) => { |
|
|
|
if(this.compareDate(item.ends_at)) { |
|
|
|
this.$set(item,'ifpast',true); |
|
|
|
}else { |
|
|
|
this.$set(item,'ifpast',false); |
|
|
|
} |
|
|
|
}) |
|
|
|
uni.stopPullDownRefresh(); |
|
|
|
}).catch(err => { |
|
|
|
console.log("====", err); |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|