Commit c2712cce6b5a0b899c854f82396a0ae3ddba91c7
1 parent
80bdd248
Exists in
master
and in
3 other branches
X
Showing
5 changed files
with
32 additions
and
9 deletions
Show diff stats
wxsdk/base/SDKConst.ts
@@ -33,7 +33,7 @@ export const GAMEDATA = { | @@ -33,7 +33,7 @@ export const GAMEDATA = { | ||
33 | } | 33 | } |
34 | 34 | ||
35 | // sdk版本 | 35 | // sdk版本 |
36 | -export const SDKVersion = 'v1.0.8'; | 36 | +export const SDKVersion = 'v1.0.9'; |
37 | // 是否打印 | 37 | // 是否打印 |
38 | export const __LOG__ = false; | 38 | export const __LOG__ = false; |
39 | // 是否mock | 39 | // 是否mock |
wxsdk/service/DataService.ts
@@ -17,12 +17,22 @@ export default class DataService { | @@ -17,12 +17,22 @@ export default class DataService { | ||
17 | // 0点数据变动 | 17 | // 0点数据变动 |
18 | let expiration = +((this.nextDay() - Date.now()) / 1000).toFixed(0); | 18 | let expiration = +((this.nextDay() - Date.now()) / 1000).toFixed(0); |
19 | setTimeout(this.resetData, expiration * 1000); | 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 | this.setPtm(0);//更新当天是否300s | 34 | this.setPtm(0);//更新当天是否300s |
25 | - this.setLogindays(this.logindays+1);// 更新登录天数 | 35 | + this.setLogindays(this.logindays + 1);// 更新登录天数 |
26 | this.setIsnew(0);//更新新老用户 | 36 | this.setIsnew(0);//更新新老用户 |
27 | } | 37 | } |
28 | 38 | ||
@@ -515,6 +525,13 @@ export default class DataService { | @@ -515,6 +525,13 @@ export default class DataService { | ||
515 | return this; | 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 | private timeInterval | 535 | private timeInterval |
519 | public updateTodayOnlineTime() { | 536 | public updateTodayOnlineTime() { |
520 | let dot = StorageUtils.I.get("pcsdk_today_online_time_300") || 0; | 537 | let dot = StorageUtils.I.get("pcsdk_today_online_time_300") || 0; |
@@ -528,13 +545,15 @@ export default class DataService { | @@ -528,13 +545,15 @@ export default class DataService { | ||
528 | return; | 545 | return; |
529 | } else { | 546 | } else { |
530 | this.setPtm(0) | 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 | private stayFun() { | 553 | private stayFun() { |
535 | let expiration = +((this.nextDay() - Date.now()) / 1000).toFixed(0); | 554 | let expiration = +((this.nextDay() - Date.now()) / 1000).toFixed(0); |
536 | let time = StorageUtils.I.get("pcsdk_today_online_time") || 0; | 555 | let time = StorageUtils.I.get("pcsdk_today_online_time") || 0; |
537 | - time += 5; | 556 | + time += 1; |
538 | StorageUtils.I.set("pcsdk_today_online_time", time, expiration) | 557 | StorageUtils.I.set("pcsdk_today_online_time", time, expiration) |
539 | let dot = StorageUtils.I.get("pcsdk_today_online_time_300") || 0; | 558 | let dot = StorageUtils.I.get("pcsdk_today_online_time_300") || 0; |
540 | if (dot === 1) { | 559 | if (dot === 1) { |
@@ -546,7 +565,7 @@ export default class DataService { | @@ -546,7 +565,7 @@ export default class DataService { | ||
546 | }, expiration * 1000); | 565 | }, expiration * 1000); |
547 | return; | 566 | return; |
548 | } | 567 | } |
549 | - // console.log("newUserTime", newUserTime, newUserDot) | 568 | + console.log("newUserTime", time, dot) |
550 | if (time >= 300 && dot == 0) { | 569 | if (time >= 300 && dot == 0) { |
551 | StorageUtils.I.set("pcsdk_today_online_time_300", 1, expiration); | 570 | StorageUtils.I.set("pcsdk_today_online_time_300", 1, expiration); |
552 | this.setPtm(1) | 571 | this.setPtm(1) |
wxsdk/share/SDKVideo.ts
@@ -162,12 +162,12 @@ export default class SDKVideo { | @@ -162,12 +162,12 @@ export default class SDKVideo { | ||
162 | private handleClose(res: any) { | 162 | private handleClose(res: any) { |
163 | __LOG__ && console.warn('====> PCSDK WxVideo 广告关闭', res && res.isEnded || res === undefined); | 163 | __LOG__ && console.warn('====> PCSDK WxVideo 广告关闭', res && res.isEnded || res === undefined); |
164 | let that = SDKVideo.I; | 164 | let that = SDKVideo.I; |
165 | + let t = Math.floor((Date.now() - that.show_time) / 1000); | ||
165 | if (res && res.isEnded || res === undefined) { | 166 | if (res && res.isEnded || res === undefined) { |
166 | // 统计看视频成功 | 167 | // 统计看视频成功 |
167 | LogService.I.adStat(that.videoKey, that.adUnitId, DOT_AD_TYPE.video, DOT_AD_STATUS.complete) | 168 | LogService.I.adStat(that.videoKey, that.adUnitId, DOT_AD_TYPE.video, DOT_AD_STATUS.complete) |
168 | that.resolve && that.resolve({ type: 2 }); | 169 | that.resolve && that.resolve({ type: 2 }); |
169 | } else { | 170 | } else { |
170 | - let t = Math.floor((Date.now() - that.show_time) / 1000); | ||
171 | // console.log("视频关闭时间:", t) | 171 | // console.log("视频关闭时间:", t) |
172 | LogService.I.adStat(that.videoKey, that.adUnitId, DOT_AD_TYPE.video, DOT_AD_STATUS.interrupt, t) | 172 | LogService.I.adStat(that.videoKey, that.adUnitId, DOT_AD_TYPE.video, DOT_AD_STATUS.interrupt, t) |
173 | that.reject && that.reject({ ...ShareVideoError.VideoQuit }); | 173 | that.reject && that.reject({ ...ShareVideoError.VideoQuit }); |
wxsdk/wx/WxLogin.ts
@@ -187,7 +187,11 @@ export default class WxLogin { | @@ -187,7 +187,11 @@ export default class WxLogin { | ||
187 | refToken: reftoken, | 187 | refToken: reftoken, |
188 | expire, | 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,7 +48,7 @@ export default class WxPay { | ||
48 | WxApi.I.requestMidasPayment(pms) | 48 | WxApi.I.requestMidasPayment(pms) |
49 | .then(() => this.handlePaySuccess({ ...params, platform }, opts, resolve, reject)) | 49 | .then(() => this.handlePaySuccess({ ...params, platform }, opts, resolve, reject)) |
50 | .catch(err => this.handlePayError({ ...params, platform }, opts, err, reject)); | 50 | .catch(err => this.handlePayError({ ...params, platform }, opts, err, reject)); |
51 | - }else{ | 51 | + } else { |
52 | reject(res); | 52 | reject(res); |
53 | } | 53 | } |
54 | }) | 54 | }) |