1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<template>
<div>
<van-cell-group>
<van-cell title="优惠劵编号" :value="couponTemplate.id" />
<van-cell title="优惠劵名" :value="couponTemplate.title"/>
</van-cell-group>
<van-button slot="button" size="small" type="primary" @click="onFetchClick">领取优惠劵</van-button>
</div>
</template>
<script>
import { getCouponTemplate, doAddCouponCard } from '../../api/promotion';
import { Dialog } from 'vant';
import { setLoginToken } from '../../utils/cache';
export default {
data() {
return {
couponTemplate: {
}
}
},
mounted() {
let id = this.$route.query.id;
let response = getCouponTemplate(id);
response.then(data => {
this.couponTemplate = data;
});
},
methods: {
onFetchClick: function () {
let that = this;
let id = this.$route.query.id;
let response = doAddCouponCard(id);
response.then(data => {
Dialog.alert({
title: '系统提示',
message: '领取成功',
beforeClose: function (action, done) {
// 关闭弹窗
done();
// 跳转到我的优惠劵
that.$router.push('/user/coupon');
}
});
});
}
}
}
</script>