ren.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <view class="content">
  3. <view class="top-bg">
  4. </view>
  5. <view class="top-wrap">
  6. <view class="tit">
  7. ·我的收益
  8. </view>
  9. <view class="val">
  10. {{userInfo.points || 0}}
  11. </view>
  12. <view class="">
  13. 累计收益
  14. </view>
  15. </view>
  16. <view class="gg-wrap flex" v-for="(item,index) in ggInfo.day_video_count" v-if="!isError">
  17. <image src="../../static/icon/jiang.png" mode=""></image>
  18. <view class="gg-tit">
  19. <view class="tit">
  20. 观看视频赚阅读积分
  21. </view>
  22. <view class="">
  23. 观看可获得阅读积分
  24. </view>
  25. </view>
  26. <view class="gg-btn pass" v-if="ggInfo.valid_bcount*1 > index">
  27. 已观看
  28. </view>
  29. <template v-if="ggInfo.valid_bcount < 3 && ggInfo.valid_bcount == index">
  30. <ad-rewarded-video adpid="1480651769" :loadnext="true" v-slot:default="{loading, error}"
  31. @load="onadload" @close="onadclose" @error="onaderror">
  32. <view class="gg-btn">
  33. 去观看
  34. </view>
  35. </ad-rewarded-video>
  36. </template>
  37. <!-- <view class="gg-btn pass" v-if="gInfo.valid_bcount*1 =< index">
  38. 去观看1
  39. </view> -->
  40. </view>
  41. <view class="gg-wrap flex" v-for="(item,index) in ggInfo.day_video_count" v-if="isError">
  42. <image src="../../static/icon/jiang.png" mode=""></image>
  43. <view class="gg-tit">
  44. <view class="tit">
  45. 观看视频赚阅读积分
  46. </view>
  47. <view class="">
  48. 观看可获得阅读积分
  49. </view>
  50. </view>
  51. <view class="gg-btn" :class="{pass: ggInfo.valid_bcount*1 > index}"
  52. @click="ggInfo.valid_bcount*1 > index? '': goLock(index)">
  53. {{ggInfo.valid_bcount*1 > index? '已观看': '去观看'}}
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script>
  59. import {
  60. mapState,
  61. mapMutations
  62. } from 'vuex';
  63. import {
  64. getGG,
  65. createGG,
  66. ggGive
  67. } from '@/api/zero.js'
  68. import {
  69. getUserInfo,
  70. getLevelList
  71. } from '@/api/user.js';
  72. export default {
  73. data() {
  74. return {
  75. isError: false,
  76. ggInfo: {},
  77. id: 0,
  78. error: '',
  79. isLoading: false,
  80. }
  81. },
  82. computed: {
  83. ...mapState('user', ['userInfo', 'hasLogin'])
  84. },
  85. onLoad(opt) {
  86. this.id = opt.id
  87. },
  88. onShow() {
  89. this.loadBaseData()
  90. this.getGG()
  91. },
  92. onReachBottom() {
  93. },
  94. onReady() {
  95. },
  96. methods: {
  97. ...mapMutations('user', ['setUserInfo']),
  98. onadload(e) {
  99. console.log('广告数据加载成功',e);
  100. let that = this
  101. },
  102. onadclose(e) {
  103. let that = this
  104. const detail = e.detail
  105. // 用户点击了【关闭广告】按钮
  106. console.log('用户点击了【关闭广告】按钮')
  107. if (detail && detail.isEnded) {
  108. // 正常播放结束
  109. console.log("正常播放结束onadclose ", detail, detail.isEnded);
  110. createGG({
  111. ad_id: 0
  112. }).then(res => {
  113. ggGive({
  114. id: res.data.id
  115. }).then(ress => {
  116. that.loadBaseData()
  117. uni.showToast({
  118. title: '奖励发放成功',
  119. duration: 2000
  120. });
  121. that.getGG()
  122. })
  123. })
  124. } else {
  125. // 播放中途退出
  126. console.log("播放中途退出onadclose ", detail, detail.isEnded);
  127. }
  128. },
  129. onaderror(e) {
  130. // 广告加载失败
  131. console.log("onaderror: ", e.detail);
  132. this.isError = true
  133. // this.$api.msg(e.detail.errMsg)
  134. },
  135. loadBaseData() {
  136. const obj = this
  137. getUserInfo({})
  138. .then(({
  139. data
  140. }) => {
  141. obj.setUserInfo(data);
  142. // obj.getLevelList()
  143. })
  144. .catch(e => {
  145. console.log(e);
  146. });
  147. },
  148. getGG() {
  149. getGG().then(res => {
  150. console.log(res)
  151. this.ggInfo = res.data
  152. })
  153. },
  154. goLock() {
  155. createGG({
  156. ad_id: 0
  157. }).then(res => {
  158. uni.navigateTo({
  159. url:'/pages/zero/gg?id=' + res.data.id
  160. })
  161. })
  162. }
  163. }
  164. }
  165. </script>
  166. <style lang="scss" scoped>
  167. .top-bg {
  168. height: 210rpx;
  169. background-color: #f53935;
  170. }
  171. .top-wrap {
  172. width: 684rpx;
  173. height: 254rpx;
  174. background: linear-gradient(-70deg, #FF6362, #FF9465);
  175. box-shadow: 0rpx 11rpx 17rpx 4rpx rgba(255, 76, 76, 0.1);
  176. border-radius: 16rpx;
  177. margin: -180rpx auto 20rpx;
  178. text-align: center;
  179. font-size: 20rpx;
  180. font-weight: 500;
  181. color: #fff;
  182. padding: 30rpx;
  183. .tit {
  184. text-align: left;
  185. font-size: 28rpx;
  186. padding: 10rpx 0;
  187. }
  188. .val {
  189. padding-bottom: 15rpx;
  190. font-size: 80rpx;
  191. font-weight: bold;
  192. }
  193. }
  194. .gg-wrap {
  195. width: 660rpx;
  196. height: 140rpx;
  197. background: #FEFEFE;
  198. box-shadow: 0rpx 0rpx 29rpx 0rpx rgba(231, 71, 68, 0.09);
  199. border-radius: 4rpx;
  200. margin: 20rpx auto;
  201. padding: 30rpx 40rpx 40rpx 90rpx;
  202. position: relative;
  203. image {
  204. position: absolute;
  205. top: 0;
  206. left: 26rpx;
  207. width: 45rpx;
  208. height: 60rpx;
  209. }
  210. .gg-tit {
  211. font-size: 24rpx;
  212. font-weight: 500;
  213. color: #999999;
  214. .tit {
  215. padding-bottom: 20rpx;
  216. font-size: 32rpx;
  217. font-weight: bold;
  218. color: #333333;
  219. }
  220. }
  221. .gg-btn {
  222. width: 125rpx;
  223. height: 46rpx;
  224. background: linear-gradient(60deg, #FF8F3B, #FF3106);
  225. border-radius: 23rpx;
  226. font-size: 24rpx;
  227. font-weight: 500;
  228. color: #FFFFFF;
  229. text-align: center;
  230. line-height: 45rpx;
  231. }
  232. }
  233. .pass {
  234. background: #999 !important;
  235. }
  236. </style>