signin.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <template>
  2. <view>
  3. <view class="bg">
  4. <view class="view_order tn-flex align-center justify-between">
  5. <view class="tn-flex">
  6. <view class="mytimes tn-flex tn-flex-direction-column">
  7. <view>{{appInfo.number_alias?appInfo.number_alias:'点数'}}</view>
  8. <view class="view_mytimes">{{ userData.coin ? userData.coin : 0 }}</view>
  9. </view>
  10. <view v-if="appInfo.time_member && appInfo.time_member == 1" style="margin-left: 60rpx;"
  11. class="mytimes tn-flex tn-flex-direction-column">
  12. <view>会员时长</view>
  13. <view class="view_mytimes">{{ userData.is_validity == 1 ? userData.countdown : 0 }}</view>
  14. </view>
  15. </view>
  16. <navigator :url="isLogin ? '/pages/user/member/member' : '/pages/user/signin'" @click="getroute"
  17. class="shoppingmall">去充值</navigator>
  18. </view>
  19. </view>
  20. <view class="neck">每日{{appInfo.number_alias?appInfo.number_alias:'点数'}}领取</view>
  21. <view class="task-item flxe align-center justify-between">
  22. <view class="task-title">
  23. <view class="task-content">
  24. 签到领{{appInfo.number_alias?appInfo.number_alias:'点数'}}(今日{{ userData.sign_count_today ? userData.sign_count_today : 0 }}/1)
  25. </view>
  26. <view class="task-frequency">
  27. {{ plan.sign ? plan.sign : 0 }}{{appInfo.number_alias?appInfo.number_alias:'点数'}}/次
  28. </view>
  29. </view>
  30. <view v-if="userData.sign_count_today == 1" class="task-buttons">立即签到</view>
  31. <view v-else class="task-button" @click="memberaddCoin('sign')">立即签到</view>
  32. </view>
  33. <!-- #ifdef MP-WEIXIN -->
  34. <view class="task-item flxe align-center justify-between">
  35. <view class="task-title">
  36. <view class="task-content">
  37. 观看视频领{{appInfo.number_alias?appInfo.number_alias:'点数'}}(今日{{ userData.video_count_today ? userData.video_count_today : 0 }}/{{ plan.video_limit ? plan.video_limit : 0 }})
  38. </view>
  39. <view class="task-frequency">
  40. {{ plan.video ? plan.video : 0 }}{{appInfo.number_alias?appInfo.number_alias:'点数'}}/次
  41. </view>
  42. </view>
  43. <view v-if="userData.video_count_today == plan.video_limit" class="task-buttons">立即观看</view>
  44. <view v-else class="task-button" @click="showInterstitialAd">立即观看</view>
  45. </view>
  46. <!-- #endif -->
  47. <!-- #ifdef MP-WEIXIN -->
  48. <view class="task-item flxe align-center justify-between">
  49. <view class="task-title">
  50. <view class="task-content">
  51. 分享给好友领{{appInfo.number_alias?appInfo.number_alias:'点数'}}(今日{{ userData.share_count_today ? userData.share_count_today : 0 }}/{{ plan.share_limit ? plan.share_limit : 0 }})
  52. </view>
  53. <view class="task-frequency">
  54. {{ plan.share ? plan.share : 0 }}{{appInfo.number_alias?appInfo.number_alias:'点数'}}/次
  55. </view>
  56. </view>
  57. <block>
  58. <view v-if="userData.share_count_today == plan.share_limit" class="task-buttons">立即分享</view>
  59. <view v-else class="task-button">立即分享</view>
  60. </block>
  61. <button v-if="userData.share_count_today < plan.share_limit" class="share-button"
  62. open-type="share"></button>
  63. </view>
  64. <!-- #endif -->
  65. <!-- <block v-if="$platform.get() === 'wxOfficialAccount'">
  66. <view class="task-item flxe align-center justify-between">
  67. <view class="task-title">
  68. <view class="task-content">
  69. 分享给好友领{{appInfo.number_alias?appInfo.number_alias:'点数'}}(今日{{ userData.share_count_today ? userData.share_count_today : 0 }}/{{ plan.share_limit ? plan.share_limit : 0 }})
  70. </view>
  71. <view class="task-frequency">{{ plan.share ? plan.share : 0 }}{{appInfo.number_alias?appInfo.number_alias:'点数'}}/次</view>
  72. </view>
  73. <block>
  74. <view v-if="userData.share_count_today == plan.share_limit" class="task-buttons">立即分享</view>
  75. <view v-else @click="tabh5share" class="task-button">立即分享</view>
  76. </block>
  77. </view>
  78. </block> -->
  79. <!-- #ifdef MP-WEIXIN -->
  80. <view class="wxad" v-if="appInfo.wxad_index && appInfo.wxad_index >= 1">
  81. <view style="width: 100%;">
  82. <wike-flow-main :flowtype="appInfo.wxad_index" :banner_id="appInfo.banner_id"
  83. :video_banner_id="appInfo.video_banner_id" :native_id="appInfo.native_id"></wike-flow-main>
  84. </view>
  85. </view>
  86. <!-- #endif -->
  87. <!-- #ifdef H5 -->
  88. <u-popup :show="h5share" mode="center" @close="offh5share">
  89. <view class="cu-dialog">
  90. <image class="guide-img" src="http://shopro.7wpp.com/imgs/modal/share_guide.png" mode=""></image>
  91. </view>
  92. </u-popup>
  93. <!-- #endif -->
  94. <view class="wike_ad"><wike-ad></wike-ad></view>
  95. <u-gap height="100" bgColor="#f2f2f2"></u-gap>
  96. <wike-tabbar :onTabbar="true" :isShowAnimate="true"></wike-tabbar>
  97. </view>
  98. </template>
  99. <script>
  100. import {
  101. mapMutations,
  102. mapActions,
  103. mapState,
  104. mapGetters
  105. } from 'vuex';
  106. // #ifdef H5
  107. // import wxsdk from "@/common/wechat/sdk";
  108. // #endif
  109. let rewardedVideoAd = null;
  110. let interstitialAd = null,
  111. sharetime,
  112. timer,
  113. time2;
  114. export default {
  115. data() {
  116. return {
  117. plan: {},
  118. h5share: false,
  119. showshare: false
  120. };
  121. },
  122. computed: {
  123. ...mapGetters(['appInfo', 'userInfo', 'userData', 'isLogin'])
  124. },
  125. watch: {
  126. appInfo: function(e) {
  127. if (this.isLogin) {
  128. this.getUserData();
  129. }
  130. }
  131. },
  132. onReady() {
  133. let that = this;
  134. // #ifdef MP-WEIXIN
  135. clearTimeout(timer);
  136. // 在适合的场景显示插屏广告
  137. timer = setTimeout(function() {
  138. // 在页面onLoad回调事件中创建插屏广告实例
  139. if (wx.createInterstitialAd && that.appInfo.interstitial_status == 1) {
  140. interstitialAd = wx.createInterstitialAd({
  141. adUnitId: that.appInfo.interstitial_id
  142. });
  143. interstitialAd.onLoad(() => {});
  144. interstitialAd.onError(err => {});
  145. interstitialAd.onClose(() => {
  146. if (that.appInfo.interstitial_infinite_status == 1) {
  147. that.showInterstitial();
  148. }
  149. });
  150. interstitialAd.show().catch(err => {
  151. console.error(err);
  152. });
  153. }
  154. }, 4000);
  155. // #endif
  156. },
  157. onUnload() {
  158. clearInterval(time2);
  159. },
  160. onLoad() {
  161. console.log('123---111111111111111111111111111111111');
  162. // http("wechat.test", {
  163. // }).then(res => {
  164. // console.log('利用原请求封装轮播图返回值', res);
  165. // })
  166. this.getPlan();
  167. // #ifdef MP-WEIXIN
  168. if (wx.createRewardedVideoAd) {
  169. rewardedVideoAd = wx.createRewardedVideoAd({
  170. adUnitId: this.appInfo.video_id
  171. });
  172. rewardedVideoAd.onLoad(() => {
  173. // console.log('onLoad event emit')
  174. });
  175. rewardedVideoAd.onError(err => {
  176. // console.log('onError event emit', err)
  177. });
  178. rewardedVideoAd.onClose(res => {
  179. if (res && res.isEnded) {
  180. // 正常播放结束,可以下发游戏奖励
  181. // uni.showToast({
  182. // title: '次数 +' + this.plan.video
  183. // })
  184. this.memberaddCoin('video');
  185. } else {
  186. // 播放中途退出,不下发游戏奖励
  187. uni.showToast({
  188. title: this.appInfo.number_alias ? '看完视频后才可获得' + this.appInfo
  189. .number_alias + '奖励' : '看完视频后才可获得点数奖励',
  190. icon: 'none'
  191. });
  192. }
  193. });
  194. }
  195. // #endif
  196. },
  197. onShareAppMessage: function(res) {
  198. if (res.from === 'button') {
  199. // console.log('s');
  200. this.memberaddCoin('share');
  201. }
  202. return {
  203. title: this.appInfo.site_name,
  204. imageUrl: this.appInfo.share_img_path
  205. };
  206. },
  207. methods: {
  208. ...mapActions(['getUserData']),
  209. getPlan() {
  210. let that = this;
  211. this.$http('conf.getGroupConf', {
  212. group: 'system.plan'
  213. }).then(res => {
  214. if (res.code == 0) {
  215. this.plan = res.data;
  216. uni.setNavigationBarTitle({
  217. title: this.appInfo.site_name
  218. });
  219. }
  220. });
  221. },
  222. tabh5share() {
  223. this.h5share = true
  224. sharetime = setTimeout(() => {
  225. this.showshare = true
  226. // console.log(this.showshare,1);
  227. }, 3000);
  228. },
  229. offh5share() {
  230. this.h5share = false
  231. // console.log(this.showshare,2);
  232. if (this.showshare) {
  233. this.memberaddCoin('share');
  234. this.showshare = false
  235. } else {
  236. clearTimeout(sharetime)
  237. }
  238. },
  239. showInterstitialAd() {
  240. // rewardedVideoAd.show();
  241. if (rewardedVideoAd && this.appInfo.video_status == 1) {
  242. uni.showToast({
  243. title: '广告拉取中',
  244. icon: 'loading'
  245. });
  246. rewardedVideoAd.show().catch(() => {
  247. // 失败重试
  248. rewardedVideoAd
  249. .load()
  250. .then(() => rewardedVideoAd.show())
  251. .catch(err => {
  252. // console.log('激励视频 广告显示失败')
  253. uni.showToast({
  254. title: '广告显示失败',
  255. icon: 'none'
  256. });
  257. });
  258. });
  259. } else {
  260. uni.showToast({
  261. title: '广告显示错误',
  262. icon: 'none'
  263. });
  264. }
  265. },
  266. getroute() {
  267. if (!this.isLogin) {
  268. uni.setStorageSync('route', '/pages/signin/signin');
  269. }
  270. },
  271. memberaddCoin(e) {
  272. if (!this.isLogin) {
  273. uni.navigateTo({
  274. url: '/pages/user/signin'
  275. });
  276. uni.setStorageSync('route', '/pages/signin/signin');
  277. return;
  278. }
  279. this.$http('member.addCoin', {
  280. type: e
  281. }).then(res => {
  282. if (res.code === 0) {
  283. if (e == 'video') {
  284. uni.showToast({
  285. title: (this.appInfo.number_alias ? this.appInfo.number_alias +
  286. ' +' : '点数 +') + this.plan.video
  287. })
  288. }
  289. if (e == 'sign') {
  290. uni.showToast({
  291. title: (this.appInfo.number_alias ? this.appInfo.number_alias +
  292. ' +' : '点数 +') + this.plan.sign
  293. })
  294. }
  295. if (e == 'share') {
  296. setTimeout(() => {
  297. uni.showToast({
  298. title: (this.appInfo.number_alias ? this.appInfo
  299. .number_alias + ' +' : '点数 +') + this.plan
  300. .share
  301. })
  302. }, 1000)
  303. }
  304. this.getUserData();
  305. }
  306. });
  307. },
  308. showInterstitial() {
  309. time2 = setInterval(
  310. function() {
  311. interstitialAd.show().catch(err => {
  312. console.error(err);
  313. });
  314. },
  315. this.appInfo.gap ? this.appInfo.gap * 1000 : 12000
  316. );
  317. }
  318. }
  319. };
  320. </script>
  321. <style lang="scss">
  322. page {
  323. background: #f2f2f2;
  324. }
  325. view {
  326. box-sizing: border-box;
  327. }
  328. .bg {
  329. width: 100%;
  330. height: 200rpx;
  331. background: #26b3a0;
  332. // border-radius: 0 0 38rpx 38rpx;
  333. }
  334. .view_order {
  335. position: relative;
  336. top: 90rpx;
  337. padding: 30rpx;
  338. margin: 0 30rpx;
  339. // width: 100%;
  340. background: #fff;
  341. height: 200rpx;
  342. border-radius: 20rpx;
  343. .mytimes {
  344. color: #9e9e9e;
  345. font-size: 32rpx;
  346. .view_mytimes {
  347. color: #ffc107;
  348. font-size: 55rpx;
  349. font-weight: bold;
  350. // margin-top: 10rpx;
  351. }
  352. }
  353. .shoppingmall {
  354. background: #ffc107;
  355. color: #fff;
  356. border-radius: 50rpx;
  357. padding: 8rpx 28rpx;
  358. }
  359. }
  360. .neck {
  361. // margin: 30rpx;
  362. margin-left: 42rpx;
  363. font-size: 38rpx;
  364. font-weight: bold;
  365. margin-top: 150rpx;
  366. }
  367. .task-item {
  368. margin: 30rpx;
  369. padding: 30rpx;
  370. border-radius: 20rpx;
  371. background-color: #fff;
  372. // background-color: #F5FFFD;
  373. // box-shadow: 0px 0px 10px 5px #fff;
  374. .task-content {
  375. font-size: 16px;
  376. // font-weight: bold;
  377. margin-bottom: 12rpx;
  378. }
  379. .task-frequency {
  380. color: #f9ae3d;
  381. }
  382. .task-button {
  383. background: #26b3a0;
  384. color: #fff;
  385. padding: 12rpx 22rpx;
  386. font-size: 25rpx;
  387. border-radius: 30rpx;
  388. }
  389. .task-buttons {
  390. background: #9e9e9e;
  391. color: #fff;
  392. padding: 12rpx 22rpx;
  393. font-size: 25rpx;
  394. border-radius: 30rpx;
  395. }
  396. }
  397. .share-button {
  398. position: absolute;
  399. width: 70px;
  400. height: 28px;
  401. border-radius: 30rpx;
  402. right: 60rpx;
  403. opacity: 0;
  404. }
  405. .wike_ad {
  406. margin: 0 30rpx;
  407. }
  408. .wxad {
  409. border-radius: 20rpx;
  410. overflow: hidden;
  411. margin: 30rpx;
  412. }
  413. .cu-dialog {
  414. position: fixed;
  415. top: 60rpx;
  416. left: 100rpx;
  417. // background: #000000;
  418. }
  419. .guide-img {
  420. width: 580rpx;
  421. height: 430rpx;
  422. }
  423. </style>