|
@@ -19,9 +19,9 @@ export default class wheelSurf extends PureComponent { |
|
@@ -19,9 +19,9 @@ export default class wheelSurf extends PureComponent { |
19
|
super(props);
|
19
|
super(props);
|
20
|
this.state = {
|
20
|
this.state = {
|
21
|
uid: 0,
|
21
|
uid: 0,
|
|
|
22
|
+ expIdx: 1,
|
22
|
query: {},
|
23
|
query: {},
|
23
|
canStart: true, // 可以抽奖
|
24
|
canStart: true, // 可以抽奖
|
24
|
- pending: false, // 抽奖中
|
|
|
25
|
slowEnding: false, // 减速结束
|
25
|
slowEnding: false, // 减速结束
|
26
|
startEnded: false, // 已结束
|
26
|
startEnded: false, // 已结束
|
27
|
|
27
|
|
|
@@ -108,6 +108,7 @@ export default class wheelSurf extends PureComponent { |
|
@@ -108,6 +108,7 @@ export default class wheelSurf extends PureComponent { |
108
|
if (result.code === 200) {
|
108
|
if (result.code === 200) {
|
109
|
this.setState({
|
109
|
this.setState({
|
110
|
conf: result.data.conf,
|
110
|
conf: result.data.conf,
|
|
|
111
|
+ expIdx: result.data.prize_idx,
|
111
|
totalParts: result.data.prize,
|
112
|
totalParts: result.data.prize,
|
112
|
remainCount: result.data.residueCount,
|
113
|
remainCount: result.data.residueCount,
|
113
|
dayLeftTimesTip: result.data.conf.btm_tip_one,
|
114
|
dayLeftTimesTip: result.data.conf.btm_tip_one,
|
|
@@ -122,12 +123,13 @@ export default class wheelSurf extends PureComponent { |
|
@@ -122,12 +123,13 @@ export default class wheelSurf extends PureComponent { |
122
|
};
|
123
|
};
|
123
|
|
124
|
|
124
|
setWxShare = () => {
|
125
|
setWxShare = () => {
|
125
|
- // TODO 分享信息
|
126
|
+ const {conf} = this.state;
|
|
|
127
|
+
|
126
|
yaSDK.wxShare({
|
128
|
yaSDK.wxShare({
|
127
|
- title: 'haha',
|
|
|
128
|
- imgUrl: '',
|
|
|
129
|
- desc: '描述',
|
|
|
130
|
- link: ''
|
129
|
+ title: conf.share_title,
|
|
|
130
|
+ imgUrl: `${conf.share_img}?imageView2/1/w/200/h/200`,
|
|
|
131
|
+ desc: conf.share_desc,
|
|
|
132
|
+ link: conf.share_url
|
131
|
});
|
133
|
});
|
132
|
};
|
134
|
};
|
133
|
|
135
|
|
|
@@ -142,13 +144,17 @@ export default class wheelSurf extends PureComponent { |
|
@@ -142,13 +144,17 @@ export default class wheelSurf extends PureComponent { |
142
|
let result = await start({
|
144
|
let result = await start({
|
143
|
act_id: +this.state.query.actId,
|
145
|
act_id: +this.state.query.actId,
|
144
|
uid: cookie.load('uid'),
|
146
|
uid: cookie.load('uid'),
|
145
|
- sessionKey: cookie.load('session_key'),
|
147
|
+ sessionKey: cookie.load('app_session_key'),
|
146
|
sessionType: cookie.load('app_client_type'),
|
148
|
sessionType: cookie.load('app_client_type'),
|
147
|
appVersion: cookie.load('app_version')
|
149
|
appVersion: cookie.load('app_version')
|
148
|
});
|
150
|
});
|
149
|
|
151
|
|
150
|
if (result.code !== 200) {
|
152
|
if (result.code !== 200) {
|
151
|
- console.log(result.message);
|
153
|
+ result = {
|
|
|
154
|
+ data: {
|
|
|
155
|
+ prize_idx: this.state.expIdx
|
|
|
156
|
+ }
|
|
|
157
|
+ }
|
152
|
}
|
158
|
}
|
153
|
|
159
|
|
154
|
let timer = setTimeout(() => {
|
160
|
let timer = setTimeout(() => {
|
|
@@ -158,7 +164,9 @@ export default class wheelSurf extends PureComponent { |
|
@@ -158,7 +164,9 @@ export default class wheelSurf extends PureComponent { |
158
|
this.setState({
|
164
|
this.setState({
|
159
|
slowEnding: true
|
165
|
slowEnding: true
|
160
|
});
|
166
|
});
|
161
|
- }, 2000);
|
167
|
+ this.state.angle = this.state.stopAngle;
|
|
|
168
|
+ this.stop(this.state.stopAngle);
|
|
|
169
|
+ }, 4000);
|
162
|
};
|
170
|
};
|
163
|
|
171
|
|
164
|
calcStopAngle = idx => {
|
172
|
calcStopAngle = idx => {
|
|
@@ -198,19 +206,37 @@ export default class wheelSurf extends PureComponent { |
|
@@ -198,19 +206,37 @@ export default class wheelSurf extends PureComponent { |
198
|
this.rotate();
|
206
|
this.rotate();
|
199
|
};
|
207
|
};
|
200
|
|
208
|
|
|
|
209
|
+ stop = angle => {
|
|
|
210
|
+ let rotateDeg = angle + 360 * 5;
|
|
|
211
|
+ let randCssName = 'stop_' + (new Date()).getTime();
|
|
|
212
|
+ let randCssContent = '{' +
|
|
|
213
|
+ 'transform: rotateZ(' + rotateDeg + 'deg) !important;' +
|
|
|
214
|
+ '-webkit-transform: rotateZ(' + rotateDeg + 'deg) !important;' +
|
|
|
215
|
+ '-webkit-transition: transform 4s ease-out;' +
|
|
|
216
|
+ '}';
|
|
|
217
|
+
|
|
|
218
|
+ document.getElementsByTagName('style')[0].innerHTML += ('.' + randCssName + ' ' + randCssContent);
|
|
|
219
|
+ document.getElementById('rotateWheel').className = 'wheel-bg ' + randCssName;
|
|
|
220
|
+ document.getElementById('rotateWheel').style.webkitTransform = 'rotateZ(' + angle + 'deg)';
|
|
|
221
|
+
|
|
|
222
|
+
|
|
|
223
|
+ let timer = setTimeout(() => {
|
|
|
224
|
+ this.setState({
|
|
|
225
|
+ startEnded: true
|
|
|
226
|
+ });
|
|
|
227
|
+ clearTimeout(timer);
|
|
|
228
|
+ }, 4000);
|
|
|
229
|
+ };
|
|
|
230
|
+
|
201
|
rotate = () => {
|
231
|
rotate = () => {
|
202
|
- let {slowEnding, startEnded, remainCount} = this.state;
|
232
|
+ let {slowEnding, startEnded} = this.state;
|
203
|
|
233
|
|
204
|
if (startEnded) {
|
234
|
if (startEnded) {
|
205
|
return;
|
235
|
return;
|
206
|
}
|
236
|
}
|
207
|
|
237
|
|
208
|
if (!slowEnding) {
|
238
|
if (!slowEnding) {
|
209
|
- this.setState({
|
|
|
210
|
- pending: true
|
|
|
211
|
- });
|
|
|
212
|
-
|
|
|
213
|
- if (this.state.speed < 20) {
|
239
|
+ if (this.state.speed < 16) {
|
214
|
this.state.speed += 0.2;
|
240
|
this.state.speed += 0.2;
|
215
|
}
|
241
|
}
|
216
|
|
242
|
|
|
@@ -218,45 +244,9 @@ export default class wheelSurf extends PureComponent { |
|
@@ -218,45 +244,9 @@ export default class wheelSurf extends PureComponent { |
218
|
if (this.state.angle >= 360) {
|
244
|
if (this.state.angle >= 360) {
|
219
|
this.state.angle -= 360;
|
245
|
this.state.angle -= 360;
|
220
|
}
|
246
|
}
|
221
|
- } else {
|
|
|
222
|
- this.state.angle = parseInt(this.state.angle);
|
|
|
223
|
-
|
|
|
224
|
- if (this.state.angle >= 360 ) {
|
|
|
225
|
- this.state.angle -= 360;
|
|
|
226
|
- }
|
|
|
227
|
- if (!this.state.setStopAngle) {
|
|
|
228
|
- this.state.angle += 3;
|
|
|
229
|
-
|
|
|
230
|
- if (this.state.angle >= 359) {
|
|
|
231
|
- this.state.angle = 0;
|
|
|
232
|
- this.state.setStopAngle = true;
|
|
|
233
|
- }
|
|
|
234
|
- }
|
|
|
235
|
- if (this.state.setStopAngle) {
|
|
|
236
|
- let diff = this.state.stopAngle - this.state.angle;
|
|
|
237
|
-
|
|
|
238
|
- switch (true) {
|
|
|
239
|
- case (diff > 200):
|
|
|
240
|
- this.state.angle += 4;
|
|
|
241
|
- break;
|
|
|
242
|
- case (diff > 100):
|
|
|
243
|
- this.state.angle += 2;
|
|
|
244
|
- break;
|
|
|
245
|
- default:
|
|
|
246
|
- this.state.angle += 1;
|
|
|
247
|
- }
|
|
|
248
|
-
|
|
|
249
|
- if (this.state.angle >= this.state.stopAngle) {
|
|
|
250
|
- this.state.setStopAngle = false;
|
|
|
251
|
-
|
|
|
252
|
- this.setState({
|
|
|
253
|
- startEnded: true
|
|
|
254
|
- });
|
|
|
255
|
- }
|
|
|
256
|
- }
|
|
|
257
|
}
|
247
|
}
|
258
|
|
248
|
|
259
|
- if (!this.state.startEnded) {
|
249
|
+ if (!this.state.slowEnding) {
|
260
|
document.getElementById('rotateWheel').style.webkitTransform = 'rotateZ(' + this.state.angle + 'deg)';
|
250
|
document.getElementById('rotateWheel').style.webkitTransform = 'rotateZ(' + this.state.angle + 'deg)';
|
261
|
requestAnimationFrame(this.rotate)
|
251
|
requestAnimationFrame(this.rotate)
|
262
|
}
|
252
|
}
|
|
@@ -295,6 +285,7 @@ export default class wheelSurf extends PureComponent { |
|
@@ -295,6 +285,7 @@ export default class wheelSurf extends PureComponent { |
295
|
startEnded: false,
|
285
|
startEnded: false,
|
296
|
speed: 0
|
286
|
speed: 0
|
297
|
});
|
287
|
});
|
|
|
288
|
+ document.getElementById('rotateWheel').className = 'wheel-bg';
|
298
|
};
|
289
|
};
|
299
|
|
290
|
|
300
|
shareInApp = () => {
|
291
|
shareInApp = () => {
|