index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <view class="main">
  3. <guide v-if="guidePages" :advData="advData"></guide>
  4. </view>
  5. </template>
  6. <script>
  7. // +----------------------------------------------------------------------
  8. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  9. // +----------------------------------------------------------------------
  10. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  11. // +----------------------------------------------------------------------
  12. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  13. // +----------------------------------------------------------------------
  14. // | Author: CRMEB Team <admin@crmeb.com>
  15. // +----------------------------------------------------------------------
  16. import guide from '@/components/guide/index.vue'
  17. import Cache from '@/utils/cache';
  18. import { setStorage } from '@/libs/uniApi.js';
  19. import {
  20. getOpenAdv
  21. } from '@/api/api.js'
  22. export default {
  23. components: {
  24. guide
  25. },
  26. data() {
  27. return {
  28. guidePages: false,
  29. frequency: '',
  30. advData: []
  31. }
  32. },
  33. onLoad(options) {
  34. if(options.spid)setStorage('spid', options.spid);
  35. },
  36. onShow() {
  37. // #ifdef H5
  38. if(this.$wechat.isWeixin()){
  39. this.$wechat.wechat();
  40. }
  41. // #endif
  42. this.loadExecution()
  43. },
  44. methods: {
  45. loadExecution() {
  46. getOpenAdv().then(res => {
  47. this.frequency = res.data.config.open_screen_space
  48. const tagDate = uni.getStorageSync('guideDate') || '',
  49. nowDate = new Date();
  50. if(tagDate >= nowDate && res.data.config.open_screen_space!=0){
  51. uni.switchTab({
  52. url: '/pages/index/index'
  53. });
  54. return
  55. }else{
  56. if (res.data.config.open_screen_switch == "" || res.data.list.length == 0) {
  57. uni.switchTab({
  58. url: '/pages/index/index'
  59. });
  60. } else if (res.data.config.open_screen_switch && res.data.list.length) {
  61. this.advData = res.data
  62. let curTime = new Date(), addHour = curTime.setHours(curTime.getHours()+res.data.config.open_screen_space);
  63. uni.setStorageSync('guideDate', new Date(addHour))
  64. this.guidePages = true
  65. }
  66. }
  67. }).catch(err => {
  68. uni.switchTab({
  69. url: '/pages/index/index'
  70. });
  71. })
  72. }
  73. },
  74. onHide() {
  75. this.guidePages = false
  76. }
  77. }
  78. </script>
  79. <style>
  80. page,
  81. .main {
  82. width: 100%;
  83. height: 100%;
  84. }
  85. </style>