video.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. // pages/video/video.js
  2. import {
  3. getVideoList,
  4. getTemplateConfig,
  5. getUuid, userLogin
  6. } from '../../api/api'
  7. import {
  8. rnd,
  9. deepCopy,
  10. goToBookDetail,
  11. goToVideoDetail, SendEvent
  12. } from '../../utils/util'
  13. import {
  14. apple
  15. } from '../../config/config'
  16. const app = getApp()
  17. let interstitialAd = null
  18. Page({
  19. data: {
  20. videoList: [],
  21. originVideoList: [],
  22. loading: false,
  23. hasMore: true,
  24. page: 1,
  25. size: 10,
  26. // 状态栏高度
  27. statusBarHeight: 20,
  28. navHeight: 64, // 导航栏高度 = 状态栏 + 44
  29. navStyle: '',
  30. listStyle: '',
  31. // 添加防抖时间戳
  32. lastLoadTime: 0,
  33. ads: null,
  34. globalConfig: null,
  35. // 视频分类列表
  36. categoryList: [],
  37. // 当前选中的分类ID
  38. currentCategoryId: null,
  39. share_count: 1,
  40. hasLoadAdConfig: false,
  41. templateAdId: '',
  42. adErrorField: {
  43. videoError: false,
  44. bannerError: false,
  45. templateError: false
  46. },
  47. },
  48. onLoad(options) {
  49. console.log('打开视频页面--------------------------')
  50. wx.setStorageSync('jump', parseInt(options.jump)) // 是否跳转阅读器
  51. if (!app.globalData.uuid) {
  52. this.getUUID().then(uuid => {
  53. // getApp().globalData.uuid = uuid
  54. console.log('登录成功')
  55. })
  56. }
  57. this.handleEntrace(options);
  58. this.setData({
  59. templateAdId: apple.ads.templateAdId,
  60. hasLoadAdConfig: true
  61. })
  62. this.interstitalLoad()
  63. getTemplateConfig({
  64. box_type: 67,
  65. uuid: app.globalData.uuid
  66. }).then(res => {
  67. this.setData({
  68. globalConfig: res.globalConfig
  69. });
  70. app.globalData.ads_config = res.globalConfig;
  71. // 获取视频分类
  72. this.getVideoCategories()
  73. })
  74. // 获取状态栏高度
  75. this.getSystemInfo()
  76. // this.handleEntrace(options);
  77. },
  78. onShow() {
  79. console.log('页面显示--------------------------')
  80. this.rewardVideoLoad()
  81. // 每次显示页面时刷新列表
  82. if (this.data.videoList.length === 0) {
  83. this.setData({
  84. page: 1
  85. })
  86. // this.loadVideoList()
  87. }
  88. // 获取当前页面的参数
  89. const pages = getCurrentPages();
  90. const currentPage = pages[pages.length - 1];
  91. const options = currentPage.options;
  92. const jump = parseInt(options.jump); // 是否跳转阅读器 1-不跳转
  93. const scene = wx.getStorageSync('scene');
  94. console.log('scene场景值:', scene);
  95. console.log('jump阅读器:', jump);
  96. console.log('shared_video_id:', options.shared_video_id);
  97. console.log('share_count:', options.share_count);
  98. console.log('isEnterVideoDetail:', app.globalData.isEnterVideoDetail);
  99. if (options.shared_video_id) {
  100. // 处理分享进入的情况
  101. if (!app.globalData.isEnterVideoDetail) {
  102. // 延迟跳转,确保列表页已经加载完成
  103. setTimeout(() => {
  104. wx.navigateTo({
  105. url: `/pages/video/detail?id=${options.shared_video_id}&title=${options.title || ''}&tag_id=${options.tag_id || ''}`,
  106. fail: (err) => {
  107. console.error('跳转到视频详情页失败:', err);
  108. wx.showToast({
  109. title: '打开视频失败',
  110. icon: 'none'
  111. });
  112. }
  113. });
  114. }, 500);
  115. } else {
  116. // 第二次进入把isEnterVideoDetail恢复默认值
  117. app.globalData.isEnterVideoDetail = true;
  118. }
  119. }
  120. // if (options.shared_video_id) {
  121. // if (+options.share_count === 1 && this.data.share_count === 1) {
  122. // this.setData({
  123. // share_count: 2
  124. // });
  125. // console.log('share_count1:', this.data.share_count)
  126. // if (jump === 1) {
  127. // console.log('jump为1直接跳转到视频详情页')
  128. // // 延迟跳转
  129. // setTimeout(() => {
  130. // this.goToVideoDetail(options.shared_video_id, options.tag_id)
  131. // }, 500);
  132. // } else {
  133. // if (scene === 1007 || scene === 1008) {
  134. // console.log('scene为1007或1008且jump不为1,跳转到书详情页')
  135. // this.goToBookDetail();
  136. // } else {
  137. // console.log('scene不为1007,1008且jump不为1,跳转到视频详情页')
  138. // // 延迟跳转
  139. // setTimeout(() => {
  140. // this.goToVideoDetail(options.shared_video_id, options.tag_id)
  141. // }, 500);
  142. // }
  143. // }
  144. // // if ((scene === 1007 || scene === 1008) && jump != 1) {
  145. // // this.goToBookDetail();
  146. // // } else {
  147. // // this.goToVideoDetail(options.shared_video_id, options.tag_id);
  148. // // }
  149. // // this.goToBookDetail();
  150. // } else if (+options.share_count === 1 && this.data.share_count === 2) {
  151. // this.setData({
  152. // share_count: 3
  153. // });
  154. // console.log('share_count2:', this.data.share_count)
  155. // // 延迟跳转,确保列表页已经加载完成
  156. // setTimeout(() => {
  157. // wx.navigateTo({
  158. // url: `/pages/video/detail?id=${options.shared_video_id}&title=${options.title || ''}&tag_id=${options.tag_id || ''}`,
  159. // fail: (err) => {
  160. // console.error('跳转到视频详情页失败:', err);
  161. // wx.showToast({
  162. // title: '打开视频失败',
  163. // icon: 'none'
  164. // });
  165. // }
  166. // });
  167. // }, 500);
  168. // }
  169. // }
  170. },
  171. handleEntrace(options) {
  172. console.log('点击入口按钮')
  173. if (!options || Object.keys(options).length === 0) {
  174. return
  175. }
  176. console.log('入口:', options)
  177. try {
  178. let { type, jump, shared_video_id, tag_id } = options
  179. const scene = wx.getStorageSync('scene');
  180. console.log('入口:', type, jump, scene, shared_video_id)
  181. if ((type === 'share' || type === 'tuiguang') && shared_video_id) {
  182. if (jump === "1") {
  183. console.log('jump为1直接跳转到视频详情页')
  184. // 延迟跳转,确保列表页已经加载完成
  185. setTimeout(() => {
  186. this.goToVideoDetail(shared_video_id, tag_id)
  187. }, 500);
  188. } else {
  189. if (scene === 1007 || scene === 1008) {
  190. console.log('scene为1007或1008且jump不为1,跳转到书详情页')
  191. // 延迟跳转,确保列表页已经加载完成
  192. setTimeout(() => {
  193. this.goToBookDetail()
  194. }, 500);
  195. } else {
  196. console.log('scene不为1007,1008且jump不为1,跳转到视频详情页')
  197. // 延迟跳转,确保列表页已经加载完成
  198. setTimeout(() => {
  199. this.goToVideoDetail(shared_video_id, tag_id)
  200. }, 500);
  201. }
  202. }
  203. }
  204. } catch (e) {
  205. console.log('处理不同场景进入小程序出错', error)
  206. }
  207. },
  208. onTabItemTap(item) {
  209. console.log(item.index)
  210. setTimeout(() => {
  211. this.interstitalPlayFn()
  212. }, 1000)
  213. },
  214. // 插屏广告加载
  215. interstitalLoad() {
  216. let adId = apple.ads.insertAdId
  217. interstitialAd = wx.createInterstitialAd({
  218. adUnitId: adId
  219. })
  220. interstitialAd.onLoad(() => {
  221. console.log('视频页插屏广告onLoad')
  222. })
  223. interstitialAd.onError((err) => {
  224. console.log('视频页插屏广告onError', err)
  225. })
  226. interstitialAd.onClose(() => {
  227. console.log('视频页插屏广告onClose')
  228. })
  229. },
  230. // 插屏广告展示
  231. interstitalPlayFn() {
  232. if (interstitialAd) {
  233. interstitialAd.show().catch((err) => {
  234. console.error(err)
  235. })
  236. }
  237. },
  238. /**
  239. * 获取uuid
  240. */
  241. getUUID() {
  242. return new Promise((resolve, reject) => {
  243. wx.login({
  244. success: res => {
  245. console.log('wxlogin:', res);
  246. let body = {
  247. code: res.code,
  248. source_type: 1,
  249. source_id: ''
  250. }
  251. getUuid(body).then(async uuidres => {
  252. console.log('登录成功:', uuidres);
  253. app.globalData.uuid = uuidres.uuid;
  254. app.globalData.openId = uuidres.open_id;
  255. // 直接从视频链接进入,同时登录IAA小说用户
  256. // userLogin({
  257. // "appid": apple.appid,
  258. // "channel": 1,
  259. // "srcType": "0",
  260. // "srcAppId": "",
  261. // "srcId": "",
  262. // "cusId": "",
  263. // "inviter": "",
  264. // "promotionId": "",
  265. // "inviterPromotionId": "",
  266. // "system": "pc",
  267. // "type": "inner",
  268. // "inner": 1,
  269. // code: res.code,
  270. // }).then(logres => {
  271. // console.log('userLogin', logres);
  272. // wx.setStorageSync('accessToken', logres.accessToken);
  273. // app.globalData.isLogin = true;
  274. // app.globalData.userCode = logres.userCode;
  275. // app.globalData.openId = logres.openId;
  276. // app.globalData.unionId = logres.unionId;
  277. // console.log('登录成功', app.globalData)
  278. // resolve(logres);
  279. // }).catch(err => {
  280. // app.globalData.isLogin = false;
  281. // reject(err);
  282. // })
  283. console.log('登录后的openid:', uuidres.open_id)
  284. console.log('登录成功:', app.globalData)
  285. SendEvent('login_shanhu', { "uuid": uuidres.uuid });
  286. resolve(res.uuid)
  287. }).catch((err) => {
  288. reject(err)
  289. })
  290. }
  291. })
  292. })
  293. },
  294. // 获取系统信息
  295. getSystemInfo() {
  296. const systemInfo = wx.getSystemInfoSync()
  297. const statusBarHeight = systemInfo.statusBarHeight
  298. const navHeight = statusBarHeight + 44
  299. this.setData({
  300. statusBarHeight: statusBarHeight,
  301. navHeight: navHeight,
  302. navStyle: `height:${navHeight}px`,
  303. listStyle: `top:${navHeight}px`
  304. })
  305. },
  306. // 获取视频分类
  307. getVideoCategories() {
  308. console.log('getVideoCategories', this.data.globalConfig)
  309. // 筛选出type=1的视频分类
  310. const videoCategories = this.data.globalConfig.categoryList.filter(item => item.type === 1)
  311. console.log('videoCategories', videoCategories)
  312. if (videoCategories.length > 0) {
  313. // 设置分类列表和默认选中的分类
  314. this.setData({
  315. categoryList: videoCategories,
  316. currentCategoryId: videoCategories[0].id
  317. })
  318. // 加载第一个分类的视频列表
  319. this.loadVideoList()
  320. } else {
  321. console.error('未找到视频分类')
  322. wx.showToast({
  323. title: '未找到视频分类',
  324. icon: 'none'
  325. })
  326. }
  327. },
  328. // 切换分类
  329. switchCategory(e) {
  330. const categoryId = e.currentTarget.dataset.id
  331. if (categoryId === this.data.currentCategoryId) return
  332. this.setData({
  333. currentCategoryId: categoryId,
  334. page: 1,
  335. videoList: [],
  336. originVideoList: [],
  337. hasMore: true
  338. })
  339. this.loadVideoList()
  340. },
  341. // 加载视频列表
  342. async loadVideoList() {
  343. if (this.data.loading) return
  344. this.setData({
  345. loading: true
  346. })
  347. try {
  348. const params = {
  349. page: this.data.page,
  350. size: this.data.size,
  351. tag_id: this.data.currentCategoryId,
  352. // 如果不是第一页,传递最后一个视频的ID作为next_id
  353. next_id: this.data.page > 1 && this.data.videoList.length > 0 ?
  354. this.data.videoList[this.data.videoList.length - 1].id :
  355. ""
  356. }
  357. let videoList = []
  358. try {
  359. videoList = await getVideoList(params)
  360. if (!Array.isArray(videoList)) {
  361. throw new Error('返回数据格式错误')
  362. }
  363. videoList = videoList.map(item => ({
  364. ...item,
  365. views: rnd(1, 10),
  366. favors: rnd(5000, 10000),
  367. adType: "video",
  368. lock: false
  369. }))
  370. this.data.originVideoList = this.data.originVideoList.concat(videoList)
  371. this.data.videoList = this.formatVideoAdList(deepCopy(this.data.originVideoList))
  372. } catch (apiError) {
  373. console.error('API调用失败:', apiError)
  374. throw apiError
  375. }
  376. // 如果是第一页,直接替换数据
  377. if (this.data.page === 1) {
  378. this.setData({
  379. videoList: this.data.videoList,
  380. originVideoList: this.data.originVideoList,
  381. loading: false,
  382. hasMore: videoList.length >= this.data.size
  383. })
  384. } else {
  385. // 否则追加数据
  386. this.setData({
  387. videoList: this.data.videoList,
  388. originVideoList: this.data.originVideoList,
  389. loading: false,
  390. hasMore: videoList.length >= this.data.size
  391. })
  392. }
  393. } catch (error) {
  394. console.error('加载视频列表失败:', error)
  395. }
  396. },
  397. /* ------------------ 广告相关 ----------------- */
  398. /**
  399. * 标记广告位置
  400. * @param {} arr
  401. * @returns
  402. */
  403. formatVideoAdList(arr) {
  404. // 原生广告间隔,激励广告间隔
  405. let templateGap = 0,
  406. rewardGap = 0
  407. console.log(this.data.globalConfig)
  408. if (this.data.globalConfig.isHomeTemplateAd === 1) {
  409. templateGap = this.data.globalConfig.homeTemplateAdInterval
  410. } else {
  411. templateGap = 0
  412. }
  413. if (this.data.globalConfig.isHomeRewardAd) {
  414. rewardGap = this.data.globalConfig.homeRewardAdInterval
  415. } else {
  416. rewardGap = 0
  417. }
  418. console.log('原生间隔templateGap', templateGap, '激励间隔rewardGap', rewardGap)
  419. // 第二个固定是原生广告
  420. let result = [arr.shift(), {
  421. adType: 'templateAd'
  422. }]
  423. // 辅助计算间隔变量
  424. let markIndex = 0
  425. let templateAdFlag = true
  426. let rewardAdFlag = true
  427. do {
  428. markIndex += 1
  429. if (templateGap > 0) {
  430. if (templateAdFlag && markIndex - 1 === templateGap) {
  431. markIndex = 0
  432. result.push({
  433. adType: "templateAd"
  434. })
  435. templateAdFlag = false
  436. rewardAdFlag = true
  437. continue
  438. }
  439. } else {
  440. rewardAdFlag = true
  441. }
  442. if (rewardGap > 0) {
  443. if (rewardAdFlag && markIndex - 1 === rewardGap) {
  444. markIndex = 0
  445. templateAdFlag = true
  446. rewardAdFlag = false
  447. let rewardItem = arr.shift()
  448. rewardItem.lock = true
  449. result.push(rewardItem)
  450. console.log("标记激励项:", rewardItem)
  451. continue
  452. }
  453. } else {
  454. templateAdFlag = true
  455. }
  456. result.push(arr.shift())
  457. } while (arr.length > 0);
  458. return result;
  459. },
  460. // 加载更多
  461. loadMore() {
  462. console.log("触发loadMore")
  463. console.log("当前状态:", {
  464. loading: this.data.loading,
  465. hasMore: this.data.hasMore,
  466. page: this.data.page,
  467. videoListLength: this.data.videoList.length
  468. })
  469. // 添加防抖,避免频繁触发
  470. const now = Date.now()
  471. if (now - this.data.lastLoadTime < 500) {
  472. console.log("防抖触发,跳过本次加载")
  473. return
  474. }
  475. if (this.data.hasMore && !this.data.loading) {
  476. console.log("开始加载更多数据")
  477. this.setData({
  478. page: this.data.page + 1,
  479. lastLoadTime: now
  480. })
  481. this.loadVideoList()
  482. } else {
  483. console.log("不满足加载条件:", {
  484. hasMore: this.data.hasMore,
  485. loading: this.data.loading
  486. })
  487. }
  488. },
  489. // 刷新列表
  490. refreshList() {
  491. wx.showLoading({
  492. title: '刷新中...',
  493. })
  494. this.setData({
  495. page: 1,
  496. videoList: [],
  497. hasMore: true
  498. })
  499. this.loadVideoList().then(() => {
  500. wx.hideLoading()
  501. wx.showToast({
  502. title: '刷新成功',
  503. icon: 'success',
  504. duration: 1500
  505. })
  506. }).catch(() => {
  507. wx.hideLoading()
  508. })
  509. },
  510. // 点击视频
  511. onVideoTap(e) {
  512. const { id, info, index } = e.currentTarget.dataset;
  513. console.log(id, info, index, '视频详情')
  514. if (!info) {
  515. wx.hideLoading();
  516. wx.showToast({
  517. title: '视频数据错误',
  518. icon: 'none'
  519. });
  520. return;
  521. }
  522. SendEvent('click_video_tab_video', { "video_id": id, "tag_id": info.tag_ids[0], "uuid": app.globalData.uuid })
  523. const encodedTitle = encodeURIComponent(info.title || '');
  524. this.unlockUrl = `/pages/video/detail?id=${id}&title=${encodedTitle}&tag_id=${info.tag_ids[0]}`
  525. if (!info.lock) {
  526. // 显示加载中提示
  527. wx.showLoading({
  528. title: '加载中...',
  529. mask: true
  530. });
  531. // 跳转到视频详情页
  532. wx.navigateTo({
  533. url: this.unlockUrl,
  534. success: () => {
  535. wx.hideLoading();
  536. },
  537. fail: (err) => {
  538. console.error('跳转失败:', err);
  539. wx.hideLoading();
  540. wx.showToast({
  541. title: '跳转失败',
  542. icon: 'none'
  543. });
  544. }
  545. });
  546. } else {
  547. this.reawrdVideoIndex = index
  548. this.rewardVideo = info
  549. this.rewardVideoPlayFn()
  550. }
  551. },
  552. // 下拉刷新
  553. onPullDownRefresh() {
  554. this.setData({
  555. page: 1,
  556. videoList: []
  557. })
  558. this.loadVideoList().then(() => {
  559. wx.stopPullDownRefresh()
  560. })
  561. },
  562. // 分享按钮点击事件
  563. onShareTap(e) {
  564. // 阻止事件冒泡
  565. e.stopPropagation();
  566. // SendEvent('click_list_share', {"video_id": video.id, "tag_id": video.tag_ids[0]});
  567. },
  568. // 分享给朋友
  569. onShareAppMessage(e) {
  570. const video = e.target.dataset.video
  571. if (!video) return {}
  572. const jump = wx.getStorageSync('jump');// 是否跳转阅读器
  573. let url = '';
  574. url = `/pages/video/video?shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}&share_count=1`;
  575. if (jump === 1) {
  576. url += '&jump=1';
  577. }
  578. SendEvent('click_list_share', { "video_id": video.id, "tag_id": video.tag_ids[0], "uuid": app.globalData.uuid });
  579. return {
  580. title: video.title,
  581. path: url,
  582. imageUrl: video.cover_image,
  583. success: function (res) {
  584. wx.showToast({
  585. title: '分享成功',
  586. icon: 'success',
  587. duration: 1500
  588. })
  589. },
  590. fail: function (res) {
  591. wx.showToast({
  592. title: '分享失败',
  593. icon: 'none',
  594. duration: 1500
  595. })
  596. }
  597. }
  598. },
  599. // 分享到朋友圈
  600. onShareTimeline(e) {
  601. const video = e.target.dataset.video
  602. if (!video) return {}
  603. const jump = wx.getStorageSync('jump');// 是否跳转阅读器
  604. let url = '';
  605. url = `shared_video_id=${video.id}&title=${encodeURIComponent(video.title)}&tag_id=${video.tag_ids[0]}&share_count=1`;
  606. SendEvent('click_list_share', { "video_id": video.id, "tag_id": video.tag_ids[0], "uuid": app.globalData.uuid });
  607. if (jump === 1) {
  608. url += '&jump=1';
  609. }
  610. return {
  611. title: video.title,
  612. query: url,
  613. imageUrl: video.cover_image
  614. }
  615. },
  616. // 跳转到书籍详情
  617. goToBookDetail() {
  618. getApp().globalData.isShowDialog = true
  619. // 使用公共的goToBookDetail函数
  620. goToBookDetail({
  621. bookId: 7266,
  622. wxBookId: 'A1Hcfv456vGtMYxQjxUm8KNdJ8',
  623. chapterId: null
  624. });
  625. },
  626. // 跳转视频详情
  627. goToVideoDetail(videoId, tagId) {
  628. // 使用公共的goToVideoDetail函数
  629. goToVideoDetail({
  630. videoId: videoId,
  631. tagId: tagId
  632. });
  633. },
  634. // 激励视频加载
  635. rewardVideoLoad() {
  636. if (wx.createRewardedVideoAd) {
  637. let adId = apple.ads.rewardAdId
  638. let that = this
  639. this.videoAd = wx.createRewardedVideoAd({
  640. adUnitId: adId
  641. })
  642. this.videoAd.onLoad(() => {
  643. console.log('首页激励加载成功')
  644. })
  645. this.videoAd.onError((err) => {
  646. console.log('首页激励失败', err)
  647. })
  648. this.videoAd.onClose((res) => {
  649. // 用户点击了【关闭广告】按钮
  650. this.setData({
  651. isLoadingVideo: false
  652. })
  653. if (res && res.isEnded) {
  654. // 发放奖励
  655. that.setData({
  656. [`videoList[${that.reawrdVideoIndex}].lock`]: false
  657. })
  658. console.log('发放奖励跳转')
  659. wx.navigateTo({
  660. url: `${that.unlockUrl}`
  661. })
  662. }
  663. })
  664. }
  665. },
  666. // 激励视频展示
  667. rewardVideoPlayFn() {
  668. wx.showLoading({
  669. title: '解锁视频中',
  670. })
  671. this.videoAd.show().then(() => {
  672. console.log('激励视频播放成功')
  673. }).catch((err) => {
  674. console.log('激励视频播放失败', err)
  675. this.setData({
  676. [`videoList[${that.reawrdVideoIndex}].lock`]: false
  677. })
  678. wx.navigateTo({
  679. url: `${this.unlockUrl}`
  680. })
  681. }).then(() => {
  682. wx.hideLoading()
  683. })
  684. },
  685. // 统一小程序广告加载成功
  686. appletsAdLoad(e) {
  687. let _target = e.currentTarget.dataset
  688. this.setData({
  689. [`adErrorField.${_target.field}`]: false
  690. })
  691. },
  692. // 统一小程序广告加载失败
  693. appletsAdError(e) {
  694. let _target = e.currentTarget.dataset
  695. this.setData({
  696. [`adErrorField.${_target.field}`]: true
  697. })
  698. console.error(_target.name, '错误', e)
  699. },
  700. // 统一小程序广告关闭
  701. appletsAdClose(e) {
  702. let _target = e.currentTarget.dataset
  703. },
  704. // 统一小程序广告点击
  705. appletsAdClick(e) {
  706. let _target = e.currentTarget.dataset
  707. },
  708. })