element.js
2.52 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import {
couponsApi
} from '~/api/api'
import {
componentsMixin
} from '../../mixins/index'
import {
IMG_URL
} from '~/utils/constantData.js'
Component({
behaviors: [componentsMixin],
properties: {
coupons: {
type: Object,
value: {}
},
mode: {
type: String,
value: 'coupon' //coupon卡券 center领券中心
},
btnStatus: {
type: Number,
value: 0
},
useMemberType: Number,
hideBtn: Boolean,
couponStyle: String
},
data: {
// 2 折扣券,3 代金券,4 兑换券,7 服务券
IMGURL: wx.$imgUrl,
IMG_URL
},
methods: {
toRecive() {
let para = {
couponIdList: [this.data.coupons.id],
receiveWay: 1,
}
couponsApi.toReciveCard(para).then(res => {
if (res) {
wx.navigateTo({
url: '/packageShopmall/packageMine/pages/coupon/success/success'
})
}
})
},
toDetail() {
let temp = JSON.stringify(this.data.coupons)
let {
discountType,
useChannel,
id
} = this.data.coupons
let detailInfo = {
xx: 'xx'
}
if (discountType == 2 || discountType == 4) {
wx.$router.go('/packageShopmall/packageMall/pages/coupon/coupon', {
userCouponId: id,
useMemberType: this.data.useMemberType,
detailInfo
})
return
}
/**线上商品代金券 */
if (discountType == 3 && useChannel == 1) {
// if(this.data.useMemberType == 1) {
// wx.$api.showToast('代金券已使用')
// return
// }
wx.$router.go('/packageShopmall/packageMine/pages/coupon/recommend/recommend', {
couponInfo: this.data.coupons
})
return
}
wx.navigateTo({
url: '/packageShopmall/packageMine/pages/coupon/detail/detail?item=' + temp
})
},
//领券中心去领取
toGet() {
let merchantId = wx.$storage.get('srcm_shopmall_merchant_id')
let para = {
couponId: this.data.coupons.couponId,
merchantId
}
couponsApi.reciveCenterCouponApi(para).then(res => {
if (res) {
wx.showToast({
title: '领取成功',
icon: 'success'
})
setTimeout(() => {
const thisPage = wx.$router.getPageInstance()
thisPage.setData({
couponsList: [],
pageNum: 1
})
thisPage.getCarCenterdData()
}, 500)
}
})
}
}
})