index.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <view class="main">
  3. <guide v-if="guidePages" :advData="advData"></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. // #ifdef H5
  24. if(this.$wechat.isWeixin()){
  25. this.$wechat.wechat();
  26. }
  27. // #endif
  28. this.loadExecution()
  29. },
  30. methods: {
  31. loadExecution() {
  32. const tagDate = uni.getStorageSync('guideDate') || '',
  33. nowDate = new Date().toLocaleDateString();
  34. if (tagDate === nowDate) {
  35. uni.switchTab({
  36. url: '/pages/index/index'
  37. });
  38. return
  39. }
  40. getOpenAdv().then(res => {
  41. if (res.data.status == 0 || res.data.value.length == 0) {
  42. uni.switchTab({
  43. url: '/pages/index/index'
  44. });
  45. } else if (res.data.status && (res.data.value.length || res.data.video_link)) {
  46. this.advData = res.data
  47. uni.setStorageSync('guideDate', new Date().toLocaleDateString());
  48. this.guidePages = true
  49. }
  50. }).catch(err => {
  51. uni.switchTab({
  52. url: '/pages/index/index'
  53. });
  54. })
  55. }
  56. },
  57. onHide() {
  58. this.guidePages = false
  59. }
  60. }
  61. </script>
  62. <style>
  63. page,
  64. .main {
  65. width: 100%;
  66. height: 100%;
  67. }
  68. </style>