From cb66e5125fe6f7ec2cc1816e7b1d272d5587c97f Mon Sep 17 00:00:00 2001 From: lipenggao Date: Mon, 29 Jul 2024 09:16:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=A3=E5=BC=8F=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/collection/collection.ts | 2 +- pages/consumption/consumption.ts | 2 +- pages/history/history.ts | 2 +- pages/pay/pay.ts | 2 +- pages/rechargeRecord/rechargeRecord.ttss | 1 + pages/videoDetail/videoDetail.ts | 75 +++++++++++++----------- utils/httpReques.ts | 2 +- 7 files changed, 48 insertions(+), 38 deletions(-) diff --git a/pages/collection/collection.ts b/pages/collection/collection.ts index 727c0bc..04df58f 100644 --- a/pages/collection/collection.ts +++ b/pages/collection/collection.ts @@ -34,7 +34,7 @@ Page({ const id = ev.currentTarget.dataset.id; console.log(id, "chapteridchapteridchapterid") tt.navigateTo({ - url: `/pages/videoDetail/videoDetail?sid=${sid}&id=${id}`, + url: `/pages/videoDetail/videoDetail?sid=${sid}&id=${id || ''}`, }); }, myModalRef(ref: any) { diff --git a/pages/consumption/consumption.ts b/pages/consumption/consumption.ts index 55b693a..15249d5 100644 --- a/pages/consumption/consumption.ts +++ b/pages/consumption/consumption.ts @@ -27,7 +27,7 @@ Page({ const sid = ev.currentTarget.dataset.sid; const id = ev.currentTarget.dataset.id; tt.navigateTo({ - url: `/pages/videoDetail/videoDetail?sid=${sid}&id=${id}`, + url: `/pages/videoDetail/videoDetail?sid=${sid}&id=${id || ''}`, }); }, }) \ No newline at end of file diff --git a/pages/history/history.ts b/pages/history/history.ts index 922d329..ca61641 100644 --- a/pages/history/history.ts +++ b/pages/history/history.ts @@ -25,7 +25,7 @@ Page({ const sid = ev.currentTarget.dataset.sid; const chapterid = ev.currentTarget.dataset.chapterid; tt.navigateTo({ - url: `/pages/videoDetail/videoDetail?sid=${sid}&id=${chapterid}`, + url: `/pages/videoDetail/videoDetail?sid=${sid}&id=${chapterid || ''}`, }); }, }) \ No newline at end of file diff --git a/pages/pay/pay.ts b/pages/pay/pay.ts index b571124..c0fb3e0 100644 --- a/pages/pay/pay.ts +++ b/pages/pay/pay.ts @@ -93,7 +93,7 @@ Page({ }); if (otherInfo.toStatus == 1) { tt.redirectTo({ - url: `/pages/videoDetail/videoDetail?sid=${otherInfo.sid}&id=${otherInfo.id}` + url: `/pages/videoDetail/videoDetail?sid=${otherInfo.sid}&id=${otherInfo.id || ''}` }); } else { tt.navigateBack({}); diff --git a/pages/rechargeRecord/rechargeRecord.ttss b/pages/rechargeRecord/rechargeRecord.ttss index 3be92f8..95b46e0 100644 --- a/pages/rechargeRecord/rechargeRecord.ttss +++ b/pages/rechargeRecord/rechargeRecord.ttss @@ -12,6 +12,7 @@ display: flex; width: 100%; height: 100rpx; + z-index: 9999; } ._reh_rec_ta_item { diff --git a/pages/videoDetail/videoDetail.ts b/pages/videoDetail/videoDetail.ts index 6da6a2f..45a784c 100644 --- a/pages/videoDetail/videoDetail.ts +++ b/pages/videoDetail/videoDetail.ts @@ -22,8 +22,8 @@ Page({ // collectionItem: {}, nextbatchList: [], selectedId: '', - adBanner: null, - unlockFlag: true + unlockFlag: true, + adBanner: null }, onLoad(options: any) { const videoCanIUse = tt.canIUse('video-player'); @@ -41,10 +41,9 @@ Page({ }) this.initFn(); + this.adInit() }, - onShow() { - - }, + onShow() { }, async initFn() { const sid = this.data.sid; @@ -173,7 +172,6 @@ Page({ // batchList: bs }) } - // this.selectComponent(`#${nextId}`, (res: any) => { // res?.hidePauseIcon() // }); @@ -264,9 +262,10 @@ Page({ } httpRequest('/addkeep', 'POST', params).then((res: any) => { if (res.status == 1) { + const ic: any = count + 1; videoInfo.bookcase = videoInfo?.bookcase == 1 ? 0 : 1; - videoInfo.count = count + 1; - videoInfo.isCount = this.handelCount(count + 1) + videoInfo.count = ic; + videoInfo.isCount = this.handelCount(ic) this.setData({ videoInfo: videoInfo // videoInfo: { @@ -363,23 +362,25 @@ Page({ }, watchAdvertisement() { let adBanner: any = this.data.adBanner; - const videoInfo: any = this.data.videoInfo; - const batchList: any = this.data.batchList; - const selectionConList = this.data.selectionConList; - const context: any = tt.createVideoContext(`${videoInfo.id}`); + tt.showToast({ + title: `广告加载中...`, + icon: 'none', + }); + adBanner.show().then((res: any) => { + // console.log("视频广告展示"); + }); + }, + adInit() { + + let isAdBanner: any = this.data.adBanner; + // const context: any = tt.createVideoContext(`${videoInfo.id}`); // this.watchInfo.isvip = 0; - if (!adBanner) { - tt.showToast({ - title: `广告加载中...`, - icon: 'none', - }); - adBanner = tt.createRewardedVideoAd({ + if (!isAdBanner) { + const adBanner = tt.createRewardedVideoAd({ adUnitId: "wh0y4vcxsbk7ixwktg", }); - adBanner.show().then((res: any) => { - // console.log("视频广告展示"); - }); + // 监听错误 adBanner.onError((err: any) => { tt.hideLoading({}); @@ -393,10 +394,9 @@ Page({ }); // 监听视频播放完成 - adBanner.onClose(async (res: any) => { + adBanner.onClose((res: any) => { console.log(res, "resres") - if (res.isEnded || true) { - + if (res.isEnded) { // const videoIndex = batchList.findIndex( // (r: any) => r.id === videoInfo.id // ); @@ -430,7 +430,9 @@ Page({ // ny.push(bb) // }) - + const videoInfo: any = this.data.videoInfo; + const batchList: any = this.data.batchList; + const selectionConList = this.data.selectionConList; const ny: any = selectionConList.map((m: any) => { const temp: any = m.temp.map((k: any) => { return { @@ -455,15 +457,18 @@ Page({ sid: videoInfo.sid, id: videoInfo.id, }; - const transferadRes: any = await httpRequest('/transferad', 'POST', params); - videoInfo.chackpay = 1; + // transferadRes: any + httpRequest('/transferad', 'POST', params).then(() => { + videoInfo.chackpay = 1; - this.setData({ - batchList: bk, - videoInfo: videoInfo, - selectionConList: ny + this.setData({ + batchList: bk, + videoInfo: videoInfo, + selectionConList: ny + }) }) + } else { tt.showToast({ title: '看完广告方可解锁', @@ -475,6 +480,9 @@ Page({ // 预加载资源 adBanner.load(); + this.setData({ + adBanner: adBanner, + }) } }, toPathVideoitself(ev: any) { @@ -532,9 +540,10 @@ Page({ // count: videoInfo?.count - 1, // isCount: this.handelCount(videoInfo?.count - 1) // } + const ic: any = videoInfo?.count - 1; videoInfo.bookcase = videoInfo?.bookcase == 1 ? 0 : 1; - videoInfo.count = videoInfo?.count - 1; - videoInfo.isCount = this.handelCount(videoInfo?.count - 1) + videoInfo.count = ic; + videoInfo.isCount = this.handelCount(ic) this.setData({ videoInfo: videoInfo }) diff --git a/utils/httpReques.ts b/utils/httpReques.ts index 0d7e335..0bf0dea 100644 --- a/utils/httpReques.ts +++ b/utils/httpReques.ts @@ -22,7 +22,7 @@ export const httpRequest = (url: string, method: any = 'GET', data: any = {}, he }, header: header, success: (res: any) => { - console.log(res,"pppppppp") + // console.log(res,"pppppppp") if (res.data.status == 1) { resolve(res.data); } else {