index.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <view class="main">
  3. <guide v-if="guidePages" :advData="advData"></guide>
  4. <view class="" v-else></view>
  5. </view>
  6. </template>
  7. <script>
  8. import guide from '@/components/guide/index.vue'
  9. import Cache from '@/utils/cache';
  10. import {
  11. getOpenAdv
  12. } from '@/api/api.js'
  13. export default {
  14. components: {
  15. guide
  16. },
  17. data() {
  18. return {
  19. guidePages: false,
  20. advData: []
  21. }
  22. },
  23. onShow() {
  24. // #ifdef H5
  25. if(this.$wechat.isWeixin()){
  26. this.$wechat.wechat();
  27. }
  28. // #endif
  29. this.loadExecution()
  30. },
  31. methods: {
  32. loadExecution() {
  33. const tagDate = uni.getStorageSync('guideDate') || '',
  34. nowDate = new Date().toLocaleDateString();
  35. if (tagDate === nowDate) {
  36. uni.switchTab({
  37. url: '/pages/index/index'
  38. });
  39. return
  40. }
  41. console.log(new Date().getTime(),'start')
  42. getOpenAdv().then(res => {
  43. if (res.data.status == 0 || res.data.value.length == 0) {
  44. uni.switchTab({
  45. url: '/pages/index/index'
  46. });
  47. console.log(new Date().getTime(),'indexend')
  48. } else if (res.data.status && (res.data.value.length || res.data.video_link)) {
  49. this.advData = res.data
  50. uni.setStorageSync('guideDate', new Date().toLocaleDateString());
  51. this.guidePages = true
  52. console.log(new Date().getTime(),'end')
  53. }
  54. }).catch(err => {
  55. uni.switchTab({
  56. url: '/pages/index/index'
  57. });
  58. })
  59. }
  60. },
  61. onHide() {
  62. this.guidePages = false
  63. }
  64. }
  65. </script>
  66. <style>
  67. page,
  68. .main {
  69. width: 100%;
  70. height: 100%;
  71. }
  72. </style>