diff --git a/me/invite/cashDetail.vue b/me/invite/cashDetail.vue index cfd8b15..abdeca6 100644 --- a/me/invite/cashDetail.vue +++ b/me/invite/cashDetail.vue @@ -48,9 +48,9 @@ --> - - 提现 + {{!isWithdraw?'观看广告提现':'立即提现'}} @@ -114,6 +114,12 @@ + + + + {{error}} + @@ -173,6 +179,10 @@ limit: 10, totalCount: 0, cashMoney: 0, + urlCallback: null, + adRewardedVideo: true, + adRewardedVideoloadNum: 0, + isWithdraw: false, }; }, onLoad() { @@ -202,8 +212,84 @@ onNavigationBarButtonTap() { // this.list(); }, + onReady() { + this.$nextTick(()=>{ + this.adRewardedVideoloadNum = 0 + this.$refs.adRewardedVideo.load(); + }) + this.getCanCash() + }, methods: { - //规则弹窗 + /** + * 获取看广告状态 + */ + getCanCash() { + this.$Request.getT('app/cash/canCash').then(res => { + console.log(res) + if (res.code == 0) { + this.isWithdraw = res.data; + } else { + this.isWithdraw = false; + } + }) + }, + /** + * 广告数据加载成功回调 + * @param {Object} e + */ + onadload(e) { + this.adRewardedVideo = true; + console.log('广告数据加载成功'); + }, + + /** + * 广告加载失败回调 + * @param {Object} e + */ + onaderror(e) { + if ( this.adRewardedVideoloadNum >=3 ) { + this.adRewardedVideo = false; + return + } + this.adRewardedVideoloadNum++ + setTimeout(() => { + this.$refs.adRewardedVideo.load(); + }, 1000); // 10 + console.log("广告加载失败") + }, + + /** + * 广告播放成功回调 + * @param {Object} e + */ + async onadclose(e) { + const detail = e.detail + if (detail && detail.isEnded) { + // 正常播放结束 + let res = await this.$Request.getT('app/ad/state', { + extraKey: this.urlCallback.extra + }) + this.getCanCash() + } else { + // 播放中途退出 + } + }, + withdraw() { + + if ( !this.isWithdraw ) { + this.urlCallback = { + userId: uni.getStorageSync('userId'), + extra: 'cash:'+uni.getStorageSync('userId') + "" + new Date().getTime(), + } + this.$refs.adRewardedVideo.show(); + } else { + this.getOut() + } + + }, + /** + * 规则弹窗打开 + */ showRule(){ this.ruleShow=true }, @@ -223,6 +309,10 @@ setAllMoney() { this.money = Math.floor(this.mayMoney * 100) / 100 }, + + /** + * 获取提现记录 + */ getMoneyDetail() { let that = this; let token = uni.getStorageSync('token') @@ -260,46 +350,50 @@ }); }, - // 可提现金额 + + /** + * 可提现金额 + */ getcashMoney() { let data = { page: this.page, limit: this.limit } - // this.$u.api.myPurseDet(data).then(res => { - // if (res.code == 0) { - // this.mayMoney = res.data.inviteMoney.money - // } else { - // uni.showToast({ - // title: res.msg, - // duration: 1000, - // icon: 'none' - // }); - // } - // }) + this.$Request.getT('app/moneyDetails/selectUserMoney').then(res => { if (res.code == 0) { this.mayMoney = res.data.amount || 0 } }) }, - // 提现记录 + + /** + * 提现记录 + */ gojilu() { uni.navigateTo({ url: '/me/invite/cashList' }); }, - //钱包明细 + + /** + * 红包明细 + */ goqianbao() { uni.navigateTo({ url: '/me/invite/moneyList?moneyType=1&viewType=2' }); }, + + /** + * 绑定支付宝 + */ goZhifuBao() { uni.navigateTo({ url: '/me/invite/zhifubao' }); }, + getMoney() { let that = this; let token = that.token @@ -345,10 +439,7 @@ }) } }, - //校验用户输入金额 - checkMobile(money) { - return RegExp(/^1[34578]\d{9}$/).test(money); - }, + getOut() { let that = this; let token = that.token