index.js
1.04 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
import { IMG_URL } from '~/config';
import NP from 'number-precision'
Page({
data: {
IMGURL: IMG_URL,
handleStatus: 0
},
onLoad(options) {
if (options.couponId) {
this.getEquityCouponsDetail(options.couponId)
}
},
// 查询优惠券详情
getEquityCouponsDetail(id) {
wx.p.api.couponsApi.getEquityCouponsDetail({ couponId: id }).then(res => {
if (res.denomination) {
res.denomination = NP.divide(res.denomination, 100)
}
this.setData({
detailInfo: res
})
this.couponId = id
})
},
// 领取
async toGet() {
const {
detailInfo
} = this.data
// const authStatus = await wx.p.router.intercept()
// if (authStatus) return
wx.p.wxApi.showLoading()
wx.p.api.couponsApi.getEquityCoupons({ couponId: this.couponId, merchantId: detailInfo.merchantId }).then(res => {
wx.hideLoading();
if (res) {
wx.p.wxApi.showToast('优惠券领取成功!')
this.setData({
handleStatus: 1
})
}
})
},
})