Commit c2712cce6b5a0b899c854f82396a0ae3ddba91c7

Authored by 宋庆平
1 parent 80bdd248

X

wxsdk/base/SDKConst.ts
... ... @@ -33,7 +33,7 @@ export const GAMEDATA = {
33 33 }
34 34  
35 35 // sdk版本
36   -export const SDKVersion = 'v1.0.8';
  36 +export const SDKVersion = 'v1.0.9';
37 37 // 是否打印
38 38 export const __LOG__ = false;
39 39 // 是否mock
... ...
wxsdk/service/DataService.ts
... ... @@ -17,12 +17,22 @@ export default class DataService {
17 17 // 0点数据变动
18 18 let expiration = +((this.nextDay() - Date.now()) / 1000).toFixed(0);
19 19 setTimeout(this.resetData, expiration * 1000);
  20 + wx.onShow(this.onShow.bind(this));
  21 + wx.onHide(this.onHide.bind(this));
  22 + }
20 23  
  24 + onShow() {
  25 + // console.log("dataOnshow");
  26 + this.updateTodayOnlineTime();
  27 + }
  28 + onHide() {
  29 + // console.log("dataOnhide");
  30 + clearInterval(this.timeInterval);
21 31 }
22 32  
23   - private resetData(){
  33 + private resetData() {
24 34 this.setPtm(0);//更新当天是否300s
25   - this.setLogindays(this.logindays+1);// 更新登录天数
  35 + this.setLogindays(this.logindays + 1);// 更新登录天数
26 36 this.setIsnew(0);//更新新老用户
27 37 }
28 38  
... ... @@ -515,6 +525,13 @@ export default class DataService {
515 525 return this;
516 526 }
517 527  
  528 + // public addOnlineTime(t) {
  529 + // let expiration = +((this.nextDay() - Date.now()) / 1000).toFixed(0);
  530 + // let time = StorageUtils.I.get("pcsdk_today_online_time") || 0;
  531 + // time += t;
  532 + // StorageUtils.I.set("pcsdk_today_online_time", time, expiration)
  533 + // }
  534 +
518 535 private timeInterval
519 536 public updateTodayOnlineTime() {
520 537 let dot = StorageUtils.I.get("pcsdk_today_online_time_300") || 0;
... ... @@ -528,13 +545,15 @@ export default class DataService {
528 545 return;
529 546 } else {
530 547 this.setPtm(0)
531   - this.timeInterval = setInterval(this.stayFun.bind(this), 5000);
  548 + this.timeInterval = setInterval(this.stayFun.bind(this), 1000);
532 549 }
533 550 }
  551 +
  552 +
534 553 private stayFun() {
535 554 let expiration = +((this.nextDay() - Date.now()) / 1000).toFixed(0);
536 555 let time = StorageUtils.I.get("pcsdk_today_online_time") || 0;
537   - time += 5;
  556 + time += 1;
538 557 StorageUtils.I.set("pcsdk_today_online_time", time, expiration)
539 558 let dot = StorageUtils.I.get("pcsdk_today_online_time_300") || 0;
540 559 if (dot === 1) {
... ... @@ -546,7 +565,7 @@ export default class DataService {
546 565 }, expiration * 1000);
547 566 return;
548 567 }
549   - // console.log("newUserTime", newUserTime, newUserDot)
  568 + console.log("newUserTime", time, dot)
550 569 if (time >= 300 && dot == 0) {
551 570 StorageUtils.I.set("pcsdk_today_online_time_300", 1, expiration);
552 571 this.setPtm(1)
... ...
wxsdk/share/SDKVideo.ts
... ... @@ -162,12 +162,12 @@ export default class SDKVideo {
162 162 private handleClose(res: any) {
163 163 __LOG__ && console.warn('====> PCSDK WxVideo 广告关闭', res && res.isEnded || res === undefined);
164 164 let that = SDKVideo.I;
  165 + let t = Math.floor((Date.now() - that.show_time) / 1000);
165 166 if (res && res.isEnded || res === undefined) {
166 167 // 统计看视频成功
167 168 LogService.I.adStat(that.videoKey, that.adUnitId, DOT_AD_TYPE.video, DOT_AD_STATUS.complete)
168 169 that.resolve && that.resolve({ type: 2 });
169 170 } else {
170   - let t = Math.floor((Date.now() - that.show_time) / 1000);
171 171 // console.log("视频关闭时间:", t)
172 172 LogService.I.adStat(that.videoKey, that.adUnitId, DOT_AD_TYPE.video, DOT_AD_STATUS.interrupt, t)
173 173 that.reject && that.reject({ ...ShareVideoError.VideoQuit });
... ...
wxsdk/wx/WxLogin.ts
... ... @@ -187,7 +187,11 @@ export default class WxLogin {
187 187 refToken: reftoken,
188 188 expire,
189 189 });
190   - this.handleExpire(expire)
  190 + try { //修改时间后会报错,未找到原因
  191 + this.handleExpire(expire)
  192 + } catch (error) {
  193 + console.log("handleExpire_error", error)
  194 + }
191 195 })
192 196 }
193 197  
... ...
wxsdk/wx/WxPay.ts
... ... @@ -48,7 +48,7 @@ export default class WxPay {
48 48 WxApi.I.requestMidasPayment(pms)
49 49 .then(() => this.handlePaySuccess({ ...params, platform }, opts, resolve, reject))
50 50 .catch(err => this.handlePayError({ ...params, platform }, opts, err, reject));
51   - }else{
  51 + } else {
52 52 reject(res);
53 53 }
54 54 })
... ...