diff --git a/wxsdk/base/SDKConst.ts b/wxsdk/base/SDKConst.ts index e3510b1..098c898 100644 --- a/wxsdk/base/SDKConst.ts +++ b/wxsdk/base/SDKConst.ts @@ -33,7 +33,7 @@ export const GAMEDATA = { } // sdk版本 -export const SDKVersion = 'v1.0.8'; +export const SDKVersion = 'v1.0.9'; // 是否打印 export const __LOG__ = false; // 是否mock diff --git a/wxsdk/service/DataService.ts b/wxsdk/service/DataService.ts index 5938901..7026728 100644 --- a/wxsdk/service/DataService.ts +++ b/wxsdk/service/DataService.ts @@ -17,12 +17,22 @@ export default class DataService { // 0点数据变动 let expiration = +((this.nextDay() - Date.now()) / 1000).toFixed(0); setTimeout(this.resetData, expiration * 1000); + wx.onShow(this.onShow.bind(this)); + wx.onHide(this.onHide.bind(this)); + } + onShow() { + // console.log("dataOnshow"); + this.updateTodayOnlineTime(); + } + onHide() { + // console.log("dataOnhide"); + clearInterval(this.timeInterval); } - private resetData(){ + private resetData() { this.setPtm(0);//更新当天是否300s - this.setLogindays(this.logindays+1);// 更新登录天数 + this.setLogindays(this.logindays + 1);// 更新登录天数 this.setIsnew(0);//更新新老用户 } @@ -515,6 +525,13 @@ export default class DataService { return this; } + // public addOnlineTime(t) { + // let expiration = +((this.nextDay() - Date.now()) / 1000).toFixed(0); + // let time = StorageUtils.I.get("pcsdk_today_online_time") || 0; + // time += t; + // StorageUtils.I.set("pcsdk_today_online_time", time, expiration) + // } + private timeInterval public updateTodayOnlineTime() { let dot = StorageUtils.I.get("pcsdk_today_online_time_300") || 0; @@ -528,13 +545,15 @@ export default class DataService { return; } else { this.setPtm(0) - this.timeInterval = setInterval(this.stayFun.bind(this), 5000); + this.timeInterval = setInterval(this.stayFun.bind(this), 1000); } } + + private stayFun() { let expiration = +((this.nextDay() - Date.now()) / 1000).toFixed(0); let time = StorageUtils.I.get("pcsdk_today_online_time") || 0; - time += 5; + time += 1; StorageUtils.I.set("pcsdk_today_online_time", time, expiration) let dot = StorageUtils.I.get("pcsdk_today_online_time_300") || 0; if (dot === 1) { @@ -546,7 +565,7 @@ export default class DataService { }, expiration * 1000); return; } - // console.log("newUserTime", newUserTime, newUserDot) + console.log("newUserTime", time, dot) if (time >= 300 && dot == 0) { StorageUtils.I.set("pcsdk_today_online_time_300", 1, expiration); this.setPtm(1) diff --git a/wxsdk/share/SDKVideo.ts b/wxsdk/share/SDKVideo.ts index 5b06413..708545a 100644 --- a/wxsdk/share/SDKVideo.ts +++ b/wxsdk/share/SDKVideo.ts @@ -162,12 +162,12 @@ export default class SDKVideo { private handleClose(res: any) { __LOG__ && console.warn('====> PCSDK WxVideo 广告关闭', res && res.isEnded || res === undefined); let that = SDKVideo.I; + let t = Math.floor((Date.now() - that.show_time) / 1000); if (res && res.isEnded || res === undefined) { // 统计看视频成功 LogService.I.adStat(that.videoKey, that.adUnitId, DOT_AD_TYPE.video, DOT_AD_STATUS.complete) that.resolve && that.resolve({ type: 2 }); } else { - let t = Math.floor((Date.now() - that.show_time) / 1000); // console.log("视频关闭时间:", t) LogService.I.adStat(that.videoKey, that.adUnitId, DOT_AD_TYPE.video, DOT_AD_STATUS.interrupt, t) that.reject && that.reject({ ...ShareVideoError.VideoQuit }); diff --git a/wxsdk/wx/WxLogin.ts b/wxsdk/wx/WxLogin.ts index 3cc2122..db79da2 100644 --- a/wxsdk/wx/WxLogin.ts +++ b/wxsdk/wx/WxLogin.ts @@ -187,7 +187,11 @@ export default class WxLogin { refToken: reftoken, expire, }); - this.handleExpire(expire) + try { //修改时间后会报错,未找到原因 + this.handleExpire(expire) + } catch (error) { + console.log("handleExpire_error", error) + } }) } diff --git a/wxsdk/wx/WxPay.ts b/wxsdk/wx/WxPay.ts index 3bd0674..b22e40a 100644 --- a/wxsdk/wx/WxPay.ts +++ b/wxsdk/wx/WxPay.ts @@ -48,7 +48,7 @@ export default class WxPay { WxApi.I.requestMidasPayment(pms) .then(() => this.handlePaySuccess({ ...params, platform }, opts, resolve, reject)) .catch(err => this.handlePayError({ ...params, platform }, opts, err, reject)); - }else{ + } else { reject(res); } }) -- libgit2 0.21.0