luckinfo.js
5.25 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
const app = getApp();
let self = null;
Page({
data: {
prizes: [
{ fonts: [{ text: '积分', top: '18%', wordWrap:false, fontColor: 'transparent'}],
imgs: [
{
src: '../../../images/luckDraw/jf.png',
width: '135rpx',
height: '107rpx',
top: '15%',
}
],
},
{ fonts: [{ text: '优惠券', top: '18%', wordWrap:false, fontColor: 'transparent'}],
imgs: [
{
src: '../../../images/luckDraw/yhq.png',
width: '135rpx',
height: '107rpx',
top: '15%',
}
],
},
{ fonts: [{ text: '美容', top: '18%', wordWrap:false, fontColor: 'transparent'}],
imgs: [
{
src: '../../../images/luckDraw/mr1.png',
width: '135rpx',
height: '107rpx',
top: '15%',
}
],
},
{ fonts: [{ text: '谢谢\n参与', top: '18%', wordWrap:false, fontColor: 'white'}]},
{ fonts: [{ text: '积分', top: '18%', wordWrap:false, fontColor: 'transparent'}],
imgs: [
{
src: '../../../images/luckDraw/jf.png',
width: '135rpx',
height: '107rpx',
top: '15%',
}
],
},
{ fonts: [{ text: '优惠券', top: '18%', wordWrap:false, fontColor: 'transparent'}],
imgs: [
{
src: '../../../images/luckDraw/yhq.png',
width: '135rpx',
height: '107rpx',
top: '15%',
}
],
},
{ fonts: [{ text: '美容', top: '18%', wordWrap:false, fontColor: 'transparent'}],
imgs: [
{
src: '../../../images/luckDraw/mr1.png',
width: '135rpx',
height: '107rpx',
top: '15%',
}
],
},
{ fonts: [{ text: '谢谢\n参与', top: '18%', wordWrap:false, fontColor: 'white'}], },
],
defaultConfig: {
offsetDegree: 22.5,
},
// defaultStyle: {
// fontColor: '#d64737',
// fontSize: '14px'
// },
blocks: [ //背景图
// { padding: '13px', background: '#d64737', top: '20rpx' }
{
padding: '76rpx',
// background: 'pink',
imgs: [{
src: 'http://201442.image.myqcloud.com/201442/0/1c825ca4-f155-453c-9f85-2cb0381824fe/original',
width: '700rpx',
height: '700rpx',
rotate: true,
}]
}
],
buttons: [
// { radius: '50px', background: '#d64737' },
// { radius: '45px', background: '#fff' },
// { radius: '41px', background: '#f6c66f', pointer: true },
// {
// radius: '35px', background: '#ffdea0',
// fonts: [{ text: '开始\n抽奖', fontSize: '18px', top: -18 }]
// }
{
radius: '60rpx',
background: 'black',
pointer: true,
imgs: [{
src: 'http://201442.image.myqcloud.com/201442/0/b29290ec-aeb3-40e9-9444-8f15fd9acda3/original',
width: '188rpx',
height: '230rpx',
top: '-130rpx',
}],
}
],
},
onLoad(options) {
console.log('options', options);
self = this;
this.data.options = options;
app.isLogin().then(function(data) {//进入页面前已经授权登录成功
self.setData({
userInfo: data,
});
});
},
onShow() {
if(app.globalData.userInfo) {
if(!this.data.isLogin) {
console.log('gl', app.globalData);
this.setData({
userInfo: app.globalData.userInfo,
imghost: app.globalData.setting.imghost,
isLogin: true,
});
let user_id = app.globalData.userInfo.user_id;
let store_id = app.globalData.setting.stoid;
let id = this.data.options.id;
let url = `/api/weshop/marketing/marketingLuckForm/getLuckInfo/${store_id}/${id}/${user_id}`;
console.log('url', url);
app.request.get(url, {
success: function(res) {
// self.setData({
// details: res.data.data
// });
console.log('res****', res.data.data);
// let basic = res.data.data;
// self.setData({
// basic,
// });
// if(basic.template_type == 1) { //获取模板
// let url = `/api/weshop/marketing/marketingLuckTemplate/get/${store_id}/${basic.template_id}`;
// app.request.get(url, {
// success: function(res) {
// // console.log('prizes//////', res.data.data);
// // self.setData({
// // prizes: res.data.data.pageData
// // });
// },
// });
// };
},
});
// 获取奖品展示的奖品
app.request.get('/api/weshop/marketing/marketingLuckList/page', {
data: {
store_id,
luck_formid: id,
},
success: function(res) {
// console.log('res//////', res.data.data.pageData);
self.setData({
prizes: res.data.data.pageData
});
},
});
};
};
},
start () {
// 获取抽奖组件实例
const $lucky = this.selectComponent('#myLucky')
// 调用play方法开始旋转
$lucky.play()
// 用定时器模拟请求接口
setTimeout(() => {
// 3s 后得到中奖索引
const index = Math.random() * 6 >> 0
// 调用stop方法然后缓慢停止
$lucky.stop(index)
}, 3000)
},
end (event) {
// 中奖奖品详情
console.log(event.detail)
},
showPopup() {
this.setData({
showPopup: true,
});
},
closePopup() {
this.setData({
showPopup: false,
});
},
})