...
|
...
|
@@ -12,7 +12,7 @@ |
|
|
<div class="coupon-name">{{item.couponName}}</div>
|
|
|
<div class="sub">{{item.receiveStartTime}} - {{item.receiveEndTime}}</div>
|
|
|
</div>
|
|
|
<cube-button :class="['item-button', item.receive === 'Y' ? 'active' : '']" @click="clickButton(item)">{{item.receive === 'Y' ? '已领取' : '立即领取'}}</cube-button>
|
|
|
<cube-button :class="['item-button', item.receive === 'N' ? 'active' : '']" @click="clickButton(item)">{{item.receive === 'N' ? '已领取' : '立即领取'}}</cube-button>
|
|
|
</div>
|
|
|
</li>
|
|
|
</ul>
|
...
|
...
|
@@ -40,6 +40,7 @@ export default { |
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
isLogin: false,
|
|
|
};
|
|
|
},
|
|
|
components: {
|
...
|
...
|
@@ -47,10 +48,18 @@ export default { |
|
|
'cube-button': Button,
|
|
|
'action-sheet': ActionSheet
|
|
|
},
|
|
|
watch: {
|
|
|
'yoho.context.isLogin': function(val) {
|
|
|
this.isLogin = val;
|
|
|
let that = this;
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
this.$refs.popup.show(() => {
|
|
|
this.$refs.couponListScroll.refresh();
|
|
|
});
|
|
|
|
|
|
this.checkLogin();
|
|
|
},
|
|
|
methods: {
|
|
|
...mapActions(['getCoupon']),
|
...
|
...
|
@@ -60,25 +69,36 @@ export default { |
|
|
onHide() {
|
|
|
this.$emit('hide');
|
|
|
},
|
|
|
async checkLogin() {
|
|
|
const user = await this.$yoho.auth();
|
|
|
|
|
|
if (user.uid) {
|
|
|
this.isLogin = true;
|
|
|
}
|
|
|
},
|
|
|
clickButton(item) {
|
|
|
let couponToken = item.couponToken;
|
|
|
|
|
|
if (item.receive === 'Y') {
|
|
|
if (item.receive === 'N') { // 是否可以领取 N:否,Y:是
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
this.getCoupon({couponToken: couponToken}).then(result => {
|
|
|
console.log(result);
|
|
|
this.$createDialog({
|
|
|
type: 'alert',
|
|
|
title: result.code === 200 ? '领取优惠券成功' : result.message,
|
|
|
icon: result.code === 200 ? 'cubeic-ok' : 'cubeic-warn'
|
|
|
}).show();
|
|
|
|
|
|
if (result.code === 200) { // 领取成功刷新一下领取状态
|
|
|
this.$emit('updateCoupon');
|
|
|
}
|
|
|
});
|
|
|
if (this.isLogin) {
|
|
|
this.getCoupon({couponToken: couponToken}).then(result => {
|
|
|
console.log(result);
|
|
|
this.$createDialog({
|
|
|
type: 'alert',
|
|
|
title: result.code === 200 ? '领取优惠券成功' : result.message,
|
|
|
icon: result.code === 200 ? 'cubeic-ok' : 'cubeic-warn'
|
|
|
}).show();
|
|
|
|
|
|
if (result.code === 200) { // 领取成功刷新一下领取状态
|
|
|
this.$emit('updateCoupon');
|
|
|
}
|
|
|
});
|
|
|
} else if (!this.isLogin) {
|
|
|
this.checkLogin();
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
};
|
...
|
...
|
|