wish.js
3.23 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import {
getBindtapData,
getObjByListKeyValue
} from '../../utils/util';
import {
productMap
} from '../../const/custom-data';
let app = getApp();
Page({
data: {
tipsRuleVisible: false,
tipsPirzeVisible: false,
userInfo: {},
wishInfo: {},
wishList: [],
helperInfo: {},
curWish: {},
status: 1, // 1正常(有库存) 2无库存
},
onShareAppMessage() {},
onLoad(options) {
this.initData();
},
initData() {
app.queryIndex().then((result) => {
this.setData({
userInfo: app.globalData.userInfo
})
this.queryWishbillDetail();
this.queryWishbillHelpers();
})
},
/**
* 领取我的奖品
*/
onGetGiftHandler(evt) {
let curData = getBindtapData(evt);
console.log("curData:", curData);
this.setData({
curWish: curData,
tipsPirzeVisible: true,
})
return;
app.poster({
url: app.api.wishbillGiftAccept,
data: curData
}).then((result) => {
// let curData
this.setData({
curWish: curData,
tipsPirzeVisible: true,
})
});
},
/**
* 查看我的奖品
*/
onCheckGiftHandler(evt) {
let curData = getBindtapData(evt);
console.log("curData:", curData);
},
// 显示规则页面
onShowRuleHandler() {
this.setData({
tipsRuleVisible: true
})
},
// 显示我的卡券
onMyCardHandler() {
app.router.push({
path: "myCard"
})
},
// 显示海报图
onCreatePosterHandler() {
app.router.push({
path: "poster"
})
},
// 查看排行榜
onRankHandler() {
app.router.push({
path: "rank"
})
},
// 分享
onShareHandler() {
},
// 获取心愿单详情
queryWishbillDetail() {
return new Promise((resolve, reject) => {
app.post({
url: app.api.wishbillDetail,
data: {
billCode: app.globalData.indexInfo.wishBillCode
}
}).then((result) => {
let wishList = result.wishGifts;
wishList.forEach(element => {
let product = productMap[element.prizeDefineCode + ""];
element = Object.assign(element, product);
let progress = element.elasticValue / element.conditionElasticValue * 100;
if (progress > 100) progress = 100;
// 直接计算坐标
let progressLeft = progress * 2.2 - 51;
element.progress = progress;
element.progressLeft = progressLeft;
});
this.setData({
wishInfo: result,
wishList: wishList
})
})
});
},
// 获取助力列表
queryWishbillHelpers() {
return new Promise((resolve, reject) => {
app.post({
url: app.api.wishbillHelpers,
data: {
billCode: app.globalData.indexInfo.wishBillCode,
page: 1,
size: 50
}
}).then((result) => {
this.setData({
helperInfo: result
})
})
});
},
hideMask() {
this.setData({
tipsRuleVisible: false,
tipsPirzeVisible: false,
})
},
// 子组件事件
evtcomp(evt) {
let {
name,
data
} = evt.detail;
switch (name) {
case "_evt_hide_mask":
this.hideMask();
break;
default:
break;
}
},
})