signin.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. <template>
  2. <view>
  3. <view style="color: #000000;">
  4. <tn-nav-bar backgroundColor="#ffffff" :bottomShadow="false">每日任务</tn-nav-bar>
  5. <view :style="{height: tobheight+'px'}"></view>
  6. </view>
  7. <!-- <view style="color: #fff;z-index: 99999999;position: relative;">
  8. <tn-nav-bar :bottomShadow="false" backgroundColor="#207CF7">数智员工</tn-nav-bar>
  9. <view :style="{height: tobheight+'px'}"></view>
  10. </view> -->
  11. <view class="topbg u-flex align-center justify-center">
  12. <view v-if="appInfo.time_member && appInfo.time_member == 1" class="u-flex package">会员套餐:<view>
  13. {{ userData.is_validity == 1 ? (userData.vip_time == 9999?'永久':userData.countdown): 0 }}
  14. </view>天
  15. </view>
  16. <view class="u-flex drop">{{appInfo.number_alias?appInfo.number_alias:'点数'}}:<view>
  17. {{ userData.coin ? userData.coin : 0 }}
  18. </view>(vip内限量次数大于0不消耗)</view>
  19. </view>
  20. <view class="topbg1"></view>
  21. <view class="daily_view" style="margin: -38px 15px 15px;">
  22. <view class="daily_neck">每日{{appInfo.number_alias?appInfo.number_alias:'点数'}}领取</view>
  23. <view v-if="plan.sign>0" class="task-item flxe align-center justify-between"
  24. style="padding: 30rpx 0 0;margin: 0;">
  25. <view class="task-title">
  26. <view class="task-content">
  27. 签到领{{appInfo.number_alias?appInfo.number_alias:'点数'}}(今日{{ userData.sign_count_today ? userData.sign_count_today : 0 }}/1)
  28. </view>
  29. <view class="task-frequency">
  30. {{ plan.sign ? plan.sign : 0 }}{{appInfo.number_alias?appInfo.number_alias:'点数'}}/次
  31. </view>
  32. </view>
  33. <view v-if="userData.sign_count_today == 1" class="task-buttons">立即签到</view>
  34. <view v-else class="task-button" @click="memberaddCoin('sign')">立即签到</view>
  35. </view>
  36. <!-- #ifdef MP-WEIXIN -->
  37. <view v-if="plan.video>0" class="task-item flxe align-center justify-between"
  38. style="padding: 30rpx 0 0;margin: 0;">
  39. <view class="task-title">
  40. <view class="task-content">
  41. 观看视频领{{appInfo.number_alias?appInfo.number_alias:'点数'}}(今日{{ userData.video_count_today ? userData.video_count_today : 0 }}/{{ plan.video_limit ? plan.video_limit : 0 }})
  42. </view>
  43. <view class="task-frequency">
  44. {{ plan.video ? plan.video : 0 }}{{appInfo.number_alias?appInfo.number_alias:'点数'}}/次
  45. </view>
  46. </view>
  47. <view v-if="userData.video_count_today == plan.video_limit" class="task-buttons">立即观看</view>
  48. <view v-else class="task-button" @click="showInterstitialAd">立即观看</view>
  49. </view>
  50. <!-- #endif -->
  51. <!-- #ifdef MP-WEIXIN -->
  52. <view v-if="plan.share>0" class="task-item flxe align-center justify-between"
  53. style="padding: 30rpx 0 0 0;margin: 0;">
  54. <view class="task-title">
  55. <view class="task-content">
  56. 分享给好友领{{appInfo.number_alias?appInfo.number_alias:'点数'}}(今日{{ userData.share_count_today ? userData.share_count_today : 0 }}/{{ plan.share_limit ? plan.share_limit : 0 }})
  57. </view>
  58. <view class="task-frequency">
  59. {{ plan.share ? plan.share : 0 }}{{appInfo.number_alias?appInfo.number_alias:'点数'}}/次
  60. </view>
  61. </view>
  62. <block>
  63. <view v-if="userData.share_count_today == plan.share_limit" class="task-buttons">立即分享</view>
  64. <view v-else class="task-button">立即分享</view>
  65. </block>
  66. <button v-if="userData.share_count_today < plan.share_limit" class="share-button"
  67. open-type="share"></button>
  68. </view>
  69. <!-- #endif -->
  70. </view>
  71. <view v-if="list.length>0" class="daily_view">
  72. <view class="daily_neck">购买{{appInfo.number_alias?appInfo.number_alias:'点数'}}</view>
  73. <view class="number">
  74. <view class="list">
  75. <view :class="num == index ? 'item real' : 'item'" v-for="(item, index) in list" :key="index"
  76. @click="num = index">
  77. <view class="card">
  78. <view class="top">
  79. <text>{{ item.coin }}</text>
  80. <image src="/static/images/buy.png"></image>
  81. </view>
  82. <text class="money">{{ item.price }}元</text>
  83. </view>
  84. <view v-if="item.is_preferential === 1" class="recommend">
  85. <text>限时特价</text>
  86. </view>
  87. </view>
  88. </view>
  89. <view @click="buy" class="sure">
  90. <text>立即充值</text>
  91. </view>
  92. <view @click="buyMember" class="sure1">
  93. <text class="buyTxt">购买会员套餐</text>
  94. </view>
  95. </view>
  96. </view>
  97. <!-- #ifdef MP-WEIXIN -->
  98. <view class="wxad" v-if="appInfo.wxad_index && appInfo.wxad_index >= 1">
  99. <view style="width: 100%;">
  100. <wike-flow-main :flowtype="appInfo.wxad_index" :banner_id="appInfo.banner_id"
  101. :video_banner_id="appInfo.video_banner_id" :native_id="appInfo.native_id"></wike-flow-main>
  102. </view>
  103. </view>
  104. <!-- #endif -->
  105. <!-- #ifdef H5 -->
  106. <u-popup :show="h5share" mode="center" @close="offh5share">
  107. <view class="cu-dialog">
  108. <image class="guide-img" src="http://shopro.7wpp.com/imgs/modal/share_guide.png" mode=""></image>
  109. </view>
  110. </u-popup>
  111. <!-- #endif -->
  112. <view class="wike_ad"><wike-ad></wike-ad></view>
  113. <u-gap height="100" bgColor="#f2f2f2"></u-gap>
  114. <!-- <wike-tabbar2 :currTabIndex='3' v-if="appInfo.page_template == 3" :is_aipainting="appInfo.is_aipainting"
  115. :onTabbar="true" :isShowAnimate="true" :appInfos="appInfo.page_template"></wike-tabbar2>
  116. <wike-tabbar :currTabIndex='3' v-else :onTabbar="true" :is_aipainting="appInfo.is_aipainting"
  117. :isShowAnimate="true" :appInfos="appInfo.page_template"></wike-tabbar> -->
  118. <wike-modal-qrcode :qrcode="gzhqrcode" :showconcern="showconcern"
  119. @concernclose="concernclose"></wike-modal-qrcode>
  120. <u-modal @cancel="handleCancel" @confirm="handleConfirm" cancelText='退出登录' showCancelButton :show="showFixInfo"
  121. confirmColor="#26b3a0" confirmText="完善信息" title="请完善个人手机号信息后使用本应用"
  122. content='您已充值,但未绑定手机号,请完善信息以方便为您提供进一步的服务'></u-modal>
  123. </view>
  124. </template>
  125. <script>
  126. import {
  127. mapMutations,
  128. mapActions,
  129. mapState,
  130. mapGetters
  131. } from 'vuex';
  132. import ShoproPay from '@/common/pay';
  133. // #ifdef H5
  134. // import wxsdk from "@/common/wechat/sdk";
  135. // #endif
  136. let rewardedVideoAd = null;
  137. let interstitialAd = null,
  138. sharetime,
  139. timer,
  140. time2;
  141. export default {
  142. data() {
  143. return {
  144. tobheight: 45,
  145. plan: {},
  146. h5share: false,
  147. showshare: false,
  148. showconcern: false,
  149. gzhqrcode: '',
  150. show_ios_pay: false,
  151. device: this.$platform.device(),
  152. num: 0,
  153. list: [
  154. ],
  155. showFixInfo: false,
  156. };
  157. },
  158. computed: {
  159. ...mapGetters(['appInfo', 'userInfo', 'userData', 'isLogin'])
  160. },
  161. onReady() {
  162. let that = this;
  163. // #ifdef MP-WEIXIN
  164. clearTimeout(timer);
  165. // 在适合的场景显示插屏广告
  166. timer = setTimeout(function() {
  167. // 在页面onLoad回调事件中创建插屏广告实例
  168. if (wx.createInterstitialAd && that.appInfo.interstitial_status == 1) {
  169. interstitialAd = wx.createInterstitialAd({
  170. adUnitId: that.appInfo.interstitial_id
  171. });
  172. interstitialAd.onLoad(() => {});
  173. interstitialAd.onError(err => {});
  174. interstitialAd.onClose(() => {
  175. if (that.appInfo.interstitial_infinite_status && that.appInfo
  176. .interstitial_infinite_status == 1) {
  177. that.showInterstitial();
  178. } else {
  179. interstitialAd.show().catch(err => {
  180. console.error(err);
  181. });
  182. }
  183. });
  184. interstitialAd.show().catch(err => {
  185. console.error(err);
  186. });
  187. }
  188. }, 4000);
  189. // #endif
  190. },
  191. onUnload() {
  192. clearInterval(time2);
  193. },
  194. onLoad() {
  195. this.getPlan();
  196. // #ifdef MP-WEIXIN
  197. if (wx.createRewardedVideoAd) {
  198. rewardedVideoAd = wx.createRewardedVideoAd({
  199. adUnitId: this.appInfo.video_id
  200. });
  201. rewardedVideoAd.onLoad(() => {});
  202. rewardedVideoAd.onError(err => {});
  203. rewardedVideoAd.onClose(res => {
  204. if (res && res.isEnded) {
  205. // 正常播放结束,可以下发游戏奖励
  206. this.memberaddCoin('video');
  207. } else {
  208. // 播放中途退出,不下发游戏奖励
  209. uni.showToast({
  210. title: this.appInfo.number_alias ? '看完视频后才可获得' + this.appInfo.number_alias +
  211. '奖励' : '看完视频后才可获得点数奖励',
  212. icon: 'none'
  213. });
  214. }
  215. });
  216. }
  217. // #endif
  218. },
  219. onShow() {
  220. this.$http('user.info').then(res => {
  221. if (res.code == 0) {
  222. console.log('用户是否是首次支付成功,但未填写手机号', res.data.is_new);
  223. this.showFixInfo = res.data.is_new;
  224. // this.showFixInfo = true;
  225. }
  226. })
  227. this.systemwechat()
  228. this.getUserData();
  229. },
  230. onShareAppMessage: function(res) {
  231. if (res.from === 'button') {
  232. this.memberaddCoin('share');
  233. }
  234. return {
  235. title: this.appInfo.site_name,
  236. imageUrl: this.appInfo.share_img_path
  237. };
  238. },
  239. methods: {
  240. ...mapActions(['getUserInfo', 'showAuthModal', 'getUserData', 'logout']),
  241. handleCancel() {
  242. this.showFixInfo = false
  243. this.logout()
  244. // uni.clearStorage()
  245. uni.reLaunch({
  246. url: '/pages/user/signin'
  247. })
  248. },
  249. handleConfirm() {
  250. uni.navigateTo({
  251. url: '/pages/user/userinfo?isNewUser=true'
  252. })
  253. },
  254. buyMember() {
  255. uni.navigateTo({
  256. url: '/pages/user/member/member?id=2'
  257. })
  258. },
  259. getPlan() {
  260. let that = this;
  261. this.$http('conf.getGroupConf', {
  262. group: 'system.plan'
  263. }).then(res => {
  264. if (res.code == 0) {
  265. this.plan = res.data;
  266. this.memberlist()
  267. if (res.data.is_ios_pay == 1 && that.checkTimeLimit()) {
  268. // ios可以付钱
  269. that.show_ios_pay = true
  270. }
  271. uni.setNavigationBarTitle({
  272. title: this.appInfo.site_name
  273. });
  274. }
  275. });
  276. },
  277. buy() {
  278. let that = this;
  279. if (!that.isLogin) {
  280. uni.navigateTo({
  281. url: '/pages/user/signin'
  282. });
  283. uni.setStorageSync('route', '/pages/signin/signin');
  284. return;
  285. }
  286. that.$http('order.create', {
  287. pay_type: 'wechat',
  288. link_id: that.list[that.num].id
  289. }).then(res => {
  290. if (res.code === 0) {
  291. if (that.userInfo.openid_miniapp || that.userInfo.openid_wechat) {
  292. let pay = new ShoproPay('wechat', res.data, 2);
  293. console.log('发起微信支付的参数:', res.data);
  294. } else {
  295. // console.log(res.data);
  296. that.paytest(res.data.order_number, res.data.id)
  297. }
  298. } else {
  299. that.$u.toast(res.msg);
  300. }
  301. });
  302. },
  303. paytest(e, id) {
  304. uni.showLoading({
  305. title: '支付跳转中...'
  306. })
  307. let uniacid = uni.getStorageSync("uniacid") || "";
  308. this.$http('pay.hupijiaopay', {
  309. order_number: e,
  310. is_commission: 0,
  311. return_url: window.location.href.split('/h5')[0] +
  312. '/h5/pages/user/public/paymentdetail?uniacid=' + uniacid + '&orderType=2&orderId=' + id,
  313. callback_url: window.location.href,
  314. }).then(res => {
  315. // console.log(res);
  316. if (res.code === 0) {
  317. // console.log(res.data);
  318. window.location.href = res.data.url
  319. // uni.navigateTo({
  320. // url:'pages/user/public/webview?url='+res.data.url
  321. // })
  322. } else {
  323. this.$u.toast(res.msg);
  324. }
  325. });
  326. },
  327. memberlist() {
  328. // console.log(i);
  329. var that = this;
  330. this.$http('member.list').then(res => {
  331. if (res.code == 0) {
  332. // #ifdef MP-WEIXIN
  333. if (this.device != 'ios') {
  334. this.list = res.data
  335. } else if (this.device == 'ios' && this.show_ios_pay) {
  336. this.list = res.data
  337. } else {
  338. this.list = []
  339. }
  340. // #endif
  341. // #ifdef H5
  342. this.list = res.data
  343. // #endif
  344. }
  345. });
  346. },
  347. checkTimeLimit() {
  348. if (this.plan.open_period == 1) {
  349. return true;
  350. } else {
  351. if (this.time_range('8:00', '20:00')) {
  352. return false;
  353. } else {
  354. return true;
  355. }
  356. }
  357. },
  358. systemwechat() {
  359. this.$http('conf.getGroupConf', {
  360. group: 'system.wechat'
  361. }).then(res => {
  362. if (res.code == 0) {
  363. this.gzhqrcode = res.data.qrcode_path
  364. const focuson = uni.getStorageSync('focuson');
  365. // console.log(focuson);
  366. if (!focuson) {
  367. if (this.gzhqrcode) {
  368. if (this.isLogin && this.appInfo.is_show_logged_qrcode == 1) {
  369. this.showconcern = true
  370. }
  371. }
  372. }
  373. }
  374. })
  375. },
  376. concernclose() {
  377. this.showconcern = false
  378. },
  379. tabh5share() {
  380. this.h5share = true
  381. sharetime = setTimeout(() => {
  382. this.showshare = true
  383. // console.log(this.showshare,1);
  384. }, 3000);
  385. },
  386. offh5share() {
  387. this.h5share = false
  388. // console.log(this.showshare,2);
  389. if (this.showshare) {
  390. this.memberaddCoin('share');
  391. this.showshare = false
  392. } else {
  393. clearTimeout(sharetime)
  394. }
  395. },
  396. showInterstitialAd() {
  397. // rewardedVideoAd.show();
  398. if (rewardedVideoAd && this.appInfo.video_status == 1) {
  399. uni.showToast({
  400. title: '广告拉取中',
  401. icon: 'loading'
  402. });
  403. rewardedVideoAd.show().catch(() => {
  404. // 失败重试
  405. rewardedVideoAd
  406. .load()
  407. .then(() => rewardedVideoAd.show())
  408. .catch(err => {
  409. uni.showToast({
  410. title: '广告显示失败',
  411. icon: 'none'
  412. });
  413. });
  414. });
  415. } else {
  416. uni.showToast({
  417. title: '广告显示错误',
  418. icon: 'none'
  419. });
  420. }
  421. },
  422. getroute() {
  423. if (!this.isLogin) {
  424. uni.setStorageSync('route', '/pages/signin/signin');
  425. }
  426. },
  427. memberaddCoin(e) {
  428. if (!this.isLogin) {
  429. uni.navigateTo({
  430. url: '/pages/user/signin'
  431. });
  432. uni.setStorageSync('route', '/pages/signin/signin');
  433. return;
  434. }
  435. this.$http('member.addCoin', {
  436. type: e
  437. }).then(res => {
  438. if (res.code === 0) {
  439. if (e == 'video') {
  440. uni.showToast({
  441. title: (this.appInfo.number_alias ? this.appInfo.number_alias + ' +' :
  442. '点数 +') + this.plan.video
  443. })
  444. }
  445. if (e == 'sign') {
  446. uni.showToast({
  447. title: (this.appInfo.number_alias ? this.appInfo.number_alias + ' +' :
  448. '点数 +') + this.plan.sign
  449. })
  450. }
  451. if (e == 'share') {
  452. setTimeout(() => {
  453. uni.showToast({
  454. title: (this.appInfo.number_alias ? this.appInfo.number_alias +
  455. ' +' : '点数 +') + this.plan.share
  456. })
  457. }, 1000)
  458. }
  459. this.getUserData();
  460. }
  461. });
  462. },
  463. showInterstitial() {
  464. time2 = setInterval(
  465. function() {
  466. interstitialAd.show().catch(err => {
  467. console.error(err);
  468. });
  469. },
  470. this.appInfo.gap ? this.appInfo.gap * 1000 : 12000
  471. );
  472. }
  473. }
  474. };
  475. </script>
  476. <style lang="scss" scoped>
  477. @import './signin.scss';
  478. </style>