From 4a6b209eafbaab6d7ee5bc9dd461962410f57c24 Mon Sep 17 00:00:00 2001 From: Penny <2500338766@qq.com> Date: Sun, 28 May 2023 03:43:21 +0800 Subject: [PATCH] =?UTF-8?q?hotfix:=E4=BC=98=E5=8C=96=E6=B5=81=E9=87=8F?= =?UTF-8?q?=E4=B8=BB=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/ai/paint/loverPaint.vue | 11 +++--- pages/ai/paint/paint.vue | 13 +++---- pages/creator/imgDetail.vue | 52 +++++++++++++++------------ pages/userInfo/goldNum/goldNum.vue | 35 +++++++++++------- pages/userInfo/goldNum/goldNumLog.vue | 11 +++--- pages/userInfo/userInfo.vue | 23 ++++++------ pages/userInfo/vip/vip.vue | 11 +++--- utils/request.js | 17 +++++++-- 8 files changed, 103 insertions(+), 70 deletions(-) diff --git a/pages/ai/paint/loverPaint.vue b/pages/ai/paint/loverPaint.vue index 6b2090a..547f96b 100644 --- a/pages/ai/paint/loverPaint.vue +++ b/pages/ai/paint/loverPaint.vue @@ -160,12 +160,13 @@ } // this.paintStyle = res.data.data //console.log('this.paintStyle',this.paintStyle) - }else { - uni.showModal({ - content: '网络错误,请稍后再试~', - showCancel: false - }); } + // else { + // uni.showModal({ + // content: '网络错误,请稍后再试~', + // showCancel: false + // }); + // } }, //获取绘画风格 async getPaintStyleList() { diff --git a/pages/ai/paint/paint.vue b/pages/ai/paint/paint.vue index 4262786..5b16667 100644 --- a/pages/ai/paint/paint.vue +++ b/pages/ai/paint/paint.vue @@ -291,12 +291,13 @@ }, }); } - }else { - uni.showModal({ - content: '网络错误,请稍后再试~', - showCancel: false - }); - } + } + // else { + // uni.showModal({ + // content: '网络错误,请稍后再试~', + // showCancel: false + // }); + // } }); } else { this.advancedSetting = e.detail.value; diff --git a/pages/creator/imgDetail.vue b/pages/creator/imgDetail.vue index 5edab25..850baa8 100644 --- a/pages/creator/imgDetail.vue +++ b/pages/creator/imgDetail.vue @@ -76,13 +76,13 @@ var videoAd = null; likeColor: '#ef223c', collectColor: '#dcaa04', urlParamId: undefined, - isplayOver: false, + //isplayOver: false, downloadUrl: undefined, isVip: false, canDownloadNum: 0, //可下载图片次数 canRewardNum: 0, //可获取奖励次数 userInfo:{}, - adList:['0qfnoa4053uwkefbas','2v63zq5hvfclpxmurl','d4ltbnxa23zp2hhqwe'] //激励视频广告列表 + //adList:['0qfnoa4053uwkefbas','2v63zq5hvfclpxmurl','d4ltbnxa23zp2hhqwe'] //激励视频广告列表 } }, async onLoad(option){ @@ -93,11 +93,12 @@ var videoAd = null; } //如果是非会员才做如下操作 if(this.isVip === false){ - this.isplayOver = false; + //this.isplayOver = false; //随机选择一个激励视频广告初始化 - let num = Math.floor(Math.random() * this.adList.length + 1)-1; - console.log('随机激励视频id为:',this.adList[num]) - this.loadAdvertise(this.adList[num]); + //let num = Math.floor(Math.random() * this.adList.length + 1)-1; + //console.log('随机激励视频id为:',this.adList[num]) + // this.loadAdvertise(this.adList[num]); + this.loadAdvertise('0qfnoa4053uwkefbas'); } }, onShow() { @@ -106,7 +107,7 @@ var videoAd = null; onHide() { console.log('进入onHide') //切出小程序时,广告状态还原 - this.isplayOver = false; + //this.isplayOver = false; }, created() { const detailId = uni.getStorageSync('detailId') @@ -162,12 +163,13 @@ var videoAd = null; }else{ that.isVip = false; } - }else { - uni.showModal({ - content: '网络错误,请稍后再试~', - showCancel: false - }); } + // else { + // uni.showModal({ + // content: '网络错误,请稍后再试~', + // showCancel: false + // }); + // } }, //获取某平台用户当日下载奖励剩余次数 @@ -246,16 +248,23 @@ var videoAd = null; console.log('激励视频广告'+adId+'加载成功') }) videoAd.onError((err) => { + if(err.errCode == 1004){ + uni.showToast({ + icon: 'none', + title: '请稍后再试~' + }) + } that.err() }) videoAd.closeHandler = (res) =>{ + console.log('激励视频下图管理res',res) if (res && res.isEnded || res === undefined) { // 正常播放结束,可以下发游戏奖励 - that.isplayOver = true; + //that.isplayOver = true; //console.log('激励视频广告观看完毕',that.isplayOver) that.achieveSaveImg(); }else{ - that.isplayOver = false; + //that.isplayOver = false; uni.showToast({ title: '您还没有看完视频,无法下载图片', icon: 'none' @@ -542,7 +551,6 @@ var videoAd = null; const res = await insertOrUpdatePreAdProfit(params); if (res.data.code === 200) { console.log("写入广告收益成功!") - that.adResult = res.data.code; } else { uni.showToast({ title: '图片下载失败!', @@ -754,7 +762,7 @@ var videoAd = null; achieveSaveImg(){ let that = this; //console.log('广告状态',that.isplayOver) - if(that.isplayOver){ + // if(that.isplayOver){ //观看完广告,可下载图片 let url = that.downloadUrl; //console.log('that.downloadUrl观看完广告',that.downloadUrl); @@ -805,7 +813,7 @@ var videoAd = null; //下载成功写入下载收益、邀请收益 that.insertPreAdProfit(); that.insertPreInviteProfit(); - that.isplayOver = false; + //that.isplayOver = false; //重置已下载状态 that.isDownload = false; } @@ -882,7 +890,7 @@ var videoAd = null; //下载成功写入下载收益、邀请收益 that.insertPreAdProfit(); that.insertPreInviteProfit(); - that.isplayOver = false; + //that.isplayOver = false; //重置已下载状态 that.isDownload = false; } @@ -904,10 +912,10 @@ var videoAd = null; }); } }); - }else{ - //未观看完广告,不可下载图片 - console.log('未观看完广告,不可下载图片') - } + // }else{ + // //未观看完广告,不可下载图片 + // console.log('未观看完广告,不可下载图片') + // } }, // 下载 download(url) { diff --git a/pages/userInfo/goldNum/goldNum.vue b/pages/userInfo/goldNum/goldNum.vue index 5aa5f50..c173d03 100644 --- a/pages/userInfo/goldNum/goldNum.vue +++ b/pages/userInfo/goldNum/goldNum.vue @@ -19,16 +19,17 @@ var videoAd = null; import { signGetGold,watchAdGetGold,checkUserCanGetGold} from "@/api/paint.js"; import {getRestRewardNum} from "@/api/userInfo.js"; +import {loginTiktok} from '@/api/auth.js' export default { data() { return { userInfo: {}, noClick:true, //防止重复提交 - isplayOver: false, + //isplayOver: false, isWatch: false, canWatch: false, //false为可观看 canRewardNum: 0, - adList:['0qfnoa4053uwkefbas','2v63zq5hvfclpxmurl','d4ltbnxa23zp2hhqwe'] //激励视频广告列表 + //adList:['0qfnoa4053uwkefbas','2v63zq5hvfclpxmurl','d4ltbnxa23zp2hhqwe'] //激励视频广告列表 }; }, onShow() { @@ -38,14 +39,15 @@ export default { onHide() { console.log('进入onHide') //切出小程序时,广告状态还原 - this.isplayOver = false; + //this.isplayOver = false; }, onLoad() { - this.isplayOver = false; + //this.isplayOver = false; //随机选择一个激励视频广告初始化 - let num = Math.floor(Math.random() * this.adList.length + 1)-1; - console.log('随机激励视频id为:',this.adList[num]) - this.loadAdvertise(this.adList[num]); + // let num = Math.floor(Math.random() * this.adList.length + 1)-1; + // console.log('随机激励视频id为:',this.adList[num]) + // this.loadAdvertise(this.adList[num]); + this.loadAdvertise('d4ltbnxa23zp2hhqwe'); }, methods: { @@ -128,16 +130,23 @@ export default { console.log('激励视频广告'+adId+'加载成功') }) videoAd.onError((err) => { + if(err.errCode == 1004){ + uni.showToast({ + icon: 'none', + title: '请稍后再试~' + }) + } that.err() }) videoAd.closeHandler = (res) =>{ + console.log('激励视频领取画意值管理res',res) if (res && res.isEnded || res === undefined) { // 正常播放结束,可以下发游戏奖励 - that.isplayOver = true; + //that.isplayOver = true; //console.log('激励视频广告观看完毕',that.isplayOver) that.watchAdGetGold(); }else{ - that.isplayOver = false; + //that.isplayOver = false; uni.showToast({ title: '您还没有看完视频,无法下载图片', icon: 'none' @@ -164,9 +173,9 @@ export default { title: '画意值领取失败', content: '请稍后重试', showCancel: false, - complete: function() { - this.isplayOver = false; - } + // complete: function() { + // this.isplayOver = false; + // } }) }) }) @@ -204,7 +213,7 @@ export default { appType: 0 } const res = await watchAdGetGold(data); - console.log('观看广告结果===', res); + //console.log('观看广告结果===', res); if (res.data.code === 200) { return uni.showToast({ title: "画意值领取成功!", diff --git a/pages/userInfo/goldNum/goldNumLog.vue b/pages/userInfo/goldNum/goldNumLog.vue index 4915359..f4aced5 100644 --- a/pages/userInfo/goldNum/goldNumLog.vue +++ b/pages/userInfo/goldNum/goldNumLog.vue @@ -77,11 +77,12 @@ export default { this.loadStatus = 'more'; that.isLoadMore = false } - }else { - uni.showModal({ - content: '网络错误,请稍后再试~', - showCancel: false - }); + } + else { + // uni.showModal({ + // content: '网络错误,请稍后再试~', + // showCancel: false + // }); that.isLoadMore = false if(that.page > 1){ that.page -= 1 diff --git a/pages/userInfo/userInfo.vue b/pages/userInfo/userInfo.vue index 5e3ae41..a4abc1a 100644 --- a/pages/userInfo/userInfo.vue +++ b/pages/userInfo/userInfo.vue @@ -152,28 +152,29 @@ import UniIcons from "../../uni_modules/uni-icons/components/uni-icons/uni-icons }else{ that.isVip = false; } - }else { - uni.showModal({ - content: '网络错误,请稍后再试~', - showCancel: false - }); } + // else { + // uni.showModal({ + // content: '网络错误,请稍后再试~', + // showCancel: false + // }); + // } }, //获取画意值 async queryGoldNum(){ let that = this; const res = await queryGoldNum(that.userInfo.id); - console.log('goldRes===', res); if (res.data.code === 200) { that.goldNum = res.data.data; console.log(that.goldNum); - }else { - uni.showModal({ - content: '网络错误,请稍后再试~', - showCancel: false - }); } + // else { + // uni.showModal({ + // content: '网络错误,请稍后再试~', + // showCancel: false + // }); + // } }, async loginFunc(res, userInfo) { diff --git a/pages/userInfo/vip/vip.vue b/pages/userInfo/vip/vip.vue index 716e8b7..a068fdf 100644 --- a/pages/userInfo/vip/vip.vue +++ b/pages/userInfo/vip/vip.vue @@ -160,12 +160,13 @@ console.log('res===', res); if (res.data.code === 200) { that.vipInfo = res.data.data - }else { - uni.showModal({ - content: '网络错误,请稍后再试~', - showCancel: false - }); } + // else { + // uni.showModal({ + // content: '网络错误,请稍后再试~', + // showCancel: false + // }); + // } }, async getVipList() { diff --git a/utils/request.js b/utils/request.js index d3d5bc9..6b5bc41 100644 --- a/utils/request.js +++ b/utils/request.js @@ -148,14 +148,14 @@ service.interceptors.request.use( service.interceptors.response.use(res => { //未授权 if(res.data.code === 401){ + //清理缓存,解决一进入页面未登录但有头像的情况 + uni.clearStorage(); + uni.clearStorageSync(); uni.showModal({ title:'提示', content:'您还没有登录!点击确定跳转登录界面以体验服务', success(res) { if (res.confirm) { - //清理缓存,解决一进入页面未登录但有头像的情况 - uni.clearStorage(); - uni.clearStorageSync(); //跳转登录界面 uni.switchTab({ url: '/pages/userInfo/userInfo' @@ -168,10 +168,21 @@ service.interceptors.response.use(res => { } } }); + }else if(res.data.code != 200){ + //拦截响应,做统一处理 + uni.showToast({ + title: '网络错误,请稍后再试~', + icon:"none", + duration: 2000, + success() { + console.log('接口请求错误',res.data.msg) + } + }) }else{ return res; } }, error => { + console.log('触发了401error') if(error.response.status === 401){ refreshToken() //刷新token并重置token } else {