index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view :style="themeColor()">
  3. <loading-page :loading="diy.getLoading()"></loading-page>
  4. <view v-show="!diy.getLoading()">
  5. <!-- 自定义模板渲染 -->
  6. <view class="diy-template-wrap bg-index" :style="diy.pageStyle()">
  7. <diy-group ref="diyGroupRef" :data="diy.data" />
  8. </view>
  9. </view>
  10. <!-- #ifdef MP-WEIXIN -->
  11. <!-- 小程序隐私协议 -->
  12. <wx-privacy-popup ref="wxPrivacyPopupRef"></wx-privacy-popup>
  13. <!-- #endif -->
  14. </view>
  15. </template>
  16. <script setup lang="ts">
  17. import {ref,nextTick} from 'vue';
  18. import {useDiy} from '@/hooks/useDiy'
  19. import {redirect} from '@/utils/common';
  20. import diyGroup from '@/addon/components/diy/group/index.vue'
  21. import { onShow } from '@dcloudio/uni-app';
  22. import useDiyStore from '@/app/stores/diy';
  23. uni.hideTabBar() // 隐藏tabbar
  24. const diy = useDiy({
  25. name: 'DIY_MALL_INDEX'
  26. })
  27. const diyGroupRef = ref(null)
  28. const wxPrivacyPopupRef:any = ref(null)
  29. // 监听页面加载
  30. diy.onLoad();
  31. onShow(()=>{
  32. const diyStore = useDiyStore();
  33. diyStore.siteId = 0
  34. })
  35. // 监听页面显示
  36. diy.onShow((data: any) => {
  37. if (data.value) {
  38. // uni.setNavigationBarTitle({
  39. // title: diyData.title
  40. // })
  41. } else if (data.page) {
  42. // 跳转到设置的启动页
  43. redirect({url: data.page, mode: 'reLaunch'})
  44. }
  45. diyGroupRef.value?.refresh();
  46. // #ifdef MP
  47. nextTick(()=>{
  48. if(wxPrivacyPopupRef.value) wxPrivacyPopupRef.value.proactive();
  49. })
  50. // #endif
  51. });
  52. // 监听页面隐藏
  53. diy.onHide();
  54. // 监听页面卸载
  55. diy.onUnload();
  56. // 监听滚动事件
  57. diy.onPageScroll()
  58. </script>
  59. <style lang="scss" scoped>
  60. @import '@/styles/diy.scss';
  61. </style>
  62. <style lang="scss">
  63. .diy-template-wrap {
  64. /* #ifdef MP */
  65. .child-diy-template-wrap {
  66. ::v-deep .diy-group {
  67. > .draggable-element.top-fixed-diy {
  68. display: block !important;
  69. }
  70. }
  71. }
  72. /* #endif */
  73. }
  74. </style>