index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <template>
  2. <view>
  3. <view class="bg">
  4. <image src="/static/icon/ad/bg.png" mode="widthFix"></image>
  5. </view>
  6. <view class="contents">
  7. <image class="contents-text" src="/static/icon/ad/wcrw.png" mode="widthFix"></image>
  8. <view class="daynum">
  9. <image class="contents-bg" src="/static/icon/ad/cjcs.png" mode="widthFix"></image>
  10. <view style="flex: 1;"></view>
  11. <text class="daynumtitle">今日奖励</text>
  12. <text class="daydraw">抽奖次数1次</text>
  13. <text class="todraw todraw1" v-if="taskStatus" @click="toChoujiang">去抽奖</text>
  14. <text class="todraw" v-else>去抽奖</text>
  15. </view>
  16. <view class="daytask">
  17. <view class="daytask-title">今日任务</view>
  18. <view class="daytask-line">
  19. <image src="/static/icon/ad/ad-video.png" mode="widthFix"></image>
  20. <view class="line-title">
  21. <view class="title1">观看视屏任务</view>
  22. <view class="title2">已观看{{ taskObj.watchCount }}/{{ taskObj.total }}</view>
  23. </view>
  24. <view style="flex: 1;"></view>
  25. <ad-rewarded-video v-if="taskStatus == false" :adpid="adpid" :loadnext="true"
  26. v-slot:default="{loading, error}" @load="onadload" @close="onadclose" @error="onaderror"
  27. :url-callback="callbackData">
  28. <!-- <view v-if="error">{{error}}</view> -->
  29. <!-- <u-button type="primary" style="width:100px;" size="mini" :disabled="loading" :loading="loading">去完成</u-button> -->
  30. <button :disabled="loading" :loading="loading" class="video-button">去完成</button>
  31. </ad-rewarded-video>
  32. </view>
  33. </view>
  34. </view>
  35. <!-- <view
  36. style="height:200px;background: #14a1ff;padding:10px;border-radius: 5px;display: flex; flex-direction: column;box-shadow: rgb(204, 204, 204) 0 0 7px 5px;">
  37. <view style="color:#fff;font-size:14px;flex:2;">今日奖励</view>
  38. <view style="color:#fff;flex:2;text-align: center;font-size: 20px;">抽奖次数1次</view>
  39. <view style="flex:1;">
  40. <view style="display: flex;justify-content: normal; justify-content: space-around;color:#fff;">
  41. <block v-if="taskStatus == false">
  42. <view>今日任务次数:{{taskObj.total}}</view>
  43. <view>当前已完成任务次数:{{taskObj.watchCount}}</view>
  44. </block>
  45. <block v-if="taskStatus">
  46. <u-button style="width:200px;" @click="toChoujiang">跳转抽奖</u-button>
  47. </block>
  48. </view>
  49. <u-line-progress active-color="#2979ff" :percent="progress"></u-line-progress>
  50. </view>
  51. </view>
  52. <view>
  53. <view style="font-size:20px;padding-top:20px;">
  54. <view style="display: flex;justify-content: space-between;align-items: center;">
  55. <view style="display: flex; align-items: center;">
  56. <u-image style="width:25px;" src="@/static/icon/ad.png" mode="widthFix"></u-image>
  57. <view style="margin-left:5px;">视频广告</view>
  58. </view>
  59. <view v-if="taskStatus">
  60. <u-button type="default">已完成</u-button>
  61. </view>
  62. </view>
  63. </view>
  64. </view> -->
  65. </view>
  66. </template>
  67. <script>
  68. import {
  69. mapState
  70. } from "vuex"
  71. export default {
  72. data() {
  73. return {
  74. adpid: '1372912966',
  75. appid: '',
  76. activityId: '1824703218157920256',
  77. taskObj: {},
  78. progress: 0,
  79. callbackData: {
  80. userId: "",
  81. extra: {}
  82. },
  83. error: "",
  84. taskStatus: false
  85. }
  86. },
  87. computed: {
  88. ...mapState(['userInfo', 'userCheckInfo']),
  89. },
  90. async onLoad() {
  91. this.refreshData();
  92. this.callbackData.userId = this.userInfo.sysUser.id
  93. },
  94. onShow() {
  95. },
  96. methods: {
  97. onadload(e) {},
  98. onCreateAd() {
  99. },
  100. onadclose(e) {
  101. const detail = e.detail
  102. // 用户点击了【关闭广告】按钮
  103. if (detail && detail.isEnded) {
  104. //重新拉取数据
  105. setTimeout(this.refreshData(), 3000);
  106. } else {
  107. // 播放中途退出
  108. console.log("onadclose " + detail.isEnded);
  109. }
  110. },
  111. onaderror(e) {
  112. // 广告加载失败
  113. // this.$refs.uToast.show({
  114. // title: '广告加载失败',
  115. // type: 'default',
  116. // })
  117. uni.showToast({
  118. icon: 'none',
  119. title: e.detail.errMsg
  120. })
  121. console.log("onaderror: ", e.detail);
  122. },
  123. refreshData() {
  124. console.log(this.userInfo)
  125. this.$http.post('https://marketing.baoxianzhanggui.com/api/advertising/getUserWatchCount', {
  126. userId: this.userInfo.sysUser.id
  127. }).then(res => {
  128. console.log(res)
  129. this.taskObj = res.data;
  130. this.progress = this.taskObj.watchCount / this.taskObj.total * 100
  131. this.taskStatus = res.data.total <= res.data.watchCount
  132. })
  133. },
  134. getErrorInfo() {
  135. console.log(this.error)
  136. },
  137. toChoujiang() {
  138. console.log('抽奖')
  139. plus.share.getServices(res => {
  140. let sweixin = null;
  141. sweixin = res.find(i => i.id === 'weixin')
  142. if (sweixin) {
  143. // 分享跳转到微信小程序
  144. sweixin.launchMiniProgram({
  145. id: "gh_71ff3b2409d8", //微信小程序原生id
  146. path: "pages/index/bigWheel/bigWheel?userId=" + this.userInfo.sysUser.id +
  147. "&activityId=" + this.activityId, // 打开小程序的页面路径,不传默认跳转首页
  148. type: 2 // 微信小程序版本类型,可取值: 0-正式版; 1-测试版; 2-体验版。 默认值为0。
  149. })
  150. } else {
  151. uni.showToast({
  152. title: '请安装微信',
  153. icon: 'none'
  154. })
  155. }
  156. }, err => {
  157. console.log("分享失败"); // 获取分享服务列表失败
  158. });
  159. uni.navigateToMiniProgram({
  160. appId: 'wx4014825e79c10552',
  161. path: 'pages/index/index?userId=' + this.userInfo.sysUser.id,
  162. extraData: {
  163. },
  164. success(res) {
  165. // 打开成功
  166. console.log(res)
  167. },
  168. error(error) {
  169. console.log(error)
  170. }
  171. })
  172. }
  173. }
  174. }
  175. </script>
  176. <style>
  177. page {
  178. background: #ffe9c6;
  179. }
  180. </style>
  181. <style lang="scss" scoped>
  182. .page {
  183. // background-color: #fff;
  184. margin: 30rpx;
  185. }
  186. // .video-button {
  187. // border: 1rpx solid var(--primary);
  188. // font-size: 30rpx;
  189. // line-height: 40rpx;
  190. // padding: 10rpx 14rpx;
  191. // color: var(--primary)
  192. // }
  193. .bg {
  194. position: fixed;
  195. top: 0;
  196. left: 0;
  197. z-index: 0;
  198. width: 750rpx;
  199. }
  200. .contents {
  201. position: relative;
  202. padding: 30rpx;
  203. box-sizing: border-box;
  204. .contents-text {
  205. width: 394rpx;
  206. position: absolute;
  207. top: 60rpx;
  208. left: 20rpx;
  209. }
  210. .daynum {
  211. position: relative;
  212. height: 808rpx;
  213. width: 100%;
  214. display: flex;
  215. flex-direction: column;
  216. align-items: center;
  217. justify-content: end;
  218. text {
  219. position: relative;
  220. }
  221. .contents-bg {
  222. position: absolute;
  223. top: 0;
  224. left: 0;
  225. width: 100%;
  226. }
  227. .daynumtitle {
  228. margin-bottom: 28rpx;
  229. font-size: 32rpx;
  230. color: #333;
  231. }
  232. .daydraw {
  233. width: 398rpx;
  234. height: 74rpx;
  235. background: linear-gradient(266deg, rgba(255, 255, 255, 0) 0%, rgba(255, 94, 39, 0.1) 100%);
  236. border-radius: 38rpx;
  237. border: 1rpx solid #FFC5B0;
  238. margin-bottom: 150rpx;
  239. text-align: center;
  240. line-height: 70rpx;
  241. color: #8F3A21;
  242. font-weight: 800;
  243. }
  244. .todraw {
  245. width: 334rpx;
  246. height: 72rpx;
  247. background: #CCCCCC;
  248. border-radius: 38rpx;
  249. border: 5rpx solid #EFEFEF;
  250. text-align: center;
  251. line-height: 64rpx;
  252. color: #FFF;
  253. font-size: 36rpx;
  254. margin-bottom: 54rpx;
  255. }
  256. .todraw1 {
  257. background: linear-gradient(180deg, #fffbf4 0%, #ffe1a1 100%);
  258. color: #8F3A21;
  259. border: 5rpx solid #ffe8ad;
  260. }
  261. }
  262. .daytask {
  263. padding: 30rpx;
  264. background: #FFF;
  265. margin-top: 40rpx;
  266. border-radius: 22rpx;
  267. .daytask-title {
  268. font-size: 32rpx;
  269. color: 333;
  270. margin-bottom: 20rpx;
  271. }
  272. .daytask-line {
  273. display: flex;
  274. justify-content: space-between;
  275. align-items: center;
  276. .line-title {
  277. margin-left: 30rpx;
  278. .title1 {
  279. color: #333;
  280. font-size: 28rpx;
  281. }
  282. .title2 {
  283. color: #969696;
  284. font-size: 24rpx;
  285. }
  286. }
  287. .video-button {
  288. background: linear-gradient(359deg, #FF4A13 0%, #FF8851 100%), #D8D8D8;
  289. height: 60rpx;
  290. line-height: 60rpx;
  291. color: #FFF;
  292. font-size: 26rpx;
  293. border-radius: 30rpx;
  294. padding: 0 30rpx;
  295. }
  296. }
  297. image {
  298. width: 48rpx;
  299. }
  300. }
  301. }
  302. </style>