signin.vue 14 KB

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