Authored by 黄敬囿

Merge branch 'feature/lottery-price' into 'master'

YOHOOD抽奖

YOHOOD抽奖需求

See merge request !19
1 import md5 from './vendors/md5'; 1 import md5 from './vendors/md5';
2 -import {GET} from './libs/request';  
3 -import {WeToast} from './vendors/toast/wetoast'; 2 +import { GET } from './libs/request';
  3 +import { WeToast } from './vendors/toast/wetoast';
4 import objectAssign from './vendors/object-assign'; 4 import objectAssign from './vendors/object-assign';
5 -import {API_HOST, MINI_APP_TYPE} from './libs/config'; 5 +import { API_HOST, MINI_APP_TYPE } from './libs/config';
6 import mta from './vendors/mta_analysis'; 6 import mta from './vendors/mta_analysis';
7 -import {Event} from '/login/utils/index.js';  
8 -import {wxLogin} from '/login/utils/login/login'; 7 +import { Event } from '/login/utils/index.js';
  8 +import { wxLogin } from '/login/utils/login/login';
9 import appReport from './libs/appReport'; 9 import appReport from './libs/appReport';
10 import iconfSwitch from './libs/switch'; 10 import iconfSwitch from './libs/switch';
11 -import {isStringEmpty, getYHStorageSync} from './utils/util'; 11 +import { isStringEmpty, getYHStorageSync } from './utils/util';
12 import regeneratorRuntime from '/login/libs/regenerator-runtime/index'; 12 import regeneratorRuntime from '/login/libs/regenerator-runtime/index';
13 13
14 import { 14 import {
@@ -17,13 +17,13 @@ import { @@ -17,13 +17,13 @@ import {
17 YB_ENTER_FOREGROUND, 17 YB_ENTER_FOREGROUND,
18 YB_ENTER_BACKGROUND, 18 YB_ENTER_BACKGROUND,
19 YB_AWAKE_MP, 19 YB_AWAKE_MP,
20 - YB_MY_LOGIN 20 + YB_MY_LOGIN,
21 } from './libs/yas'; 21 } from './libs/yas';
22 import router from './pages/zeroSell/router/router'; 22 import router from './pages/zeroSell/router/router';
23 23
24 const event = new Event(); 24 const event = new Event();
25 global.event = event; 25 global.event = event;
26 - 26 +
27 App({ 27 App({
28 async onLaunch(options) { 28 async onLaunch(options) {
29 let that = this; 29 let that = this;
@@ -41,51 +41,51 @@ App({ @@ -41,51 +41,51 @@ App({
41 that.getSimplePise(); 41 that.getSimplePise();
42 this.checkNetworkType(); 42 this.checkNetworkType();
43 43
44 - if (options && options.scene){  
45 - this.globalData.ch = options.scene 44 + if (options && options.scene) {
  45 + this.globalData.ch = options.scene;
46 } 46 }
47 47
48 - if (options && options.query && options.query.union_type){  
49 - this.updateUnionType(options.query.union_type) 48 + if (options && options.query && options.query.union_type) {
  49 + this.updateUnionType(options.query.union_type);
50 } 50 }
51 51
52 wx.checkSession({ 52 wx.checkSession({
53 - success: function () { 53 + success: function() {
54 that.getWechatThirdSession(); 54 that.getWechatThirdSession();
55 that.getUserInfo(); 55 that.getUserInfo();
56 that.getUnionID(); 56 that.getUnionID();
57 that.getUser_union_type(); 57 that.getUser_union_type();
58 }, 58 },
59 - fail: function () { 59 + fail: function() {
60 wx.setStorage({ 60 wx.setStorage({
61 key: 'WXThird_session', 61 key: 'WXThird_session',
62 - data: '' 62 + data: '',
63 }); 63 });
64 wx.setStorage({ 64 wx.setStorage({
65 key: 'userInfo', 65 key: 'userInfo',
66 - data: {} 66 + data: {},
67 }); 67 });
68 68
69 wx.setStorage({ 69 wx.setStorage({
70 key: 'unionID', 70 key: 'unionID',
71 - data: '' 71 + data: '',
72 }); 72 });
73 73
74 wx.setStorage({ 74 wx.setStorage({
75 key: 'user_union_type', 75 key: 'user_union_type',
76 - data: '' 76 + data: '',
77 }); 77 });
78 - } 78 + },
79 }); 79 });
80 this.getSessionkey(); 80 this.getSessionkey();
81 let timestamp = new Date().getTime() + ''; 81 let timestamp = new Date().getTime() + '';
82 this.globalData.sid = md5(timestamp); 82 this.globalData.sid = md5(timestamp);
83 83
84 - if (options){ 84 + if (options) {
85 let channel = options.query.channel; 85 let channel = options.query.channel;
86 let channelType = options.query.type; 86 let channelType = options.query.type;
87 - let params = { 'CHANNEL': channel, 'TYPE': channelType };  
88 - yasReport(YB_LAUNCH_APP, params, this); 87 + let params = { CHANNEL: channel, TYPE: channelType };
  88 + yasReport(YB_LAUNCH_APP, params, this);
89 } 89 }
90 this.mtainit(options); 90 this.mtainit(options);
91 await wxLogin(); 91 await wxLogin();
@@ -101,74 +101,86 @@ App({ @@ -101,74 +101,86 @@ App({
101 logged(userInfo); 101 logged(userInfo);
102 } 102 }
103 } else { 103 } else {
104 - event.once('user-login-success', (userInfo) => {  
105 - yasReport(YB_MY_LOGIN, {LOGIN_TYPE: 4}); 104 + event.once('user-login-success', userInfo => {
  105 + yasReport(YB_MY_LOGIN, { LOGIN_TYPE: 4 });
106 if (loginSuccess) { 106 if (loginSuccess) {
107 loginSuccess(userInfo); 107 loginSuccess(userInfo);
108 } 108 }
109 }); 109 });
110 wx.navigateTo({ 110 wx.navigateTo({
111 url: '/login/login-page/login-page', 111 url: '/login/login-page/login-page',
112 - }) 112 + });
113 } 113 }
114 }); 114 });
115 }, 115 },
116 -  
117 - //当应用程序进入前台显示状态时触发 116 +
  117 + //当应用程序进入前台显示状态时触发
118 onShow(options) { 118 onShow(options) {
119 - iconfSwitch(this).then(data => {  
120 - console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> app onshow switch');  
121 - this.globalData.hasSetSwitch = true; 119 + iconfSwitch(this).then(
  120 + data => {
  121 + console.log(
  122 + '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> app onshow switch',
  123 + );
  124 + this.globalData.hasSetSwitch = true;
122 if (data['javaapi'] && '0' === data['javaapi']) { 125 if (data['javaapi'] && '0' === data['javaapi']) {
123 this.globalData.switch_javaApiEnable = false; 126 this.globalData.switch_javaApiEnable = false;
124 } 127 }
125 - }, () => {  
126 - this.globalData.hasSetSwitch = true;  
127 - });  
128 - let that = this 128 + },
  129 + () => {
  130 + this.globalData.hasSetSwitch = true;
  131 + },
  132 + );
  133 + let that = this;
129 let params = {}; 134 let params = {};
130 - yasReport(YB_ENTER_FOREGROUND, params, that)  
131 - if (!that.globalData.hasReportAwakeAction){  
132 - let pathParam = ""  
133 - if(options && options.query) { 135 + yasReport(YB_ENTER_FOREGROUND, params, that);
  136 + if (!that.globalData.hasReportAwakeAction) {
  137 + let pathParam = '';
  138 + if (options && options.query) {
134 for (var Key in options.query) { 139 for (var Key in options.query) {
135 if (pathParam.length == 0) { 140 if (pathParam.length == 0) {
136 pathParam = Key + '=' + options.query[Key] + ''; 141 pathParam = Key + '=' + options.query[Key] + '';
137 } else { 142 } else {
138 - pathParam = pathParam + '&' + '' + Key + '=' + options.query[Key] + ''; 143 + pathParam =
  144 + pathParam + '&' + '' + Key + '=' + options.query[Key] + '';
139 } 145 }
140 } 146 }
141 } 147 }
142 let path = ''; 148 let path = '';
143 if (options && options.path) { 149 if (options && options.path) {
144 - path = options.path 150 + path = options.path;
145 } 151 }
146 - if(pathParam!==""){  
147 - path = path + "?" + pathParam 152 + if (pathParam !== '') {
  153 + path = path + '?' + pathParam;
148 } 154 }
149 params = { 155 params = {
150 - PAGE_PATH: path 156 + PAGE_PATH: path,
151 }; 157 };
152 yasReport(YB_AWAKE_MP, params, this); 158 yasReport(YB_AWAKE_MP, params, this);
153 that.globalData.hasReportAwakeAction = true; 159 that.globalData.hasReportAwakeAction = true;
154 } 160 }
155 161
156 - if (options && options.scene){  
157 - appReport({  
158 - reportType: 'start',  
159 - pt: 'LIFECYCLE',  
160 - pn: 'RESUME',  
161 - param: {  
162 - 'activeWay': options.scene + ''  
163 - }  
164 - }, this);  
165 - }else{  
166 - appReport({  
167 - reportType: 'start',  
168 - pt: 'LIFECYCLE',  
169 - pn: 'RESUME',  
170 - param: {}  
171 - }, this); 162 + if (options && options.scene) {
  163 + appReport(
  164 + {
  165 + reportType: 'start',
  166 + pt: 'LIFECYCLE',
  167 + pn: 'RESUME',
  168 + param: {
  169 + activeWay: options.scene + '',
  170 + },
  171 + },
  172 + this,
  173 + );
  174 + } else {
  175 + appReport(
  176 + {
  177 + reportType: 'start',
  178 + pt: 'LIFECYCLE',
  179 + pn: 'RESUME',
  180 + param: {},
  181 + },
  182 + this,
  183 + );
172 } 184 }
173 185
174 let scene = options ? options.scene : ''; 186 let scene = options ? options.scene : '';
@@ -176,19 +188,22 @@ App({ @@ -176,19 +188,22 @@ App({
176 }, 188 },
177 189
178 //当应用程序进入后台状态时触发 190 //当应用程序进入后台状态时触发
179 - onHide () { 191 + onHide() {
180 let params = {}; 192 let params = {};
181 yasReport(YB_ENTER_BACKGROUND, params); 193 yasReport(YB_ENTER_BACKGROUND, params);
182 - appReport({  
183 - reportType: 'start',  
184 - pt: 'LIFECYCLE',  
185 - pn: 'STOP',  
186 - param: {}  
187 - }, this); 194 + appReport(
  195 + {
  196 + reportType: 'start',
  197 + pt: 'LIFECYCLE',
  198 + pn: 'STOP',
  199 + param: {},
  200 + },
  201 + this,
  202 + );
188 }, 203 },
189 204
190 - getUserInfo: function () {  
191 - var value = getYHStorageSync('userInfo','app') 205 + getUserInfo: function() {
  206 + var value = getYHStorageSync('userInfo', 'app');
192 if (value) { 207 if (value) {
193 this.globalData.userInfo = value; 208 this.globalData.userInfo = value;
194 } 209 }
@@ -199,126 +214,128 @@ App({ @@ -199,126 +214,128 @@ App({
199 return this.globalData.userInfo.mobile; 214 return this.globalData.userInfo.mobile;
200 }, 215 },
201 216
202 - getUser_union_type: function () { 217 + getUser_union_type: function() {
203 this.getUnionTypeWithUid(this.getUid()); 218 this.getUnionTypeWithUid(this.getUid());
204 }, 219 },
205 220
206 /* 221 /*
207 - *union_type表示渠道号,在推广阶段通过商品详情页等传入。  
208 - * 接收到该参数时,赋值给全局变量时,持久化到本地。  
209 - * 在取值时,先从全局变量获取,若未获取到则从本地缓存中获取。  
210 - * 时效48小时  
211 - */  
212 - getUnion_type: function () { 222 + *union_type表示渠道号,在推广阶段通过商品详情页等传入。
  223 + * 接收到该参数时,赋值给全局变量时,持久化到本地。
  224 + * 在取值时,先从全局变量获取,若未获取到则从本地缓存中获取。
  225 + * 时效48小时
  226 + */
  227 + getUnion_type: function() {
213 try { 228 try {
214 - var value = this.checkUnion_type(this.globalData.union_type, this.globalData.union_type_time); 229 + var value = this.checkUnion_type(
  230 + this.globalData.union_type,
  231 + this.globalData.union_type_time,
  232 + );
215 if (!value) { 233 if (!value) {
216 - let union_type = getYHStorageSync('union_type','app');  
217 - let union_type_time = getYHStorageSync('union_type_time','app');  
218 - value = this.checkUnion_type(union_type, union_type_time); 234 + let union_type = getYHStorageSync('union_type', 'app');
  235 + let union_type_time = getYHStorageSync('union_type_time', 'app');
  236 + value = this.checkUnion_type(union_type, union_type_time);
219 } 237 }
220 - return value 238 + return value;
221 } catch (e) { 239 } catch (e) {
222 // console.log(e) 240 // console.log(e)
223 } 241 }
224 }, 242 },
225 243
226 - checkUnion_type: function (union_type, union_type_time) {  
227 - if (!union_type)return ''; 244 + checkUnion_type: function(union_type, union_type_time) {
  245 + if (!union_type) return '';
228 let time_old = union_type_time; 246 let time_old = union_type_time;
229 let time_new = new Date().getTime() + ''; 247 let time_new = new Date().getTime() + '';
230 - var dayDiff = parseInt ((parseInt(time_new) - parseInt(time_old)) / 1000 ); 248 + var dayDiff = parseInt((parseInt(time_new) - parseInt(time_old)) / 1000);
231 if (dayDiff > 2 * 24 * 3600) { 249 if (dayDiff > 2 * 24 * 3600) {
232 return ''; 250 return '';
233 } 251 }
234 return union_type; 252 return union_type;
235 }, 253 },
236 254
237 - getUnionID: function () {  
238 - var value = getYHStorageSync('unionID','app') 255 + getUnionID: function() {
  256 + var value = getYHStorageSync('unionID', 'app');
239 if (value) { 257 if (value) {
240 this.globalData.WXUnion_ID = value; 258 this.globalData.WXUnion_ID = value;
241 } 259 }
242 }, 260 },
243 261
244 - getWechatThirdSession: function () { 262 + getWechatThirdSession: function() {
245 try { 263 try {
246 - var that = this  
247 - var value = this.globalData.WXThird_session 264 + var that = this;
  265 + var value = this.globalData.WXThird_session;
248 if (!isStringEmpty(value)) { 266 if (!isStringEmpty(value)) {
249 that.globalData.WXThird_session = value; 267 that.globalData.WXThird_session = value;
250 - }else{  
251 - value = getYHStorageSync('WXThird_session','app') 268 + } else {
  269 + value = getYHStorageSync('WXThird_session', 'app');
252 } 270 }
253 - return value 271 + return value;
254 } catch (e) { 272 } catch (e) {
255 // console.log(e) 273 // console.log(e)
256 } 274 }
257 }, 275 },
258 276
259 - setUserInfo: function (cb) { 277 + setUserInfo: function(cb) {
260 this.globalData.userInfo = objectAssign(this.globalData.userInfo, cb); 278 this.globalData.userInfo = objectAssign(this.globalData.userInfo, cb);
261 wx.setStorage({ 279 wx.setStorage({
262 - key: "userInfo",  
263 - data: this.globalData.userInfo  
264 - }) 280 + key: 'userInfo',
  281 + data: this.globalData.userInfo,
  282 + });
265 if (this.globalData.userInfo.uid) { 283 if (this.globalData.userInfo.uid) {
266 this.getUnionTypeWithUid(this.globalData.userInfo.uid); 284 this.getUnionTypeWithUid(this.globalData.userInfo.uid);
267 } 285 }
268 }, 286 },
269 287
270 - setSessionkey: function (sessionkey) { 288 + setSessionkey: function(sessionkey) {
271 this.globalData.sessionkey = sessionkey; 289 this.globalData.sessionkey = sessionkey;
272 wx.setStorage({ 290 wx.setStorage({
273 - key: "sessionkey",  
274 - data: this.globalData.sessionkey  
275 - }) 291 + key: 'sessionkey',
  292 + data: this.globalData.sessionkey,
  293 + });
276 }, 294 },
277 295
278 - setWechatThirdSession: function (session) { 296 + setWechatThirdSession: function(session) {
279 this.globalData.WXThird_session = session; 297 this.globalData.WXThird_session = session;
280 wx.setStorage({ 298 wx.setStorage({
281 - key: "WXThird_session",  
282 - data: this.globalData.WXThird_session  
283 - }) 299 + key: 'WXThird_session',
  300 + data: this.globalData.WXThird_session,
  301 + });
284 }, 302 },
285 303
286 - setWXUnionID: function (unionID) { 304 + setWXUnionID: function(unionID) {
287 this.globalData.WXUnion_ID = unionID; 305 this.globalData.WXUnion_ID = unionID;
288 wx.setStorage({ 306 wx.setStorage({
289 - key: "unionID",  
290 - data: unionID  
291 - }) 307 + key: 'unionID',
  308 + data: unionID,
  309 + });
292 }, 310 },
293 311
294 - setOpenID:function(openID){  
295 -  
296 - if(openID=='') return 312 + setOpenID: function(openID) {
  313 + if (openID == '') return;
297 this.globalData.openID = openID; 314 this.globalData.openID = openID;
298 wx.setStorage({ 315 wx.setStorage({
299 - key: "openID",  
300 - data: openID  
301 - })  
302 - },  
303 -  
304 - getOpenID: function () {  
305 - let openid = ''  
306 - if (!isStringEmpty(this.globalData.openID)){  
307 - openid = this.globalData.openID  
308 - }else{  
309 - openid = getYHStorageSync('open_id','app')  
310 - this.globalData.openID = openid 316 + key: 'openID',
  317 + data: openID,
  318 + });
  319 + },
  320 +
  321 + getOpenID: function() {
  322 + let openid = '';
  323 + if (!isStringEmpty(this.globalData.openID)) {
  324 + openid = this.globalData.openID;
  325 + } else {
  326 + openid = getYHStorageSync('open_id', 'app');
  327 + this.globalData.openID = openid;
311 } 328 }
312 - return openid 329 + return openid;
313 }, 330 },
314 331
315 - updateUid: function (uid) { 332 + updateUid: function(uid) {
316 this.getUserInfo(); 333 this.getUserInfo();
317 this.globalData.userInfo.uid = uid; 334 this.globalData.userInfo.uid = uid;
318 wx.setStorage({ 335 wx.setStorage({
319 - key: "userInfo",  
320 - data: this.globalData.userInfo  
321 - }) 336 + key: 'userInfo',
  337 + data: this.globalData.userInfo,
  338 + });
322 this.getUnionTypeWithUid(uid); 339 this.getUnionTypeWithUid(uid);
323 }, 340 },
324 341
@@ -330,88 +347,87 @@ App({ @@ -330,88 +347,87 @@ App({
330 systemInfo: null, 347 systemInfo: null,
331 WXThird_session: '', 348 WXThird_session: '',
332 WXUnion_ID: '', 349 WXUnion_ID: '',
333 - openID:'', 350 + openID: '',
334 p2SecretKey: '', 351 p2SecretKey: '',
335 sessionkey: '', 352 sessionkey: '',
336 sid: '', 353 sid: '',
337 - udid:'',  
338 - cid:'1',  
339 - mobileRegisterState:'', 354 + udid: '',
  355 + cid: '1',
  356 + mobileRegisterState: '',
340 hasReportAwakeAction: false, 357 hasReportAwakeAction: false,
341 - defraudurl:'https://activity.yoho.cn/feature/45.html?title=防诈骗提醒', 358 + defraudurl: 'https://activity.yoho.cn/feature/45.html?title=防诈骗提醒',
342 miniapp_type: MINI_APP_TYPE, 359 miniapp_type: MINI_APP_TYPE,
343 - union_type:'',//渠道号,大数据上传用 360 + union_type: '', //渠道号,大数据上传用
344 union_type_time: '', 361 union_type_time: '',
345 - ch:'',  
346 - networkType:'0',  
347 - deviceInfo:{}, 362 + ch: '',
  363 + networkType: '0',
  364 + deviceInfo: {},
348 currentScene: 1001, 365 currentScene: 1001,
349 - user_union_type: '',//用户相关unionType 要与union_type区分开  
350 - user_union_type_imageUrl: '',//联盟图片  
351 - user_nounion_type_imageUrl:'',//非联盟用户分享banner图片 366 + user_union_type: '', //用户相关unionType 要与union_type区分开
  367 + user_union_type_imageUrl: '', //联盟图片
  368 + user_nounion_type_imageUrl: '', //非联盟用户分享banner图片
352 shareId: '', 369 shareId: '',
353 shareInfo: {}, 370 shareInfo: {},
354 }, 371 },
355 372
356 - isLogin: function () { 373 + isLogin: function() {
357 let uid = this.getUid(); 374 let uid = this.getUid();
358 return uid > 0; 375 return uid > 0;
359 }, 376 },
360 377
361 - getUid: function () { 378 + getUid: function() {
362 let uid = this.globalData.userInfo.uid; 379 let uid = this.globalData.userInfo.uid;
363 - if(!uid || uid === 0){ 380 + if (!uid || uid === 0) {
364 let userInfo = this.getUserInfo(); 381 let userInfo = this.getUserInfo();
365 - uid = userInfo.uid || 0 382 + uid = userInfo.uid || 0;
366 } 383 }
367 return uid; 384 return uid;
368 }, 385 },
369 386
370 - getMiniappType:function(){  
371 - return MINI_APP_TYPE 387 + getMiniappType: function() {
  388 + return MINI_APP_TYPE;
372 }, 389 },
373 390
374 //获取加签的秘钥 391 //获取加签的秘钥
375 - getSimplePise: function () {  
376 - let that = this  
377 - let data = {  
378 - "udid": that.globalData.udid,  
379 - "method": 'resources.simple.pice'}  
380 - let method = "GET" 392 + getSimplePise: function() {
  393 + let that = this;
  394 + let data = {
  395 + udid: that.globalData.udid,
  396 + method: 'resources.simple.pice',
  397 + };
  398 + let method = 'GET';
381 let header = { 399 let header = {
382 - 'Content-Type': 'application/x-www-form-urlencoded'  
383 - } 400 + 'Content-Type': 'application/x-www-form-urlencoded',
  401 + };
384 402
385 wx.request({ 403 wx.request({
386 - url:API_HOST, 404 + url: API_HOST,
387 data, 405 data,
388 method, 406 method,
389 header: header, 407 header: header,
390 - success: function (res) { 408 + success: function(res) {
391 // console.log("res:", res) 409 // console.log("res:", res)
392 - if (res && res.data && res.data.data && res.data.data.sk){ 410 + if (res && res.data && res.data.data && res.data.data.sk) {
393 that.globalData.p2SecretKey = res.data.data.sk; 411 that.globalData.p2SecretKey = res.data.data.sk;
394 wx.setStorage({ 412 wx.setStorage({
395 - key: "p2SecretKey",  
396 - data: res.data.data.sk 413 + key: 'p2SecretKey',
  414 + data: res.data.data.sk,
397 }); 415 });
398 } 416 }
399 }, 417 },
400 - fail: function (err) {  
401 -  
402 - } 418 + fail: function(err) {},
403 }); 419 });
404 }, 420 },
405 421
406 /* 422 /*
407 获取用户相关union_type 423 获取用户相关union_type
408 */ 424 */
409 - getUnionTypeWithUid: function (uid) { 425 + getUnionTypeWithUid: function(uid) {
410 if (!uid) return; 426 if (!uid) return;
411 let param = { 427 let param = {
412 method: 'app.union.shareOrder.queryUnionTypeByUid', 428 method: 'app.union.shareOrder.queryUnionTypeByUid',
413 uid, 429 uid,
414 - } 430 + };
415 let that = this; 431 let that = this;
416 GET(API_HOST, param) 432 GET(API_HOST, param)
417 .then(data => { 433 .then(data => {
@@ -422,14 +438,13 @@ App({ @@ -422,14 +438,13 @@ App({
422 that.globalData.user_nounion_type_imageUrl = data.data.applyImageUrl; 438 that.globalData.user_nounion_type_imageUrl = data.data.applyImageUrl;
423 } 439 }
424 }) 440 })
425 - .catch(error => {  
426 - }); 441 + .catch(error => {});
427 }, 442 },
428 443
429 - getShareInfo: function () { 444 + getShareInfo: function() {
430 let param = { 445 let param = {
431 share_id: this.globalData.shareId, 446 share_id: this.globalData.shareId,
432 - } 447 + };
433 let that = this; 448 let that = this;
434 GET(API_HOST + '/operations/api/v5/webshare/getShare', param) 449 GET(API_HOST + '/operations/api/v5/webshare/getShare', param)
435 .then(data => { 450 .then(data => {
@@ -437,35 +452,31 @@ App({ @@ -437,35 +452,31 @@ App({
437 that.globalData.shareInfo = data.data; 452 that.globalData.shareInfo = data.data;
438 } 453 }
439 }) 454 })
440 - .catch(error => {  
441 - }); 455 + .catch(error => {});
442 }, 456 },
443 457
444 - fastloginSwitch: function () {  
445 - let that = this 458 + fastloginSwitch: function() {
  459 + let that = this;
446 let param = { 460 let param = {
447 method: 'app.passport.fastloginSwitch', 461 method: 'app.passport.fastloginSwitch',
448 }; 462 };
449 GET(API_HOST, param) 463 GET(API_HOST, param)
450 - .then(json => {  
451 - })  
452 - .catch(error => {  
453 - }); 464 + .then(json => {})
  465 + .catch(error => {});
454 }, 466 },
455 467
456 - checkUDID:function(){  
457 - let that = this 468 + checkUDID: function() {
  469 + let that = this;
458 try { 470 try {
459 - var value = getYHStorageSync('udid','app') 471 + var value = getYHStorageSync('udid', 'app');
460 if (value) { 472 if (value) {
461 that.globalData.udid = value; 473 that.globalData.udid = value;
462 - }else{ 474 + } else {
463 let udidValue = md5(that.getUUID()); 475 let udidValue = md5(that.getUUID());
464 that.globalData.udid = udidValue; 476 that.globalData.udid = udidValue;
465 try { 477 try {
466 - wx.setStorageSync('udid', udidValue)  
467 - } catch (e) {  
468 - } 478 + wx.setStorageSync('udid', udidValue);
  479 + } catch (e) {}
469 } 480 }
470 //获取签名秘钥 481 //获取签名秘钥
471 } catch (e) { 482 } catch (e) {
@@ -474,15 +485,15 @@ App({ @@ -474,15 +485,15 @@ App({
474 } 485 }
475 }, 486 },
476 487
477 - checkNetworkType:function(){ 488 + checkNetworkType: function() {
478 let that = this; 489 let that = this;
479 let net = ''; 490 let net = '';
480 491
481 wx.getNetworkType({ 492 wx.getNetworkType({
482 - success: function (res) { 493 + success: function(res) {
483 // 返回网络类型, 有效值: 494 // 返回网络类型, 有效值:
484 // wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络) 495 // wifi/2g/3g/4g/unknown(Android下不常见的网络类型)/none(无网络)
485 - var networkType = res.networkType 496 + var networkType = res.networkType;
486 if (networkType === 'wifi') { 497 if (networkType === 'wifi') {
487 net = '1'; 498 net = '1';
488 } else if (networkType === '2g') { 499 } else if (networkType === '2g') {
@@ -495,30 +506,43 @@ App({ @@ -495,30 +506,43 @@ App({
495 net = '0'; 506 net = '0';
496 } 507 }
497 }, 508 },
498 - complete:function(res){  
499 - appReport({  
500 - reportType: 'start',  
501 - pt: 'LIFECYCLE',  
502 - pn: 'START',  
503 - param: {}  
504 - }, that);  
505 - }  
506 - }) 509 + complete: function(res) {
  510 + appReport(
  511 + {
  512 + reportType: 'start',
  513 + pt: 'LIFECYCLE',
  514 + pn: 'START',
  515 + param: {},
  516 + },
  517 + that,
  518 + );
  519 + },
  520 + });
507 that.globalData.networkType = net; 521 that.globalData.networkType = net;
508 }, 522 },
509 523
510 - getUUID: function () {  
511 - let value = "" + Date.now() + '-' + Math.floor(1e7 * Math.random()) + '-' + Math.random().toString(16).replace('.', '') + '-' + String(Math.random() * 31242).replace('.', '').slice(0, 8); 524 + getUUID: function() {
  525 + let value =
  526 + '' +
  527 + Date.now() +
  528 + '-' +
  529 + Math.floor(1e7 * Math.random()) +
  530 + '-' +
  531 + Math.random()
  532 + .toString(16)
  533 + .replace('.', '') +
  534 + '-' +
  535 + String(Math.random() * 31242)
  536 + .replace('.', '')
  537 + .slice(0, 8);
512 return value; 538 return value;
513 }, 539 },
514 540
515 - loginCallBack: function (response) {  
516 -  
517 - }, 541 + loginCallBack: function(response) {},
518 542
519 - getSessionkey: function () { 543 + getSessionkey: function() {
520 if (this.isLogin) { 544 if (this.isLogin) {
521 - var value = getYHStorageSync('sessionkey','app'); 545 + var value = getYHStorageSync('sessionkey', 'app');
522 if (value) { 546 if (value) {
523 this.globalData.sessionkey = value; 547 this.globalData.sessionkey = value;
524 } 548 }
@@ -527,18 +551,18 @@ App({ @@ -527,18 +551,18 @@ App({
527 }, 551 },
528 552
529 //更新渠道号同时更新时间戳,48小时失效 553 //更新渠道号同时更新时间戳,48小时失效
530 - updateUnionType: function (union_type) {  
531 - if (union_type){ 554 + updateUnionType: function(union_type) {
  555 + if (union_type) {
532 let timeS = new Date().getTime() + ''; 556 let timeS = new Date().getTime() + '';
533 this.globalData.union_type = union_type; 557 this.globalData.union_type = union_type;
534 this.globalData.union_type_time = timeS; 558 this.globalData.union_type_time = timeS;
535 wx.setStorage({ 559 wx.setStorage({
536 - key: "union_type_time", 560 + key: 'union_type_time',
537 data: timeS, 561 data: timeS,
538 }); 562 });
539 wx.setStorage({ 563 wx.setStorage({
540 - key: "union_type",  
541 - data: union_type 564 + key: 'union_type',
  565 + data: union_type,
542 }); 566 });
543 } 567 }
544 }, 568 },
@@ -547,11 +571,9 @@ App({ @@ -547,11 +571,9 @@ App({
547 }, 571 },
548 mtainit() { 572 mtainit() {
549 mta.App.init({ 573 mta.App.init({
550 - "appID": "500570715",  
551 - "eventID": "500570797", 574 + appID: '500570715',
  575 + eventID: '500570797',
552 }); 576 });
553 }, 577 },
554 - WeToast 578 + WeToast,
555 }); 579 });
556 -  
557 -  
@@ -7,6 +7,7 @@ @@ -7,6 +7,7 @@
7 "pages/zeroSell/error", 7 "pages/zeroSell/error",
8 "pages/bindPhoneNumber/bindPhoneNumber", 8 "pages/bindPhoneNumber/bindPhoneNumber",
9 "pages/choosecountry/choosecountry", 9 "pages/choosecountry/choosecountry",
  10 + "pages/zeroSell/originalPriceSell",
10 "login/login-page/login-page" 11 "login/login-page/login-page"
11 ], 12 ],
12 "window": { 13 "window": {
@@ -22,4 +23,4 @@ @@ -22,4 +23,4 @@
22 "wxf9bac5064053057a" 23 "wxf9bac5064053057a"
23 ], 24 ],
24 "sitemapLocation": "sitemap40.json" 25 "sitemapLocation": "sitemap40.json"
25 -}  
  26 +}
1 -import { getUserInfo, getPhoneNumber, checkUnionIdIsBind } from '../utils/login/login.js'; 1 +import {
  2 + getUserInfo,
  3 + getPhoneNumber,
  4 + checkUnionIdIsBind,
  5 +} from '../utils/login/login.js';
2 Component({ 6 Component({
3 /** 7 /**
4 * 组件的属性列表 8 * 组件的属性列表
@@ -6,41 +10,42 @@ Component({ @@ -6,41 +10,42 @@ Component({
6 properties: { 10 properties: {
7 theme: { 11 theme: {
8 type: String, 12 type: String,
9 - value: 'light' 13 + value: 'light',
10 }, 14 },
11 isShow: Boolean, 15 isShow: Boolean,
12 openType: { 16 openType: {
13 type: String, 17 type: String,
14 - value: "getUserInfo",  
15 - observer: function (newValue, oldValue) {  
16 - if (newValue === "getPhoneNumber") { 18 + value: 'getUserInfo',
  19 + observer: function(newValue, oldValue) {
  20 + if (newValue === 'getPhoneNumber') {
17 this.setData({ 21 this.setData({
18 - loginBtnTitle: "绑定手机号"  
19 - }) 22 + loginBtnTitle: '绑定手机号',
  23 + });
20 } else if (newValue === 'getUserInfo') { 24 } else if (newValue === 'getUserInfo') {
21 this.setData({ 25 this.setData({
22 - loginBtnTitle: "微信授权登录"  
23 - }) 26 + loginBtnTitle: '微信授权登录',
  27 + });
24 } else { 28 } else {
25 this.setData({ 29 this.setData({
26 - loginBtnTitle: "微信登录",  
27 - checkUnionIdIsBind: 'checkUnionIdIsBind'  
28 - }) 30 + loginBtnTitle: '微信登录',
  31 + checkUnionIdIsBind: 'checkUnionIdIsBind',
  32 + });
29 } 33 }
30 - }  
31 - } 34 + },
  35 + },
32 }, 36 },
33 37
34 /** 38 /**
35 * 组件的初始数据 39 * 组件的初始数据
36 */ 40 */
37 data: { 41 data: {
38 - logo: "https://feature.yoho.cn/1019/youhuo2.png",  
39 - lightLogo: "https://img11.static.yhbimg.com/article/2018/11/29/11/018a4f01d4621f9072788f6510ac83bfec.png",  
40 - loginBtnTitle: "微信授权登录",  
41 - subLogoTitle: "LIVE IN STAY COOL",  
42 - tips: "还差一步,绑定手机号,加入Yoho!Family!",  
43 - checkUnionIdIsBind: '' 42 + logo: 'https://feature.yoho.cn/1019/youhuo2.png',
  43 + lightLogo:
  44 + 'https://img11.static.yhbimg.com/article/2018/11/29/11/018a4f01d4621f9072788f6510ac83bfec.png',
  45 + loginBtnTitle: '微信授权登录',
  46 + subLogoTitle: 'LIVE IN STAY COOL',
  47 + tips: '还差一步,绑定手机号,加入Yoho!Family!',
  48 + checkUnionIdIsBind: '',
44 }, 49 },
45 50
46 /** 51 /**
@@ -48,7 +53,7 @@ Component({ @@ -48,7 +53,7 @@ Component({
48 */ 53 */
49 methods: { 54 methods: {
50 getUserInfo, 55 getUserInfo,
51 - getPhoneNumber,  
52 - checkUnionIdIsBind  
53 - }  
54 -}) 56 + getPhoneNumber,
  57 + checkUnionIdIsBind,
  58 + },
  59 +});
1 // page/subPackage/pages/zeroSell/components/help.js 1 // page/subPackage/pages/zeroSell/components/help.js
2 2
3 -import router from '../router/router' 3 +import router from '../router/router';
4 4
5 Component({ 5 Component({
6 /** 6 /**
7 * 组件的属性列表 7 * 组件的属性列表
8 */ 8 */
9 properties: { 9 properties: {
10 - 10 + url: {
  11 + type: String,
  12 + value: 'https://activity.yoho.cn/feature/2765.html',
  13 + },
  14 + text: {
  15 + type: String,
  16 + value: '查看活动说明',
  17 + },
  18 + title: {
  19 + type: String,
  20 + value: '活动说明',
  21 + obsever: function(title) {
  22 + this.setData({
  23 + title,
  24 + });
  25 + },
  26 + },
11 }, 27 },
12 28
13 /** 29 /**
14 * 组件的初始数据 30 * 组件的初始数据
15 */ 31 */
16 data: { 32 data: {
17 - url: 'https://activity.yoho.cn/feature/2765.html',  
18 - title: '活动说明' 33 + title: '活动说明',
19 }, 34 },
20 35
21 /** 36 /**
@@ -24,9 +39,9 @@ Component({ @@ -24,9 +39,9 @@ Component({
24 methods: { 39 methods: {
25 _onTap() { 40 _onTap() {
26 router.go('webview', { 41 router.go('webview', {
27 - url: this.data.url,  
28 - title: this.data.title  
29 - })  
30 - }  
31 - }  
32 -}) 42 + url: this.properties.url,
  43 + title: this.data.title,
  44 + });
  45 + },
  46 + },
  47 +});
1 -  
2 -  
3 -<view class="help" bindtap="_onTap">  
4 -<image class="helpe-img" src="../images/que_ic@2x.png"></image>  
5 -<text>查看活动说明 </text> 1 +<view class="help" bindtap="_onTap">
  2 + <image class="helpe-img" src="../images/que_ic@2x.png"></image>
  3 + <text>{{text}}</text>
6 </view> 4 </view>
  1 +// page/subPackage/pages/zeroSell/components/action-bar.js
  2 +
  3 +import ZeroSellService from '../../service/zero-sell';
  4 +import CommonService from '../../service/common';
  5 +import { fomartCountdownTime } from '../../../../utils/util';
  6 +
  7 +const event = global.event;
  8 +
  9 +var app = getApp();
  10 +
  11 +Component({
  12 + /**
  13 + * 组件的属性列表
  14 + */
  15 + properties: {
  16 + // UNKNOWN: 0,
  17 + // READY: 1, // 未开始
  18 + // START: 2, // 参加
  19 + // ALEADY: 3, // 已参加活动
  20 + // WAIT: 4, // 等待抽奖中
  21 + // LUCK: 5, // 抽奖结束
  22 + // END: 6, // 活动结束
  23 + // PEOPLE_LIMIT_WAIT: 7 // 人数达到活动限制、已满员、人数不足统一为待开奖状态
  24 + status: {
  25 + type: Number,
  26 + value: 1,
  27 + },
  28 + num: {
  29 + type: Number,
  30 + value: 0,
  31 + },
  32 + shareUid: {
  33 + type: Number,
  34 + value: 0,
  35 + },
  36 + actId: {
  37 + type: Number,
  38 + value: 0,
  39 + },
  40 + copyText: {
  41 + type: String,
  42 + value: '',
  43 + },
  44 + text: {
  45 + type: String,
  46 + value: '',
  47 + },
  48 + type: {
  49 + type: Number,
  50 + value: 0,
  51 + },
  52 + // time in seconds
  53 + formatTimeList: {
  54 + type: Array,
  55 + value: [],
  56 + observer(value) {
  57 + this.setData({
  58 + remainingTime: value.join(':'),
  59 + });
  60 + },
  61 + },
  62 + isLogin: {
  63 + type: Boolean,
  64 + value: false,
  65 + },
  66 + activityStatus: {
  67 + type: Number,
  68 + status: 1,
  69 + },
  70 + },
  71 +
  72 + /**
  73 + * 组件的初始数据
  74 + */
  75 + data: {
  76 + show: false,
  77 + code: '',
  78 + error: false,
  79 + fellow: false,
  80 + remainingTime: '',
  81 + },
  82 +
  83 + ready() {
  84 + this.service = new ZeroSellService();
  85 + this.commonService = new CommonService();
  86 + },
  87 +
  88 + /**
  89 + * 组件的方法列表
  90 + */
  91 + methods: {
  92 + fetchCode() {
  93 + wx.showLoading({
  94 + mask: true,
  95 + });
  96 + event.emit('user-is-login', {
  97 + logged: this.getCode.bind(this),
  98 + loginSuccess: function() {},
  99 + });
  100 + },
  101 +
  102 + getCode(userInfo) {
  103 + this.service
  104 + .fetchCode({
  105 + shareUid: this.properties.shareUid,
  106 + uid: app.getUid(),
  107 + actPrizeId: this.properties.actId,
  108 + userThumb: userInfo.avatarUrl,
  109 + userName: userInfo.nickName,
  110 + })
  111 + .then(result => {
  112 + wx.hideLoading();
  113 + if (result.code === 200) {
  114 + this.setData({
  115 + show: true,
  116 + code: result.data.prizeCode,
  117 + });
  118 + this.triggerEvent('gaincodesuccess', this.properties.actId);
  119 + } else {
  120 + this.setData({
  121 + error: true,
  122 + errorText: result.message,
  123 + });
  124 + }
  125 + });
  126 + },
  127 + goShare() {
  128 + this.triggerEvent('share');
  129 + this.setData({
  130 + show: false,
  131 + error: false,
  132 + fellow: false,
  133 + });
  134 + },
  135 +
  136 + hadJoinToShare() {
  137 + this.goShare();
  138 + this.triggerEvent('changeStatus');
  139 + },
  140 +
  141 + goMyList() {
  142 + wx.reLaunch({
  143 + url: '/pages/zeroSell/index?tabIndex=3&reload=0',
  144 + });
  145 + },
  146 +
  147 + goList() {
  148 + wx.navigateTo({
  149 + url: '/pages/zeroSell/index?reload=0',
  150 + });
  151 + },
  152 +
  153 + cancelFellow() {
  154 + this.setData({
  155 + fellow: false,
  156 + });
  157 + },
  158 +
  159 + cancelAlert() {
  160 + this.setData({
  161 + show: false,
  162 + error: false,
  163 + });
  164 +
  165 + this.triggerEvent('changeStatus');
  166 + },
  167 +
  168 + openFellowAlert() {
  169 + this.setData({
  170 + fellow: true,
  171 + });
  172 + },
  173 +
  174 + hiddenAlert(e) {
  175 + this.setData({
  176 + show: false,
  177 + error: false,
  178 + fellow: false,
  179 + });
  180 + this.triggerEvent('changeStatus');
  181 + },
  182 +
  183 + submitFormId(e) {
  184 + return this.commonService.addWechatFormId({
  185 + formId: e.detail.formId,
  186 + uid: app.getUid() || 0,
  187 + openId: app.getOpenID() || '',
  188 + miniapp_type: app.getMiniappType(),
  189 + });
  190 + },
  191 +
  192 + goLogin() {
  193 + const event = global.event;
  194 + event.emit('user-is-login', {
  195 + logged: this.logged,
  196 + loginSuccess: this.loginSuccess,
  197 + });
  198 + },
  199 +
  200 + logged() {},
  201 +
  202 + loginSuccess() {},
  203 + },
  204 +});
  1 +{
  2 + "component": true,
  3 + "usingComponents": {
  4 + "zero-alert": "../alert",
  5 + "new-lucky-alert": "../new-lucky-alert",
  6 + "fellow-alert": "../fellow-alert"
  7 + }
  8 +}
  1 +<!-- page/subPackage/pages/zeroSell/components/action-bar.wxml -->
  2 +<view class="action-bar" wx:if="{{isLogin}}">
  3 + <block wx:if="{{status === 1}}">
  4 + <view class="action-item over">
  5 + <text>距开始</text>
  6 + <text class="remaining-time">{{remainingTime}}</text>
  7 + </view>
  8 + </block>
  9 + <block wx:elif="{{status === 2}}">
  10 + <form bindsubmit='submitFormId' report-submit='true' class="action-item">
  11 + <button class="action-item confirm" style="border-radius: unset;" form-type="submit" bindtap="fetchCode">
  12 + 参加抽奖
  13 + </button>
  14 + </form>
  15 + </block>
  16 + <block wx:elif="{{status === 3}}">
  17 + <button class="action-item ok" bindtap="goShare" open-type="share">邀请好友参加,增加中奖率</button>
  18 + </block>
  19 + <block wx:elif="{{status >= 3}}">
  20 + <view class="action-item over">已结束</view>
  21 + </block>
  22 +</view>
  23 +<view class="action-bar2" wx:else>
  24 + <block wx:if="{{activityStatus === 1}}">
  25 + <button class="action-item over" bindtap="goLogin">
  26 + <text>距开始</text>
  27 + <text class="remaining-time">{{remainingTime}}</text>
  28 + </button>
  29 + </block>
  30 + <block wx:if="{{activityStatus === 2}}">
  31 + <button class="action-item confirm" bindtap="goLogin">参加抽奖</button>
  32 + </block>
  33 + <block wx:elif="{{activityStatus >= 3}}">
  34 + <button class="action-item over" bindtap="goLogin">已结束</button>
  35 + </block>
  36 +</view>
  37 +<new-lucky-alert wx:if="{{show}}" bindhiddenalert="hiddenAlert">
  38 + <view class="code-alert">
  39 + <text class="code-title">参加抽奖成功</text>
  40 + <view class="code-bg">
  41 + <view class="title">你的抽奖码是</view>
  42 + <view class="code">{{code}}</view>
  43 + </view>
  44 + <form bindsubmit='submitFormId' report-submit='true'>
  45 + <button open-type="share" class="share" form-type="submit" bindtap="hadJoinToShare">
  46 + 分享一下,中奖概率立马double
  47 + </button>
  48 + </form>
  49 + <view class="share-desc">1个好友参加=1个抽奖码=中奖几率UP!</view>
  50 + </view>
  51 +</new-lucky-alert>
  52 +<zero-alert wx:if="{{error}}">
  53 + <view class="error-alert">
  54 + <view class="error-title">OOPS</view>
  55 + <view class="error-content">{{errorText}}</view>
  56 + </view>
  57 + <view class="foot">
  58 + <view class="foot-item" bindtap="cancelAlert">确定</view>
  59 + </view>
  60 +</zero-alert>
  61 +<fellow-alert show="{{fellow}}" bindok="cancelFellow" copyText="{{copyText}}" type="{{type}}" text="{{text}}"></fellow-alert>
  1 +@import '../action-bar.wxss';
  2 +
  3 +/* page/subPackage/pages/zeroSell/components/action-bar.wxss */
  4 +
  5 +
  6 +.action-bar {
  7 + display: flex;
  8 + width: 100%;
  9 + height: 100rpx;
  10 +}
  11 +
  12 +.action-item {
  13 + flex: 1;
  14 + color: white;
  15 + text-align: center;
  16 + font-size: 32rpx;
  17 + height: 100rpx;
  18 + line-height: 100rpx;
  19 + background-color: white;
  20 + border-radius: unset
  21 +}
  22 +
  23 +.action-list {
  24 + flex: 0;
  25 + position: relative;
  26 + flex-basis: 150rpx;
  27 +}
  28 +
  29 +.action-image {
  30 + width: 46rpx;
  31 + height: 42rpx;
  32 + position: absolute;
  33 + top: 50%;
  34 + left: 50%;
  35 + /* transform: translateY(-50%); */
  36 + transform: translate(-50%, -50%);
  37 +
  38 +}
  39 +
  40 +.over {
  41 + background-color: #B0B0B0;
  42 +}
  43 +
  44 +.code-alert {
  45 + text-align: center;
  46 + color: black;
  47 + margin-top: -400rpx;
  48 + display: flex;
  49 + flex-direction: column;
  50 + align-items: center;
  51 +}
  52 +
  53 +.code-title {
  54 + margin-top: -10rpx;
  55 +}
  56 +
  57 +.code-bg {
  58 + margin-top: 80rpx;
  59 + display: flex;
  60 + flex-direction: row;
  61 + align-items: center;
  62 + justify-content: center;
  63 +}
  64 +
  65 +.title {
  66 + font-size: 28rpx;
  67 + color: #444444;
  68 +}
  69 +
  70 +.code {
  71 + min-width: 192rpx;
  72 + height: 50rpx;
  73 + font-size: 28rpx;
  74 + font-weight: bolder;
  75 + line-height: 50rpx;
  76 + text-align: center;
  77 + border: 1rpx solid black;
  78 + margin-left: 20rpx;
  79 +}
  80 +
  81 +.share {
  82 + font-size: 28rpx;
  83 + color: #FFFFFF;
  84 + background: #64ad88;
  85 + border-radius: 28px;
  86 + width: 460rpx;
  87 + height: 80rpx;
  88 + line-height: 80rpx;
  89 + margin-top: 50rpx;
  90 + vertical-align: center;
  91 +}
  92 +
  93 +.share-desc {
  94 + font-size: 20rpx;
  95 + color: #B0B0B0;
  96 + font-family: PingFangSC-Medium;
  97 + margin-top: 10rpx;
  98 +}
  99 +
  100 +.foot {
  101 + display: flex;
  102 + position: absolute;
  103 + box-sizing: border-box;
  104 + bottom: 0;
  105 + width: 100%;
  106 + height: 90rpx;
  107 + line-height: 90rpx;
  108 + font-size: 28rpx;
  109 + font-weight: bolder;
  110 + text-align: center;
  111 + border-top: 1rpx solid #E0E0E0;
  112 +}
  113 +
  114 +.foot-item {
  115 + flex: 1;
  116 + text-align: center;
  117 + font-size: 32rpx;
  118 + height: 90rpx;
  119 + line-height: 90rpx;
  120 + color: black;
  121 + border: none !important;
  122 + border-radius: unset;
  123 +}
  124 +
  125 +.foot-item + .foot-item {
  126 + border-left: 1rpx solid #E0E0E0 !important;
  127 +}
  128 +
  129 +.info {
  130 + color: #D0021B !important;
  131 +}
  132 +
  133 +.error-alert {
  134 + text-align: center;
  135 + color: black;
  136 + margin-top: 40rpx;
  137 +}
  138 +
  139 +.error-title {
  140 + font-size: 40rpx;
  141 + color: #D0021B ;
  142 + margin-bottom: 30rpx;
  143 +}
  144 +
  145 +.error-content {
  146 + font-size: 30rpx;
  147 + padding: 0 100rpx;
  148 +}
  149 +
  150 +
  151 +.ok,
  152 +.confirm {
  153 + background-color: #132f48;
  154 +}
  155 +.remaining-time {
  156 + margin-left: 20rpx;
  157 + width: 140rpx;
  158 + display: inline-block;
  159 +}
  1 +// page/subPackage/pages/zeroSell/components/product-detail-header.js
  2 +
  3 +import { formatTimeByDefined } from '../../../../utils/util';
  4 +Component({
  5 + properties: {
  6 + product: {
  7 + type: Object,
  8 + observer(product) {
  9 + const { end_time: endTime, start_time: startTime, status } = product;
  10 + let nextActivityTime = '';
  11 + if (status === 1 || status >=3 ) {
  12 + nextActivityTime = `${formatTimeByDefined(
  13 + startTime,
  14 + 'Y.M.D h:m',
  15 + )}-${formatTimeByDefined(endTime, 'h:m')}`;
  16 + }
  17 + this.setData({
  18 + nextActivityTime,
  19 + });
  20 + },
  21 + },
  22 + avatars: {
  23 + type: Array,
  24 + },
  25 + shareFlag: {
  26 + type: Boolean,
  27 + value: false,
  28 + observer(value) {
  29 + this.setData({ show: value });
  30 + },
  31 + },
  32 + formatTimeList: {
  33 + type: Array,
  34 + value: [],
  35 + },
  36 + },
  37 + data: {
  38 + show: false,
  39 + isEnd: false,
  40 + nextActivityTime: '',
  41 + },
  42 + ready() {},
  43 + methods: {},
  44 +});
  1 +{
  2 + "component": true,
  3 + "usingComponents": {
  4 + "avatars": "../avatar-swiper"
  5 + }
  6 +}
  1 +<wxs src="../helper.wxs" module="helper" />
  2 +<view class="product_countdown" wx:if="{{product.status === 2 && formatTimeList.length > 0}}" hidden="{{ show }}">
  3 + <view class="countdown_label">
  4 + <text class="countdown_labeltext">抽奖</text>
  5 + <text class="countdown_labeltext">倒计时</text>
  6 + </view>
  7 + <view wx:for="{{formatTimeList}}" wx:key="">
  8 + <view class="num-wrapper">
  9 + <view class="mask"></view>
  10 + <text class="num-text">{{item}}</text>
  11 + <view class="mask-left"></view>
  12 + <view class="mask-right"></view>
  13 + </view>
  14 + <view class="number-seprator" wx:if="{{index !== 2}}">:</view>
  15 + </view>
  16 +</view>
  17 +<view class="next-preview" wx:if="{{product.status === 1 || product.status >= 3}}" hidden="{{ show }}">
  18 + <text class="next-tip">{{product.status === 1 ? '下一场活动时间' : '活动时间'}}</text>
  19 + <text class="next-time">{{nextActivityTime}}</text>
  20 +</view>
  21 +<view class="avatarcontainer">
  22 + <view class="avatars" wx:if="{{avatars.length > 0 && !show}}">
  23 + <avatars list="{{avatars}}"></avatars>
  24 + </view>
  25 + <image class="product_image" src="{{product.cover_img}}"></image>
  26 +</view>
  27 +<view class="product_name">{{product.name}}</view>
  28 +<view class="product_lucky_bg">
  29 + <view class="product_lucky">
  30 + <text>原价购</text>
  31 + <text class="price-info">{{product.lottery_price}}</text>
  32 + </view>
  33 + <view class="product_price">
  34 + <text>市场参考价</text>
  35 + <text class="price-info line">{{product.price}}</text>
  36 + </view>
  37 +</view>
  1 +.product_image {
  2 + width: 690rpx;
  3 + height: 434rpx;
  4 +}
  5 +
  6 +.product_name {
  7 + display: inline-block;
  8 + margin-top: 10rpx;
  9 + letter-spacing: -0.34px;
  10 + width: 686rpx;
  11 + font-size: 30rpx;
  12 + font-weight: bold;
  13 + word-break: break-all;
  14 + color: #222222;
  15 +}
  16 +
  17 +.product_lucky_bg {
  18 + display: flex;
  19 + flex-direction: row;
  20 + align-items: center;
  21 + justify-content: space-evenly;
  22 + margin: 30rpx 20rpx 56rpx 20rpx;
  23 + font-size: 22rpx;
  24 +}
  25 +
  26 +.product_price,
  27 +.product_lucky {
  28 + display: flex;
  29 + flex-direction: column;
  30 + justify-content: center;
  31 +}
  32 +
  33 +.product_price {
  34 + color: #999999;
  35 +}
  36 +
  37 +.price-info {
  38 + font-weight: bold;
  39 + font-size: 36rpx;
  40 +}
  41 +
  42 +.line {
  43 + text-decoration: line-through;
  44 +}
  45 +
  46 +.product_margin {
  47 + margin-bottom: 40rpx;
  48 +}
  49 +
  50 +.product_countdown {
  51 + display: flex;
  52 + height: 92rpx;
  53 + margin-top: 44rpx;
  54 + margin-bottom: 36rpx;
  55 + justify-content: center;
  56 + align-items: center;
  57 +}
  58 +
  59 +.countdown_label {
  60 + width: 60rpx;
  61 + font-family: PingFang-SC-Regular;
  62 + font-size: 20rpx;
  63 + color: #222222;
  64 + letter-spacing: -0.36rpx;
  65 + text-align: center;
  66 + display: inline-block;
  67 + margin-right: 16rpx;
  68 + position: relative;
  69 +}
  70 +
  71 +.countdown_labeltext {
  72 + display: block;
  73 +}
  74 +
  75 +.avatars {
  76 + display: inline-block;
  77 + text-align: center;
  78 + margin-left: auto;
  79 + margin-right: auto;
  80 + left: calc(50% - 180rpx);
  81 + top: 36rpx;
  82 + position: absolute;
  83 +}
  84 +
  85 +.avatarcontainer {
  86 + position: relative;
  87 +}
  88 +
  89 +.num-wrapper {
  90 + display: inline-block;
  91 + position: relative;
  92 + width: 72rpx;
  93 + height: 84rpx;
  94 + font-size: 50rpx;
  95 + line-height: 84rpx;
  96 + background: #444;
  97 + color: white;
  98 + font-weight: bolder;
  99 +}
  100 +
  101 +.num-wrapper + .num-wrapper {
  102 + margin-left: 10rpx;
  103 +}
  104 +
  105 +.mask {
  106 + position: absolute;
  107 + width: 100%;
  108 + height: 50%;
  109 + top: 0;
  110 + left: 0;
  111 + opacity: 0.4;
  112 + background-color: black;
  113 + z-index: 0;
  114 +}
  115 +
  116 +.num-text {
  117 + z-index: 99;
  118 +}
  119 +.mask-left {
  120 + position: absolute;
  121 + width: 3.5rpx;
  122 + height: 8rpx;
  123 + top: calc(50% - 4rpx);
  124 + left: 0;
  125 + background-color: white;
  126 +}
  127 +
  128 +.mask-right {
  129 + position: absolute;
  130 + width: 3.5rpx;
  131 + height: 8rpx;
  132 + top: calc(50% - 4rpx);
  133 + right: 0;
  134 + background-color: white;
  135 +}
  136 +
  137 +.number-seprator {
  138 + font-size: 60rpx;
  139 + line-height: 84rpx;
  140 + height: 84rpx;
  141 + margin-left: 10rpx;
  142 + margin-right: 10rpx;
  143 + box-sizing: border-box;
  144 + color: black;
  145 + display: inline-block;
  146 +}
  147 +
  148 +.next-preview {
  149 + display: flex;
  150 + flex-direction: column;
  151 + align-items: center;
  152 + margin-bottom: 20rpx;
  153 + margin-top: 28rpx;
  154 +}
  155 +.next-tip {
  156 + background-color: #132f48;
  157 + color: white;
  158 + border-radius: 20rpx;
  159 + height: 30rpx;
  160 + padding: 5rpx 20rpx;
  161 + font-size: 24rpx;
  162 + margin-bottom: 20rpx;
  163 + display: flex;
  164 + align-items: center;
  165 +}
  166 +.next-time {
  167 + font-size: 36rpx;
  168 +}
  1 +import ZeroSellService from './service/zero-sell';
  2 +import CommonService from './service/common';
  3 +import {
  4 + decodePhoneNumber,
  5 + getUnionID,
  6 + decodeUnionId,
  7 + openAuthorizeSettings,
  8 +} from '../../utils/login';
  9 +import { getQRCodeSource } from '../../libs/miniQRCodeRoute';
  10 +import { Toast } from '../../vendors/zanui/index';
  11 +import router from './router/router';
  12 +import { formatImageUrl, fomartCountdownTime } from '../../utils/util';
  13 +import { jumpByUrl } from '../../libs/urlRoute';
  14 +import { yasReport, YB_PAGE_OPEN_L, YB_LUCK_DT_JOIN_C } from '../../libs/yas';
  15 +
  16 +const ACTIVITY = {
  17 + UNKNOWN: 0,
  18 + READY: 1, // 活动未开始
  19 + START: 2, // 活动开始
  20 + END: 3, // 活动结束
  21 + LUCK: 4, // 活动已开奖、抽奖结束
  22 + END_LESS_PEOPLE: 5, // 人数不足
  23 +};
  24 +
  25 +const ACTION_BAR_STATUS = {
  26 + UNKNOWN: 0,
  27 + READY: 1, // 未开始
  28 + START: 2, // 参加
  29 + ALEADY: 3, // 已参加活动
  30 + WAIT: 4, // 等待抽奖中
  31 + LUCK: 5, // 抽奖结束
  32 + END: 6, // 活动结束
  33 + PEOPLE_LIMIT_WAIT: 7, // 人数达到活动限制、已满员、人数不足统一为待开奖状态
  34 +};
  35 +
  36 +let app = getApp();
  37 +let timeoutId = null; // 定时器ID
  38 +
  39 +/**
  40 + * YOHOOD 原价购 抽奖
  41 + */
  42 +
  43 +Page(
  44 + Object.assign(
  45 + {
  46 + /**
  47 + * 页面的初始数据
  48 + */
  49 + data: {
  50 + isGoApp: false,
  51 + tabIdx: '',
  52 + showAuth: false,
  53 + actPrizeId: '',
  54 + shareUid: 0,
  55 + scene: '',
  56 + appParameter: '',
  57 + myPrizeCount: 0,
  58 + product: {},
  59 + avatars: [],
  60 + recommends: [],
  61 + actionStatus: ACTION_BAR_STATUS.UNKNOWN,
  62 + snapData: {},
  63 + hasUnionID: false,
  64 + uid: 0,
  65 + isLogin: false,
  66 + bannerSrc: null,
  67 + bannerUrl: null,
  68 + loading: false,
  69 + page: 1,
  70 + codeList: [],
  71 + animation: null,
  72 + shareFlag: false,
  73 + notice: {},
  74 + lottery: {},
  75 + formatTimeList: [],
  76 + isCountdownEnd: false,
  77 + activityId: ''
  78 + },
  79 +
  80 + /**
  81 + * 生命周期函数--监听页面加载
  82 + */
  83 + onLoad: function(options) {
  84 + app = getApp();
  85 + wx.hideShareMenu();
  86 +
  87 + this.service = new ZeroSellService();
  88 + this.commonService = new CommonService();
  89 +
  90 + let data = {};
  91 +
  92 + let currentScene = app.globalData.currentScene;
  93 + let isGoApp =
  94 + currentScene == 1036 || currentScene == 1069 ? true : false;
  95 + data.isGoApp = isGoApp;
  96 +
  97 + if (options.shareUid) {
  98 + data.shareUid = options.shareUid;
  99 + }
  100 +
  101 + if (options.tabIdx) {
  102 + data.tabIdx = options.tabIdx;
  103 + }
  104 +
  105 + if (options.actPrizeId) {
  106 + data.actPrizeId = options.actPrizeId;
  107 + }
  108 +
  109 + let appParameter = `https://m.yohobuy.com?openby:yohobuy={"action":"go.h5","params":{"param":{},"url":"https://m.yohobuy.com/activity/yoluck/${
  110 + data.actPrizeId
  111 + }.html"}}`;
  112 + data.appParameter = appParameter;
  113 +
  114 + if (options.scene && options.scene.length === 32) {
  115 + data.scene = options.scene;
  116 + }
  117 +
  118 + this.setData(data);
  119 +
  120 + new app.WeToast();
  121 +
  122 + this._getDetailBanner();
  123 + yasReport(YB_PAGE_OPEN_L);
  124 + },
  125 +
  126 + /**
  127 + * 生命周期函数--监听页面初次渲染完成
  128 + */
  129 + onReady: function() {},
  130 +
  131 + /**
  132 + * 生命周期函数--监听页面显示
  133 + */
  134 + onShow: function() {
  135 + wx.showLoading({
  136 + mask: true,
  137 + });
  138 + setTimeout(() => {
  139 + app = app || getApp();
  140 + let uid = app.getUid();
  141 + this.setData({
  142 + hasUnionID:
  143 + app.globalData.WXUnion_ID !== null &&
  144 + app.globalData.WXUnion_ID !== '' &&
  145 + app.globalData.WXUnion_ID !== undefined
  146 + ? true
  147 + : false,
  148 + isLogin: app.isLogin(),
  149 + uid,
  150 + });
  151 + this._getUser();
  152 + // this._getGroupList();
  153 +
  154 + if (this.data.shareUid && this.data.scene) {
  155 + this._init();
  156 + } else if (this.data.scene && !this.data.shareUid) {
  157 + this._fetchParams(this.data.scene).then(() => {
  158 + return this._init();
  159 + });
  160 + } else {
  161 + this._init();
  162 + }
  163 + }, 1100);
  164 + },
  165 +
  166 + /**
  167 + * 生命周期函数--监听页面隐藏
  168 + */
  169 + onHide: function() {
  170 + wx.hideLoading();
  171 + },
  172 +
  173 + /**
  174 + * 生命周期函数--监听页面卸载
  175 + */
  176 + onUnload: function() {},
  177 +
  178 + /**
  179 + * 页面相关事件处理函数--监听用户下拉动作
  180 + */
  181 + onPullDownRefresh: function() {
  182 + wx.showLoading({
  183 + mask: true,
  184 + });
  185 + const {product = {}} = this.data;
  186 + if(product.status === ACTIVITY.END || product.status === ACTIVITY.LUCK) {
  187 + wx.navigateTo({url: '/pages/zeroSell/originalPriceSell'})
  188 + }else {
  189 + this._init({isPulldown: true}).then(() => {
  190 + wx.stopPullDownRefresh();
  191 + });
  192 + }
  193 + },
  194 +
  195 + /**
  196 + * 页面上拉触底事件的处理函数
  197 + */
  198 + onReachBottom: function() {
  199 + if (this.data.loading) return;
  200 + let page = this.data.page || 1;
  201 + page = page + 1;
  202 + this.setData({
  203 + page,
  204 + loading: true,
  205 + });
  206 + // this._loadGroupList(page);
  207 + },
  208 +
  209 + _getMineCode(actPrizeId) {
  210 + if (this.data.uid) {
  211 + this.service
  212 + .fetchMyPrizeList({
  213 + uid: this.data.uid,
  214 + actPrizeId,
  215 + })
  216 + .then(res => {
  217 + let len = res.data.length;
  218 + if (len) {
  219 + res.data.map(value => {
  220 + value.user_thumb = formatImageUrl(value.user_thumb, 60, 60);
  221 + });
  222 + this.setData({
  223 + codeList: res.data,
  224 + });
  225 + wx.getSystemInfo({
  226 + success: sys => {
  227 + let animation = wx.createAnimation({
  228 + duration: 400 * len,
  229 + });
  230 + setTimeout(
  231 + function() {
  232 + wx.createSelectorQuery()
  233 + .select('.code-list-item-container')
  234 + .boundingClientRect()
  235 + .exec(r => {
  236 + if (r && r[0] && r[0].height) {
  237 + animation
  238 + .height(
  239 + r[0].height - (65 * sys.screenWidth) / 375,
  240 + )
  241 + .step();
  242 + this.setData({
  243 + animation: animation.export(),
  244 + });
  245 + }
  246 + });
  247 + }.bind(this),
  248 + 800,
  249 + );
  250 + },
  251 + });
  252 + }
  253 + });
  254 + }
  255 + },
  256 + _getGroupList() {
  257 + this.commonService
  258 + .getGroupList({
  259 + limit: 20,
  260 + page: 1,
  261 + })
  262 + .then(res => {
  263 + if (res.code === 200 && res.data) {
  264 + this.setData({
  265 + groupList: res.data.list,
  266 + });
  267 + }
  268 + });
  269 + },
  270 +
  271 + _loadGroupList(page) {
  272 + this.commonService
  273 + .getGroupList({
  274 + limit: 20,
  275 + page,
  276 + })
  277 + .then(res => {
  278 + if (res.code === 200 && res.data) {
  279 + let groupList = this.data.groupList || [];
  280 + if (res.data.list.length > 0) {
  281 + this.setData({
  282 + groupList: groupList.concat(res.data.list),
  283 + loading: false,
  284 + });
  285 + } else {
  286 + this.setData({
  287 + loading: false,
  288 + });
  289 + }
  290 + }
  291 + })
  292 + .catch(error => {
  293 + this.setData({
  294 + loading: false,
  295 + });
  296 + });
  297 + },
  298 +
  299 + _init(options = {}) {
  300 + const { isPulldown, id } = options
  301 + let params = {
  302 + actPrizeId: isPulldown ? '' : this.data.actPrizeId || id,
  303 + };
  304 +
  305 + return this.service
  306 + .getYohoodDetail(params)
  307 + .then(r1 => {
  308 + wx.hideLoading();
  309 + if (r1.code === 200 && r1.data) {
  310 + let product = r1.data;
  311 +
  312 + this._getMineCode(product.id);
  313 + this._formatCountdownTime(product);
  314 +
  315 + this.setData({
  316 + product: product,
  317 + activityId: product.id,
  318 + myPrizeCount: r1.code === 200 ? r1.data.myCodeNum : 0,
  319 + notice: JSON.parse(product.notice || '{}'),
  320 + lottery: JSON.parse(product.lottery_info || '{}'),
  321 + });
  322 +
  323 + this._setActionStatus();
  324 + } else {
  325 + return Promise.reject();
  326 + }
  327 + })
  328 + .catch(e => {
  329 + wx.hideLoading();
  330 + console.error(e);
  331 + });
  332 + },
  333 +
  334 + _formatCountdownTime(product) {
  335 + let { remaining, id} = product;
  336 + // 初始化倒计时时间
  337 + const formatTimeList = fomartCountdownTime(remaining);
  338 + this.setData({
  339 + formatTimeList,
  340 + });
  341 + // 清除定时器
  342 + clearInterval(timeoutId)
  343 + if(!remaining) {
  344 + return
  345 + }
  346 + timeoutId = setInterval(() => {
  347 + remaining--;
  348 + const formatTimeList = fomartCountdownTime(remaining);
  349 + const isCountdownEnd = formatTimeList.join('') === '000000';
  350 + if (isCountdownEnd) {
  351 + // 延时500毫秒调接口
  352 + const timeId = setTimeout(()=> {
  353 + this.changeActionStatus({id});
  354 + clearTimeout(timeId)
  355 + },500)
  356 + clearInterval(timeoutId);
  357 + }
  358 + this.setData({
  359 + formatTimeList
  360 + });
  361 + }, 1000);
  362 + },
  363 +
  364 + _fetchParams(code) {
  365 + return getQRCodeSource(code).then(result => {
  366 + this.setData({
  367 + shareUid: +result.shareUid,
  368 + actPrizeId: result.actPrizeId,
  369 + });
  370 + });
  371 + },
  372 + _setActionStatus() {
  373 + let status = ACTION_BAR_STATUS.START;
  374 + let activityStatus = this.data.product.status;
  375 +
  376 + if (activityStatus === ACTIVITY.UNKNOWN) {
  377 + status = ACTION_BAR_STATUS.END;
  378 + } else if (activityStatus === ACTIVITY.READY) {
  379 + status = ACTION_BAR_STATUS.READY;
  380 + } else if (activityStatus >= ACTIVITY.END) {
  381 + if (this._isInActivity()) {
  382 + if (activityStatus === ACTIVITY.LUCK) {
  383 + status = ACTION_BAR_STATUS.LUCK;
  384 + } else if (
  385 + activityStatus === ACTIVITY.END_LESS_PEOPLE ||
  386 + activityStatus === ACTIVITY.END
  387 + ) {
  388 + status = ACTION_BAR_STATUS.WAIT;
  389 + } else {
  390 + status = ACTION_BAR_STATUS.WAIT;
  391 + }
  392 + } else {
  393 + if (
  394 + activityStatus === ACTIVITY.END_LESS_PEOPLE ||
  395 + activityStatus === ACTIVITY.END
  396 + ) {
  397 + status = ACTION_BAR_STATUS.PEOPLE_LIMIT_WAIT;
  398 + } else {
  399 + status = ACTION_BAR_STATUS.END;
  400 + }
  401 + }
  402 + } else {
  403 + if (this._isInActivity()) {
  404 + status = ACTION_BAR_STATUS.ALEADY;
  405 + } else {
  406 + status = ACTION_BAR_STATUS.START;
  407 + }
  408 + }
  409 +
  410 + this.setData({
  411 + actionStatus: status,
  412 + });
  413 + },
  414 +
  415 + _isInActivity() {
  416 + return this.data.myPrizeCount > 0;
  417 + },
  418 +
  419 + changeActionStatus(options = {}) {
  420 + wx.showLoading({
  421 + mask: true,
  422 + });
  423 + this._init(options);
  424 + },
  425 +
  426 + share(event) {
  427 + this.setData({
  428 + 'actionsheet.show': true,
  429 + });
  430 + },
  431 +
  432 + _jumpBanner() {
  433 + if (this.data.bannerUrl == null) {
  434 + return;
  435 + }
  436 + jumpByUrl(this.data.bannerUrl);
  437 + },
  438 + _getDetailBanner() {
  439 + let commonService = this.commonService;
  440 + commonService
  441 + .getResourceCode('ccc32dbedf164a52b4efa34383878860')
  442 + .then(data => {
  443 + this.setData({
  444 + bannerSrc: formatImageUrl(data.src, 750, 140, 2),
  445 + bannerUrl: data.url,
  446 + });
  447 + })
  448 + .catch(error => {});
  449 + },
  450 +
  451 + _getUser() {
  452 + const userInfo = app.getUserInfo();
  453 +
  454 + if (app.isLogin() && (!userInfo || !userInfo.nickName)) {
  455 + return this.service
  456 + .getUserProfile({ uid: app.getUid() })
  457 + .then(json => {
  458 + if (json && json.code && json.code === 200) {
  459 + userInfo.nickName = json.data.nickname || '';
  460 + userInfo.avatarUrl = json.data.head_ico || '';
  461 + app.setUserInfo(userInfo);
  462 + }
  463 + });
  464 + } else {
  465 + return Promise.resolve();
  466 + }
  467 + },
  468 +
  469 + handleZanActionsheetCancel({ componentId }) {
  470 + this.setData({
  471 + 'actionsheet.show': false,
  472 + });
  473 + },
  474 +
  475 + handleZanActionsheetClick({ componentId, index }) {
  476 + this.setData({
  477 + 'actionsheet.show': false,
  478 + });
  479 +
  480 + if (index === 1) {
  481 + router.go('snapShare', this.data.snapData);
  482 + }
  483 + },
  484 + onShareAppMessage(res) {
  485 + let params = {
  486 + TITLE: `有货UFOYOHOOD现场搞事情,点一下原价购买${
  487 + this.data.product.name
  488 + }`,
  489 + DESC: '我在YOHOOD发现一个不错的商品赶快来看看吧!',
  490 + };
  491 + this.setData({
  492 + shareFlag: true,
  493 + });
  494 + setTimeout(
  495 + function() {
  496 + this.setData({ shareFlag: false });
  497 + }.bind(this),
  498 + 600,
  499 + );
  500 + if (res.from === 'menu') {
  501 + // 用户点击右上角分享
  502 + return {
  503 + title: params.TITLE, // 分享标题
  504 + desc: params.DESC, // 分享描述
  505 + path: `/pages/zeroSell/originalPriceSell?actPrizeId=${
  506 + this.data.product.id
  507 + }`,
  508 + };
  509 + } else if (res.from === 'button') {
  510 + // 用户点击分享按钮
  511 + return {
  512 + title: params.TITLE, // 分享标题
  513 + desc: params.DESC, // 分享描述
  514 + path: `/pages/zeroSell/originalPriceSell?actPrizeId=${
  515 + this.data.product.id
  516 + }&shareUid=${app.getUid()}`,
  517 + };
  518 + }
  519 + },
  520 + reportSuccess({ detail }) {
  521 + yasReport(YB_LUCK_DT_JOIN_C, { ACTIVITY_ID: detail });
  522 + },
  523 +
  524 + getUserInfo: function(e) {
  525 + var that = this;
  526 + if (e.detail.errMsg === 'getUserInfo:ok') {
  527 + decodeUnionId(app.getWechatThirdSession(), e, function(response) {
  528 + if (response.isHaveUnionID) {
  529 + that.setData({
  530 + hasUnionID: true,
  531 + });
  532 + }
  533 + });
  534 + } else {
  535 + openAuthorizeSettings(function(response) {
  536 + if (response.isHaveUnionID) {
  537 + that.setData({
  538 + hasUnionID: true,
  539 + });
  540 + }
  541 + });
  542 + }
  543 + },
  544 +
  545 + getPhoneNumber: function(e) {
  546 + this.setData({
  547 + showAuth: false,
  548 + });
  549 +
  550 + var that = this;
  551 + if (e.detail.errMsg === 'getPhoneNumber:ok') {
  552 + decodePhoneNumber(e.detail.iv, e.detail.encryptedData, '', function(
  553 + result,
  554 + ) {
  555 + if (result.code != 200) {
  556 + that.wetoast.toast({
  557 + title: result.message,
  558 + titleClassName: 'wetoast-title',
  559 + duration: 1000,
  560 + success: function() {
  561 + that.loginAndRegisterTapped();
  562 + }.bind(that),
  563 + });
  564 + } else {
  565 + if (result.is_register) {
  566 + that.showZanToast(
  567 + {
  568 + title:
  569 + '欢迎加入Yoho!Family!新人礼包已发放到个人中心-优惠券,请注意查收',
  570 + success: function() {
  571 + let uid =
  572 + app.globalData.userInfo.uid > 0
  573 + ? app.globalData.userInfo.uid
  574 + : 0;
  575 + that.setData({
  576 + uid,
  577 + isLogin: app.isLogin(),
  578 + });
  579 + },
  580 + },
  581 + 1500,
  582 + );
  583 + } else {
  584 + let uid =
  585 + app.globalData.userInfo.uid > 0
  586 + ? app.globalData.userInfo.uid
  587 + : 0;
  588 + that.setData({
  589 + uid,
  590 + isLogin: app.isLogin(),
  591 + });
  592 + }
  593 + }
  594 + });
  595 + } else {
  596 + let needBind = true;
  597 + that.setData({
  598 + needBind,
  599 + });
  600 + // that.loginAndRegisterTapped(true);
  601 + wx.navigateTo({
  602 + url: '/pages/bindPhoneNumber/bindPhoneNumber',
  603 + });
  604 + }
  605 + },
  606 + launchAppError: function(e) {
  607 + wx.showToast({
  608 + title: '打开失败!您可能未安装Yoho!Buy官方APP,请下载后再尝试。',
  609 + icon: 'none',
  610 + duration: 3000,
  611 + });
  612 + },
  613 + //跳转到登录页面
  614 + loginAndRegisterTapped(needBind) {
  615 + let that = this;
  616 + let app = getApp();
  617 + if (wx.getSetting) {
  618 + wx.getSetting({
  619 + success: res => {
  620 + if (
  621 + res &&
  622 + res.authSetting &&
  623 + res.authSetting['scope.userInfo'] !== null &&
  624 + res.authSetting['scope.userInfo'] !== undefined &&
  625 + res.authSetting['scope.userInfo'] === false
  626 + ) {
  627 + wx.showModal({
  628 + title: '',
  629 + content: '检测到您未打开微信用户信息授权,开启后即可进行登录',
  630 + confirmText: '去开启',
  631 + confirmColor: '#000000',
  632 + success: function(res) {
  633 + if (res.confirm) {
  634 + wx.openSetting({
  635 + success: res => {
  636 + if (
  637 + res.authSetting['scope.userInfo'] !== null &&
  638 + res.authSetting['scope.userInfo'] !== undefined &&
  639 + res.authSetting['scope.userInfo'] === true
  640 + ) {
  641 + getUnionID(app.getWechatThirdSession(), function(
  642 + response,
  643 + ) {});
  644 + }
  645 + },
  646 + });
  647 + } else {
  648 + wx.navigateTo({
  649 + url: '/pages/bindPhoneNumber/bindPhoneNumber',
  650 + });
  651 + }
  652 + },
  653 + });
  654 + } else {
  655 + wx.navigateTo({
  656 + url: '/pages/bindPhoneNumber/bindPhoneNumber',
  657 + });
  658 + }
  659 + },
  660 + });
  661 + } else {
  662 + wx.showModal({
  663 + title: '提示',
  664 + content:
  665 + '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。',
  666 + });
  667 + }
  668 + },
  669 + },
  670 + Toast,
  671 + ),
  672 +);
  1 +{
  2 + "navigationBarTitleText": "YO!LUCK原价购",
  3 + "enablePullDownRefresh": true,
  4 + "usingComponents": {
  5 + "product-item": "./components/product-item",
  6 + "product-header": "./components/yohoodLottery/product-detail-header",
  7 + "prize-progress": "./components/prize-progress",
  8 + "more": "./components/more",
  9 + "avatars": "./components/avatar-swiper",
  10 + "help": "./components/help",
  11 + "fellow-bar": "./components/fellow-bar",
  12 + "action-bar": "./components/yohoodLottery/action-bar",
  13 + "zero-alert": "./components/alert",
  14 + "group-recommend": "./components/group-recommend"
  15 + }
  16 +}
  1 +<view class="header {{shareFlag || (notice.content || product.status >= 3 ? 'mt-header': '') }}">
  2 + <product-header product="{{product}}" shareFlag="{{shareFlag}}" format-timeList="{{formatTimeList}}" bindchangeStatus="changeActionStatus" avatars="{{avatars}}"></product-header>
  3 +</view>
  4 +<view class="lottery-info">
  5 + <view class="flow-tile-wrap">
  6 + <text>活动流程</text>
  7 + <help url="https://activity.yoho.cn/feature/5901.html" text="活动规则" title="原价购活动说明"></help>
  8 + </view>
  9 + <image mode="aspectFill" class="jion-tips-image" src="https://cdn.yoho.cn/o_1dhq2n6551qc5djrv5v1geekcq8.png"></image>
  10 +</view>
  11 +<view class="machine {{shareFlag ? 'machine-t-m' : 'machine-t-l'}}">
  12 + <view class="open-shadow"></view>
  13 + <view class="code-list" animation="{{animation}}">
  14 + <view class="code-list-item-container">
  15 + <view class="code-list-item">
  16 + <view class="content"></view>
  17 + </view>
  18 + <view class="code-list-item" wx:for="{{codeList}}" wx:key="{{index}}">
  19 + <view class="content">
  20 + <image class="thumb" mode="widthFix" src="{{item.user_thumb}}"></image>
  21 + <view class="text">
  22 + <view>我的</view>
  23 + <view>抽奖码</view>
  24 + </view>
  25 + <view class="my-code">{{item.prize_code}}</view>
  26 + </view>
  27 + <image class="shadow" src="https://img11.static.yhbimg.com/yhb-img01/2018/12/27/19/0140fa3243af949068d2aabeedb0ea0666.png" mode="widthFix" wx:if="{{index == 2 && codeList.length>3 }}"></image>
  28 + </view>
  29 + </view>
  30 + </view>
  31 +</view>
  32 +<view class="fellow-bar" wx:if="{{product.status && !shareFlag}}">
  33 + <block wx:if="{{product.status >= 3}}">
  34 + <view class="endTip">
  35 + <text>{{notice.content || '本场活动已结束(下拉刷新可查看新活动)'}}</text>
  36 + </view>
  37 + </block>
  38 + <block wx:elif="{{notice.content}}">
  39 + <fellow-bar notice="{{notice}}"></fellow-bar>
  40 + </block>
  41 +</view>
  42 +<view class="action-bar">
  43 + <action-bar activity-status="{{product.status}}" format-timeList="{{formatTimeList}}" is-login="{{isLogin}}" status="{{actionStatus}}" num="{{myPrizeCount}}" share-uid="{{shareUid}}" act-id="{{activityId}}" bindchangeStatus="changeActionStatus" bindshare="share" copyText="{{lottery.miniappCopy}}" text="{{lottery.miniappTip}}" bindgaincodesuccess="reportSuccess" type="{{lottery.miniappType}}"></action-bar>
  44 +</view>
  45 +<view class="foot"></view>
  46 +<import src="../../vendors/zanui/toast/index.wxml" />
  47 +<template is="zan-toast" data="{{zanToast}}" />
  48 +<import src="../../vendors/toast/wetoast.wxml" />
  49 +<template is="wetoast" data="{{...__wetoast__}}" />
  50 +<zero-alert wx:if="{{showAuth}}">
  51 + <view class="auth-content">OOPS 用户尚未授权登录</view>
  52 + <button class="auth-foot action-item confirm" open-type="{{!hasUnionID ? 'getUserInfo':'getPhoneNumber'}}" bindgetphonenumber="getPhoneNumber" bindgetuserinfo='getUserInfo'>
  53 + 授权登录
  54 + </button>
  55 +</zero-alert>
  56 +<button wx:if="{{isGoApp}}" class="appBtn" bindtap='goApp' type="default" hover-class="none" open-type="launchApp" app-parameter="{{appParameter}}" binderror="launchAppError">
  57 + <image class="appImg" src="./images/back2App@3x.png"></image>
  58 +</button>
  1 +/* page/subPackage/pages/zeroSell/detail.wxss */
  2 +
  3 +@import '../../vendors/zanui/actionsheet/index.wxss';
  4 +
  5 +.line {
  6 + height: 20rpx;
  7 + background-color: #f0f0f0;
  8 +}
  9 +
  10 +.product-item {
  11 + margin-bottom: 80rpx;
  12 +}
  13 +
  14 +.header {
  15 + position: relative;
  16 + text-align: center;
  17 + overflow: hidden;
  18 +}
  19 +.mt-header {
  20 + margin-top: 80rpx;
  21 +}
  22 +
  23 +.fellow-bar {
  24 + position: fixed;
  25 + width: 100%;
  26 + top: 0rpx;
  27 + z-index: 1000;
  28 +}
  29 +
  30 +.action-bar {
  31 + position: fixed;
  32 + width: 100%;
  33 + bottom: 0;
  34 + z-index: 999;
  35 +}
  36 +
  37 +.foot {
  38 + height: 160rpx;
  39 +}
  40 +
  41 +.action-item {
  42 + flex: 1;
  43 + color: white;
  44 + text-align: center;
  45 + font-size: 32rpx;
  46 + height: 100rpx;
  47 + line-height: 100rpx;
  48 + background-color: white;
  49 + border-radius: unset;
  50 +}
  51 +
  52 +.action-list {
  53 + flex: 0;
  54 + position: relative;
  55 + flex-basis: 150rpx;
  56 +}
  57 +
  58 +.action-image {
  59 + width: 46rpx;
  60 + height: 42rpx;
  61 + position: absolute;
  62 + top: 50%;
  63 + left: 50%;
  64 + /* transform: translateY(-50%); */
  65 + transform: translate(-50%, -50%);
  66 +}
  67 +
  68 +.action-bar2 {
  69 + display: flex;
  70 + width: 100%;
  71 + height: 100rpx;
  72 +}
  73 +
  74 +.auth-content {
  75 + font-size: 28rpx;
  76 + color: #444444;
  77 + line-height: 40rpx;
  78 + text-align: center;
  79 + margin-top: 96rpx;
  80 +}
  81 +
  82 +.auth-foot {
  83 + position: absolute;
  84 + box-sizing: border-box;
  85 + bottom: 0;
  86 + width: 100%;
  87 + height: 90rpx;
  88 + line-height: 90rpx;
  89 + font-size: 32rpx;
  90 + font-weight: bolder;
  91 + text-align: center;
  92 + border-top: 1rpx solid #e0e0e0;
  93 +}
  94 +
  95 +.jion-tips-image {
  96 + margin-left: 30rpx;
  97 + width: 690rpx;
  98 + height: 80rpx;
  99 + margin-top: 20rpx;
  100 +}
  101 +
  102 +.machine {
  103 + background-image: url('https://cdn.yoho.cn/o_1dh8e94lvd4g1ut18pk1in8ure8.png');
  104 + background-size: contain;
  105 + background-repeat: no-repeat;
  106 + min-height: 258rpx;
  107 + position: relative;
  108 + margin-left: 83.6rpx;
  109 + width: 598rpx;
  110 + overflow: hidden;
  111 +}
  112 +.machine-t-l {
  113 + margin-top: 20rpx;
  114 +}
  115 +
  116 +.machine-t-m {
  117 + margin-top: 40rpx;
  118 +}
  119 +
  120 +.machine .code-list {
  121 + position: relative;
  122 + width: 410rpx;
  123 + height: 22rpx;
  124 + margin: 110rpx auto 0 78rpx;
  125 + overflow: hidden;
  126 +}
  127 +
  128 +.code-list .code-list-item {
  129 + margin-top: -12rpx;
  130 + width: 410rpx;
  131 + height: 164rpx;
  132 + overflow: hidden;
  133 + position: relative;
  134 +}
  135 +
  136 +.code-list .code-list-item-container {
  137 + position: absolute;
  138 + bottom: 0;
  139 + width: 410rpx;
  140 +}
  141 +
  142 +.code-list .code-list-item .code {
  143 + float: left;
  144 +}
  145 +
  146 +.machine .code {
  147 + width: 410rpx;
  148 + position: relative;
  149 +}
  150 +
  151 +.code-list .code-list-item .content {
  152 + width: 410rpx;
  153 + height: 164rpx;
  154 + position: relative;
  155 + background-image: url('https://img11.static.yhbimg.com/yhb-img01/2018/12/27/19/0140fa3243af949068d2aabeedb0ea0666.png');
  156 + background-size: cover;
  157 + background-repeat: no-repeat;
  158 + overflow: hidden;
  159 + z-index: 4;
  160 +}
  161 +
  162 +.code-list .code-list-item .content .thumb {
  163 + width: 60rpx;
  164 + height: 60rpx;
  165 + margin: 46rpx 10rpx 46rpx 32rpx;
  166 + border-radius: 30rpx;
  167 +}
  168 +.code-list .code-list-item .content .my-code {
  169 + height: 44rpx;
  170 + float: right;
  171 + vertical-align: middle;
  172 + line-height: 156rpx;
  173 + font-size: 32rpx;
  174 + margin-right: 46rpx;
  175 +}
  176 +.code-list .code-list-item .content .text {
  177 + font-size: 16rpx;
  178 + display: inline-block;
  179 + height: 172rpx;
  180 + vertical-align: middle;
  181 +}
  182 +.code-list .code-list-item .shadow {
  183 + width: 410rpx;
  184 + position: absolute;
  185 + top: 6rpx;
  186 +}
  187 +
  188 +.code-list .down {
  189 + width: 20rpx;
  190 + height: 20rpx;
  191 + margin-left: 50%;
  192 +}
  193 +.open-shadow {
  194 + box-shadow: 0rpx 0rpx 16rpx 4rpx #000;
  195 + width: 394rpx;
  196 + height: 0rpx;
  197 + position: absolute;
  198 + top: 112rpx;
  199 + z-index: 10;
  200 + left: 82rpx;
  201 +}
  202 +
  203 +.appBtn {
  204 + position: fixed;
  205 + width: 80rpx;
  206 + height: 160rpx;
  207 + right: 50rpx;
  208 + bottom: 148rpx;
  209 + padding: 0;
  210 + align-self: center;
  211 + background-color: transparent !important;
  212 + z-index: 99;
  213 +}
  214 +.appBtn::after {
  215 + border: none;
  216 +}
  217 +
  218 +.appBtn .appImg {
  219 + width: 80rpx;
  220 + height: 160rpx;
  221 +}
  222 +
  223 +.flow-tile-wrap {
  224 + display: flex;
  225 + font-size: 36rpx;
  226 + padding: 0 30rpx;
  227 + align-items: center;
  228 + justify-content: space-between;
  229 +}
  230 +.endTip {
  231 + background-color: #999999;
  232 + height: 80rpx;
  233 + color: #ffffff;
  234 + display: flex;
  235 + align-items: center;
  236 + padding-left: 30rpx;
  237 + font-size: 28rpx;
  238 + letter-spacing: -0.34rpx;
  239 +}
@@ -6,8 +6,8 @@ import iconfSwitch from '../../../libs/switch'; @@ -6,8 +6,8 @@ import iconfSwitch from '../../../libs/switch';
6 import md5 from '../../../vendors/md5'; 6 import md5 from '../../../vendors/md5';
7 7
8 //注:g_sourceApiArry与g_toJavaApiArry的length要相等,且一一对应 8 //注:g_sourceApiArry与g_toJavaApiArry的length要相等,且一一对应
9 -const g_sourceApiArry = [ '/list', '/content', '/list/recommend', '/code/recent', '/list/mine', '/code/gain', '/code/mine' ];  
10 -const g_toJavaApiArry = [ 'app.yoluck.activityList', 'app.yoluck.getContent', 'app.yoluck.recommendList', 'app.yoluck.recent', 'app.yoluck.participationList', 'app.yoluck.getCode', 'app.yoluck.userCode' ]; 9 +const g_sourceApiArry = [ '/list', '/content', '/list/recommend', '/code/recent', '/list/mine', '/code/gain', '/code/mine','/yohood/content' ];
  10 +const g_toJavaApiArry = [ 'app.yoluck.activityList', 'app.yoluck.getContent', 'app.yoluck.recommendList', 'app.yoluck.recent', 'app.yoluck.participationList', 'app.yoluck.getCode', 'app.yoluck.userCode','app.yohood.getContent' ];
11 11
12 12
13 const app = getApp(); 13 const app = getApp();
@@ -32,7 +32,7 @@ class Service { @@ -32,7 +32,7 @@ class Service {
32 32
33 //适配服务器更换Java接口,开关控制是否切换 33 //适配服务器更换Java接口,开关控制是否切换
34 if (app.globalData.switch_javaApiEnable && pathIndex >= 0) { 34 if (app.globalData.switch_javaApiEnable && pathIndex >= 0) {
35 - if (result.data.list) { 35 + if (result.data&& result.data.list) {
36 let newList = Humps.decamelizeKeys(Object.values(result.data.list)); 36 let newList = Humps.decamelizeKeys(Object.values(result.data.list));
37 result.data.list = newList; 37 result.data.list = newList;
38 } else { 38 } else {
@@ -49,6 +49,21 @@ class ZeroSellService extends Service { @@ -49,6 +49,21 @@ class ZeroSellService extends Service {
49 }); 49 });
50 } 50 }
51 51
  52 + getYohoodDetail(data) {
  53 + return this._get('/yohood/content', data).then(result => {
  54 + if (result.code === 200) {
  55 + Object.keys(result.data).forEach(item => {
  56 + if (item === 'my_code_num') {
  57 + result.data['myCodeNum'] = result.data[item];
  58 + }
  59 + })
  60 + return result;
  61 + }
  62 +
  63 + return result;
  64 + });
  65 + }
  66 +
52 getRecommend(data) { 67 getRecommend(data) {
53 data.channel = 0 68 data.channel = 0
54 return this._get('/list/recommend', data).then(result => { 69 return this._get('/list/recommend', data).then(result => {
@@ -71,10 +71,18 @@ @@ -71,10 +71,18 @@
71 "scene": "1011" 71 "scene": "1011"
72 }, 72 },
73 { 73 {
74 - "id": -1, 74 + "id": 5,
75 "name": "YOLUCK DETAIL", 75 "name": "YOLUCK DETAIL",
76 "pathName": "pages/zeroSell/detail", 76 "pathName": "pages/zeroSell/detail",
77 - "query": "actPrizeId=41" 77 + "query": "actPrizeId=224",
  78 + "scene": null
  79 + },
  80 + {
  81 + "id": 6,
  82 + "name": "YOHOOD LOTTERY",
  83 + "pathName": "pages/zeroSell/originalPriceSell",
  84 + "query": "",
  85 + "scene": null
78 }, 86 },
79 { 87 {
80 "id": 6, 88 "id": 6,
1 -'use strict' 1 +'use strict';
2 2
3 //获取应用实例 3 //获取应用实例
4 4
5 -/**  
6 - * 时间戳转化为年 月 日 时 分 秒 5 +/**
  6 + * 时间戳转化为年 月 日 时 分 秒
7 * time: 传入时间戳 7 * time: 传入时间戳
8 - * format:返回格式,支持自定义,但参数必须与formateArr里保持一致 8 + * format:返回格式,支持自定义,但参数必须与formateArr里保持一致
9 * formatTimeByDefined(1488481383,'Y/M/D h:m:s') => 2017/03/03 03:03:03 9 * formatTimeByDefined(1488481383,'Y/M/D h:m:s') => 2017/03/03 03:03:03
10 -*/ 10 + */
11 function formatTimeByDefined(time, format) { 11 function formatTimeByDefined(time, format) {
12 -  
13 var formateArr = ['Y', 'M', 'D', 'h', 'm', 's']; 12 var formateArr = ['Y', 'M', 'D', 'h', 'm', 's'];
14 var returnArr = []; 13 var returnArr = [];
15 14
@@ -26,31 +25,35 @@ function formatTimeByDefined(time, format) { @@ -26,31 +25,35 @@ function formatTimeByDefined(time, format) {
26 format = format.replace(formateArr[i], returnArr[i]); 25 format = format.replace(formateArr[i], returnArr[i]);
27 } 26 }
28 return format; 27 return format;
29 -} 28 +}
30 29
31 function formatTime(date) { 30 function formatTime(date) {
32 - var year = date.getFullYear()  
33 - var month = date.getMonth() + 1  
34 - var day = date.getDate()  
35 -  
36 - var hour = date.getHours()  
37 - var minute = date.getMinutes()  
38 - var second = date.getSeconds()  
39 -  
40 - return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':') 31 + var year = date.getFullYear();
  32 + var month = date.getMonth() + 1;
  33 + var day = date.getDate();
  34 +
  35 + var hour = date.getHours();
  36 + var minute = date.getMinutes();
  37 + var second = date.getSeconds();
  38 +
  39 + return (
  40 + [year, month, day].map(formatNumber).join('/') +
  41 + ' ' +
  42 + [hour, minute, second].map(formatNumber).join(':')
  43 + );
41 } 44 }
42 45
43 function formatNumber(n) { 46 function formatNumber(n) {
44 - n = n.toString()  
45 - return n[1] ? n : '0' + n 47 + n = n.toString();
  48 + return n[1] ? n : '0' + n;
46 } 49 }
47 50
48 function getDeviceInfo(wx) { 51 function getDeviceInfo(wx) {
49 - let res = wx.getSystemInfoSync(),  
50 - windowWidth; 52 + let res = wx.getSystemInfoSync(),
  53 + windowWidth;
51 54
52 - windowWidth = res.windowWidth;  
53 - return { windowWidth }; 55 + windowWidth = res.windowWidth;
  56 + return { windowWidth };
54 } 57 }
55 58
56 function shouldDiscardTap(currentTimeStamp, lastTimeStamp) { 59 function shouldDiscardTap(currentTimeStamp, lastTimeStamp) {
@@ -61,31 +64,41 @@ function shouldDiscardTap(currentTimeStamp, lastTimeStamp) { @@ -61,31 +64,41 @@ function shouldDiscardTap(currentTimeStamp, lastTimeStamp) {
61 return false; 64 return false;
62 } 65 }
63 66
64 -function formatImgUrl (json) {  
65 - json.data && json.data.map((item, index) => {  
66 - let replaceStr = "{width}";  
67 - let url = item.src;  
68 - url = url.replace(new RegExp('{width}'), windowWidth * 2).replace(new RegExp('{height}'), 100).replace(new RegExp('{mode}'), '2');  
69 - item.src = url;  
70 - // console.log(url)  
71 - }); 67 +function formatImgUrl(json) {
  68 + json.data &&
  69 + json.data.map((item, index) => {
  70 + let replaceStr = '{width}';
  71 + let url = item.src;
  72 + url = url
  73 + .replace(new RegExp('{width}'), windowWidth * 2)
  74 + .replace(new RegExp('{height}'), 100)
  75 + .replace(new RegExp('{mode}'), '2');
  76 + item.src = url;
  77 + // console.log(url)
  78 + });
72 return json; 79 return json;
73 } 80 }
74 81
75 -function getImageUrl(url, windowWidth,height){  
76 - if(!url){ 82 +function getImageUrl(url, windowWidth, height) {
  83 + if (!url) {
77 return ''; 84 return '';
78 } 85 }
79 - return url.replace(new RegExp('{width}'), windowWidth *2).replace(new RegExp('{height}'), height?height:100).replace(new RegExp('{mode}'), '2'); 86 + return url
  87 + .replace(new RegExp('{width}'), windowWidth * 2)
  88 + .replace(new RegExp('{height}'), height ? height : 100)
  89 + .replace(new RegExp('{mode}'), '2');
80 } 90 }
81 91
82 -function formatImageUrl(url, width, height, mode){ 92 +function formatImageUrl(url, width, height, mode) {
83 url = url || ''; 93 url = url || '';
84 if (url && url.indexOf('?') === -1) { 94 if (url && url.indexOf('?') === -1) {
85 - url = url + '?imageView2/{mode}/w/{width}/h/{height}'; 95 + url = url + '?imageView2/{mode}/w/{width}/h/{height}';
86 } 96 }
87 97
88 - return url.replace(/{width}/g, width).replace(/{height}/g, height).replace('{mode}', mode || 2); 98 + return url
  99 + .replace(/{width}/g, width)
  100 + .replace(/{height}/g, height)
  101 + .replace('{mode}', mode || 2);
89 } 102 }
90 103
91 // 自动识别 2倍 3倍图 104 // 自动识别 2倍 3倍图
@@ -98,31 +111,40 @@ function getImageUrlWithWH(image_url, image_width, image_height) { @@ -98,31 +111,40 @@ function getImageUrlWithWH(image_url, image_width, image_height) {
98 if (!image_url) { 111 if (!image_url) {
99 return ''; 112 return '';
100 } 113 }
101 - return image_url.replace(/{width}/g, parseInt(image_width * DEVICE_WIDTH_RATIO * pixelRatio)).replace(/{height}/g, parseInt(image_height * DEVICE_WIDTH_RATIO * pixelRatio)).replace('{mode}', 2); 114 + return image_url
  115 + .replace(
  116 + /{width}/g,
  117 + parseInt(image_width * DEVICE_WIDTH_RATIO * pixelRatio),
  118 + )
  119 + .replace(
  120 + /{height}/g,
  121 + parseInt(image_height * DEVICE_WIDTH_RATIO * pixelRatio),
  122 + )
  123 + .replace('{mode}', 2);
102 } 124 }
103 125
104 -function getBrandID (url) {  
105 - let params = url.split("openby:yohobuy=") 126 +function getBrandID(url) {
  127 + let params = url.split('openby:yohobuy=');
106 if (params.length == 2) { 128 if (params.length == 2) {
107 - let jsonParam = JSON.parse(params[1]) 129 + let jsonParam = JSON.parse(params[1]);
108 return jsonParam.params.brand_id; 130 return jsonParam.params.brand_id;
109 } 131 }
110 return null; 132 return null;
111 } 133 }
112 134
113 -function isStringEmpty(str){  
114 - if (str===undefined || str ===null || str ===''){  
115 - return true  
116 - }else{  
117 - return false 135 +function isStringEmpty(str) {
  136 + if (str === undefined || str === null || str === '') {
  137 + return true;
  138 + } else {
  139 + return false;
118 } 140 }
119 return true; 141 return true;
120 } 142 }
121 143
122 function getGoodDetailParam(url) { 144 function getGoodDetailParam(url) {
123 - let params = url.split("openby:yohobuy=") 145 + let params = url.split('openby:yohobuy=');
124 if (params.length == 2) { 146 if (params.length == 2) {
125 - let jsonParam = JSON.parse(params[1]) 147 + let jsonParam = JSON.parse(params[1]);
126 return JSON.stringify(jsonParam.params); 148 return JSON.stringify(jsonParam.params);
127 } 149 }
128 return null; 150 return null;
@@ -130,29 +152,29 @@ function getGoodDetailParam(url) { @@ -130,29 +152,29 @@ function getGoodDetailParam(url) {
130 152
131 function formatDateTime(inputTime) { 153 function formatDateTime(inputTime) {
132 var date = new Date(); 154 var date = new Date();
133 - date.setTime(inputTime*1000); 155 + date.setTime(inputTime * 1000);
134 var y = date.getFullYear(); 156 var y = date.getFullYear();
135 var m = date.getMonth() + 1; 157 var m = date.getMonth() + 1;
136 - m = m < 10 ? ('0' + m) : m; 158 + m = m < 10 ? '0' + m : m;
137 var d = date.getDate(); 159 var d = date.getDate();
138 - d = d < 10 ? ('0' + d) : d;  
139 - return y + '.' + m + '.'+d;  
140 -};  
141 -  
142 -function formateTimestamp(start,end){  
143 - var startTime = formatDateTime(start)  
144 - var endTime = formatDateTime(end)  
145 - return startTime+'-'+endTime 160 + d = d < 10 ? '0' + d : d;
  161 + return y + '.' + m + '.' + d;
  162 +}
  163 +
  164 +function formateTimestamp(start, end) {
  165 + var startTime = formatDateTime(start);
  166 + var endTime = formatDateTime(end);
  167 + return startTime + '-' + endTime;
146 } 168 }
147 169
148 function getParameterByName(name, url) { 170 function getParameterByName(name, url) {
149 if (!url) url = window.location.href; 171 if (!url) url = window.location.href;
150 - name = name.replace(/[\[\]]/g, "\\$&");  
151 - var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), 172 + name = name.replace(/[\[\]]/g, '\\$&');
  173 + var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
152 results = regex.exec(url); 174 results = regex.exec(url);
153 if (!results) return null; 175 if (!results) return null;
154 if (!results[2]) return ''; 176 if (!results[2]) return '';
155 - return decodeURIComponent(results[2].replace(/\+/g, " ")); 177 + return decodeURIComponent(results[2].replace(/\+/g, ' '));
156 } 178 }
157 179
158 function getSknFromUrl(url) { 180 function getSknFromUrl(url) {
@@ -160,7 +182,9 @@ function getSknFromUrl(url) { @@ -160,7 +182,9 @@ function getSknFromUrl(url) {
160 url = decodeURIComponent(url).toLowerCase(); 182 url = decodeURIComponent(url).toLowerCase();
161 let components = url.split('/'); 183 let components = url.split('/');
162 let lastElement = components.pop(); 184 let lastElement = components.pop();
163 - let startLegal = url.startsWith('https://m.yohobuy.com/product') || url.startsWith('http://m.yohobuy.com/product'); 185 + let startLegal =
  186 + url.startsWith('https://m.yohobuy.com/product') ||
  187 + url.startsWith('http://m.yohobuy.com/product');
164 let endLegal = lastElement.endsWith('.html'); 188 let endLegal = lastElement.endsWith('.html');
165 if (!startLegal || !endLegal) { 189 if (!startLegal || !endLegal) {
166 return ''; 190 return '';
@@ -175,7 +199,9 @@ function getShopIdFromUrl(url) { @@ -175,7 +199,9 @@ function getShopIdFromUrl(url) {
175 url = decodeURIComponent(url).toLowerCase(); 199 url = decodeURIComponent(url).toLowerCase();
176 let components = url.split('/'); 200 let components = url.split('/');
177 let lastElement = components.pop(); 201 let lastElement = components.pop();
178 - let startLegal = url.startsWith('https://m.yohobuy.com/shop') || url.startsWith('http://m.yohobuy.com/shop'); 202 + let startLegal =
  203 + url.startsWith('https://m.yohobuy.com/shop') ||
  204 + url.startsWith('http://m.yohobuy.com/shop');
179 let endLegal = lastElement.endsWith('.html'); 205 let endLegal = lastElement.endsWith('.html');
180 if (!startLegal || !endLegal) { 206 if (!startLegal || !endLegal) {
181 return ''; 207 return '';
@@ -187,9 +213,9 @@ function getShopIdFromUrl(url) { @@ -187,9 +213,9 @@ function getShopIdFromUrl(url) {
187 } 213 }
188 214
189 function getShopID(url) { 215 function getShopID(url) {
190 - let params = url.split("openby:yohobuy=") 216 + let params = url.split('openby:yohobuy=');
191 if (params.length == 2) { 217 if (params.length == 2) {
192 - let jsonParam = JSON.parse(params[1]) 218 + let jsonParam = JSON.parse(params[1]);
193 return jsonParam.params.shop_id; 219 return jsonParam.params.shop_id;
194 } 220 }
195 return null; 221 return null;
@@ -202,22 +228,23 @@ function contains(arr, obj) { @@ -202,22 +228,23 @@ function contains(arr, obj) {
202 } 228 }
203 } 229 }
204 return -1; 230 return -1;
205 -} 231 +}
206 232
207 function getGuangType(url) { 233 function getGuangType(url) {
208 - let params = url.split("openby:yohobuy=") 234 + let params = url.split('openby:yohobuy=');
209 if (params.length == 2) { 235 if (params.length == 2) {
210 - let jsonParam = JSON.parse(params[1]) 236 + let jsonParam = JSON.parse(params[1]);
211 return jsonParam.params.type; 237 return jsonParam.params.type;
212 } 238 }
213 return null; 239 return null;
214 } 240 }
215 241
216 -// public method for encoding 242 +// public method for encoding
217 function base64Encode(input) { 243 function base64Encode(input) {
218 - let _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; 244 + let _keyStr =
  245 + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
219 246
220 - var output = ""; 247 + var output = '';
221 var chr1, chr2, chr3, enc1, enc2, enc3, enc4; 248 var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
222 var i = 0; 249 var i = 0;
223 input = _utf8_encode(input); 250 input = _utf8_encode(input);
@@ -234,21 +261,25 @@ function base64Encode(input) { @@ -234,21 +261,25 @@ function base64Encode(input) {
234 } else if (isNaN(chr3)) { 261 } else if (isNaN(chr3)) {
235 enc4 = 64; 262 enc4 = 64;
236 } 263 }
237 - output = output +  
238 - _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +  
239 - _keyStr.charAt(enc3) + _keyStr.charAt(enc4); 264 + output =
  265 + output +
  266 + _keyStr.charAt(enc1) +
  267 + _keyStr.charAt(enc2) +
  268 + _keyStr.charAt(enc3) +
  269 + _keyStr.charAt(enc4);
240 } 270 }
241 return output; 271 return output;
242 } 272 }
243 273
244 -// public method for decoding 274 +// public method for decoding
245 function base64Decode(input) { 275 function base64Decode(input) {
246 - let _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";  
247 - var output = ""; 276 + let _keyStr =
  277 + 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  278 + var output = '';
248 var chr1, chr2, chr3; 279 var chr1, chr2, chr3;
249 var enc1, enc2, enc3, enc4; 280 var enc1, enc2, enc3, enc4;
250 var i = 0; 281 var i = 0;
251 - input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); 282 + input = input.replace(/[^A-Za-z0-9\+\/\=]/g, '');
252 while (i < input.length) { 283 while (i < input.length) {
253 enc1 = _keyStr.indexOf(input.charAt(i++)); 284 enc1 = _keyStr.indexOf(input.charAt(i++));
254 enc2 = _keyStr.indexOf(input.charAt(i++)); 285 enc2 = _keyStr.indexOf(input.charAt(i++));
@@ -270,13 +301,13 @@ function base64Decode(input) { @@ -270,13 +301,13 @@ function base64Decode(input) {
270 } 301 }
271 302
272 function _utf8_encode(string) { 303 function _utf8_encode(string) {
273 - string = string.replace(/\r\n/g, "\n");  
274 - var utftext = ""; 304 + string = string.replace(/\r\n/g, '\n');
  305 + var utftext = '';
275 for (var n = 0; n < string.length; n++) { 306 for (var n = 0; n < string.length; n++) {
276 var c = string.charCodeAt(n); 307 var c = string.charCodeAt(n);
277 if (c < 128) { 308 if (c < 128) {
278 utftext += String.fromCharCode(c); 309 utftext += String.fromCharCode(c);
279 - } else if ((c > 127) && (c < 2048)) { 310 + } else if (c > 127 && c < 2048) {
280 utftext += String.fromCharCode((c >> 6) | 192); 311 utftext += String.fromCharCode((c >> 6) | 192);
281 utftext += String.fromCharCode((c & 63) | 128); 312 utftext += String.fromCharCode((c & 63) | 128);
282 } else { 313 } else {
@@ -284,16 +315,15 @@ function _utf8_encode(string) { @@ -284,16 +315,15 @@ function _utf8_encode(string) {
284 utftext += String.fromCharCode(((c >> 6) & 63) | 128); 315 utftext += String.fromCharCode(((c >> 6) & 63) | 128);
285 utftext += String.fromCharCode((c & 63) | 128); 316 utftext += String.fromCharCode((c & 63) | 128);
286 } 317 }
287 -  
288 } 318 }
289 return utftext; 319 return utftext;
290 } 320 }
291 321
292 -// private method for UTF-8 decoding 322 +// private method for UTF-8 decoding
293 function _utf8_decode(utftext) { 323 function _utf8_decode(utftext) {
294 - var string = ""; 324 + var string = '';
295 var i = 0; 325 var i = 0;
296 - var c = 0; 326 + var c = 0;
297 var c1 = 0; 327 var c1 = 0;
298 var c2 = 0; 328 var c2 = 0;
299 var c3 = 0; 329 var c3 = 0;
@@ -302,14 +332,16 @@ function _utf8_decode(utftext) { @@ -302,14 +332,16 @@ function _utf8_decode(utftext) {
302 if (c < 128) { 332 if (c < 128) {
303 string += String.fromCharCode(c); 333 string += String.fromCharCode(c);
304 i++; 334 i++;
305 - } else if ((c > 191) && (c < 224)) { 335 + } else if (c > 191 && c < 224) {
306 c2 = utftext.charCodeAt(i + 1); 336 c2 = utftext.charCodeAt(i + 1);
307 string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); 337 string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
308 i += 2; 338 i += 2;
309 } else { 339 } else {
310 c2 = utftext.charCodeAt(i + 1); 340 c2 = utftext.charCodeAt(i + 1);
311 c3 = utftext.charCodeAt(i + 2); 341 c3 = utftext.charCodeAt(i + 2);
312 - string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); 342 + string += String.fromCharCode(
  343 + ((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63),
  344 + );
313 i += 3; 345 i += 3;
314 } 346 }
315 } 347 }
@@ -319,7 +351,7 @@ function _utf8_decode(utftext) { @@ -319,7 +351,7 @@ function _utf8_decode(utftext) {
319 key: 关键词 351 key: 关键词
320 fromPage: 来源页面名称 352 fromPage: 来源页面名称
321 **/ 353 **/
322 -function getYHStorageSync(key,fromPage) { 354 +function getYHStorageSync(key, fromPage) {
323 // console.log(key) 355 // console.log(key)
324 // console.log(fromPage) 356 // console.log(fromPage)
325 try { 357 try {
@@ -344,7 +376,7 @@ key: 关键词 @@ -344,7 +376,7 @@ key: 关键词
344 value: 内容 376 value: 内容
345 fromPage: 来源页面名称 377 fromPage: 来源页面名称
346 **/ 378 **/
347 -function setStorageSync(key,value, fromPage) { 379 +function setStorageSync(key, value, fromPage) {
348 try { 380 try {
349 wx.setStorageSync(key, value); 381 wx.setStorageSync(key, value);
350 return true; 382 return true;
@@ -366,6 +398,26 @@ function removeStorageSync(key, fromPage) { @@ -366,6 +398,26 @@ function removeStorageSync(key, fromPage) {
366 } 398 }
367 } 399 }
368 400
  401 +/**
  402 + * 格式化倒计时时间
  403 + * time in seconds
  404 + */
  405 +function fomartCountdownTime(remainingTimeInSeconds = 0) {
  406 + if (remainingTimeInSeconds < 0) {
  407 + return [];
  408 + }
  409 +
  410 + const timeInHour = Math.floor(remainingTimeInSeconds / 3600);
  411 + let remainingTime = remainingTimeInSeconds - timeInHour * 3600;
  412 +
  413 + const timeInMinute = Math.floor(remainingTime / 60);
  414 + remainingTime = parseInt(remainingTime - timeInMinute * 60);
  415 +
  416 + return [timeInHour, timeInMinute, remainingTime].map(time => {
  417 + return `${time > 9 ? time : `0${time}`}`;
  418 + });
  419 +}
  420 +
369 module.exports = { 421 module.exports = {
370 formatTimeByDefined, 422 formatTimeByDefined,
371 formatTime: formatTime, 423 formatTime: formatTime,
@@ -389,5 +441,6 @@ module.exports = { @@ -389,5 +441,6 @@ module.exports = {
389 base64Decode, 441 base64Decode,
390 getYHStorageSync, 442 getYHStorageSync,
391 setStorageSync, 443 setStorageSync,
392 - removeStorageSync  
393 -}  
  444 + removeStorageSync,
  445 + fomartCountdownTime,
  446 +};