index.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. <collect-tip ref="collectTipRef" ></collect-tip>
  12. <!-- 小程序隐私协议 -->
  13. <wx-privacy-popup ref="wxPrivacyPopupRef"></wx-privacy-popup>
  14. <!-- #endif -->
  15. </view>
  16. </template>
  17. <script setup lang="ts">
  18. import { ref, nextTick } from 'vue';
  19. import { useDiy } from '@/hooks/useDiy'
  20. import { redirect } from '@/utils/common';
  21. import { useShare } from '@/hooks/useShare'
  22. import diyGroup from '@/addon/components/diy/group/index.vue'
  23. const { setShare } = useShare()
  24. uni.hideTabBar() // 隐藏tabbar
  25. const diy = useDiy({
  26. type: '1'
  27. })
  28. const diyGroupRef = ref(null)
  29. const wxPrivacyPopupRef: any = ref(null)
  30. const collectTipRef: any = ref(null)
  31. // 监听页面加载
  32. diy.onLoad();
  33. // 监听页面显示
  34. diy.onShow((data: any) => {
  35. if (data.value) {
  36. // uni.setNavigationBarTitle({
  37. // title: diyData.title
  38. // })
  39. } else if (data.page) {
  40. // 跳转到设置的启动页
  41. redirect({ url: data.page, mode: 'reLaunch' })
  42. }
  43. let share = data.share ? JSON.parse(data.share) : null;
  44. setShare(share);
  45. diyGroupRef.value?.refresh();
  46. // #ifdef MP
  47. nextTick(() => {
  48. if (wxPrivacyPopupRef.value) wxPrivacyPopupRef.value.proactive();
  49. if (collectTipRef.value) collectTipRef.value.show();
  50. })
  51. // #endif
  52. });
  53. // 监听页面隐藏
  54. diy.onHide();
  55. // 监听页面卸载
  56. diy.onUnload();
  57. // 监听滚动事件
  58. diy.onPageScroll()
  59. </script>
  60. <style lang="scss" scoped>
  61. @import '@/styles/diy.scss';
  62. </style>
  63. <style lang="scss">
  64. .diy-template-wrap {
  65. /* #ifdef MP */
  66. .child-diy-template-wrap {
  67. ::v-deep .diy-group {
  68. > .draggable-element.top-fixed-diy {
  69. display: block !important;
  70. }
  71. }
  72. }
  73. /* #endif */
  74. }
  75. </style>