index.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <template>
  2. <view v-if="template">
  3. <s-layout
  4. title="首页"
  5. navbar="custom"
  6. tabbar="/pages/index/index"
  7. :bgStyle="template.style?.background"
  8. :navbarStyle="template.style?.navbar"
  9. onShareAppMessage
  10. >
  11. <s-block v-for="(item, index) in template.data" :key="index" :styles="item.style">
  12. <s-block-item :type="item.type" :data="item.data" :styles="item.style" />
  13. </s-block>
  14. <!-- 广告模块 -->
  15. <s-popup-image />
  16. </s-layout>
  17. </view>
  18. </template>
  19. <script setup>
  20. import { computed } from 'vue';
  21. import { onLoad, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app';
  22. import sheep from '@/sheep';
  23. import $share from '@/sheep/platform/share';
  24. // 隐藏原生tabBar
  25. uni.hideTabBar();
  26. const template = computed(() => sheep.$store('app').template?.home);
  27. onLoad((options) => {
  28. // #ifdef MP
  29. // 小程序识别二维码
  30. if (options.scene) {
  31. const sceneParams = decodeURIComponent(options.scene).split('=');
  32. options[sceneParams[0]] = sceneParams[1];
  33. }
  34. // #endif
  35. // 预览模板
  36. if (options.templateId) {
  37. sheep.$store('app').init(options.templateId);
  38. }
  39. // 解析分享信息
  40. if (options.spm) {
  41. $share.decryptSpm(options.spm);
  42. }
  43. // 进入指定页面(完整页面路径)
  44. if (options.page) {
  45. sheep.$router.go(decodeURIComponent(options.page));
  46. }
  47. });
  48. // 下拉刷新
  49. onPullDownRefresh(() => {
  50. sheep.$store('app').init();
  51. setTimeout(function () {
  52. uni.stopPullDownRefresh();
  53. }, 800);
  54. });
  55. onPageScroll(() => {});
  56. </script>
  57. <style></style>