index.vue 1.3 KB

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