index.js
1.42 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
import { componentsMixin } from '../../mixins/index'
import {
equityApi
} from "../../api/api"
Component({
behaviors: [componentsMixin],
properties: {
show: Boolean
},
/**
* 组件的初始数据
*/
data: {
IMGVERSION_FILE_NAME: "mine/version/v3.7.2/",
status: 0,
},
/**
* 组件的方法列表
*/
methods: {
closeModal() {
this.setData({
show: false,
status: 0
})
},
bindInput(e) {
this.fillText = e.detail.value
},
click() {
if (!this.fillText) return wx.$util.showToast('请输入兑换码')
wx.$util.showLoading()
equityApi.equityExchange({ exchangeCode: this.fillText }).then(res => {
wx.hideLoading()
console.log(res);
if(res){
if(res.effectiveType==1){
res.dateName = '永久有效'
}else if(res.effectiveType==2){
res.dateName = `${res.effectiveNum}天`
}else if(res.effectiveType==3&&res.effectiveStartDate&&res.effectiveEndDate){
res.dateName = `${new Date(res.effectiveStartDate).format('yyyy-MM-dd')}-${new Date(res.effectiveEndDate).format('yyyy-MM-dd')}`
}
this.setData({
status: 1,
cardInfo:res
})
}
})
},
toCheck() {
this.closeModal()
wx.$eventbus.emit('EQUITY')
wx.switchTab({
url: '/pages/tab/equity/equity',
});
}
}
})