index.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <view v-if="template">
  3. <s-layout title="首页" navbar="custom" tabbar="/pages/index/index" :bgStyle="template.page"
  4. :navbarStyle="template.style?.navbar" onShareAppMessage>
  5. <s-block v-for="(item, index) in template.components" :key="index" :styles="item.property.style">
  6. <s-block-item :type="item.id" :data="item.property" :styles="item.property.style" />
  7. </s-block>
  8. <!-- 广告模块 -->
  9. <s-popup-image />
  10. </s-layout>
  11. </view>
  12. </template>
  13. <script setup>
  14. import {
  15. computed
  16. } from 'vue';
  17. import {
  18. onLoad,
  19. onPageScroll,
  20. onPullDownRefresh
  21. } 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. // TODO 芋艿:测试接口的调用
  48. sheep.$api.app.test();
  49. });
  50. // 下拉刷新
  51. onPullDownRefresh(() => {
  52. sheep.$store('app').init();
  53. setTimeout(function() {
  54. uni.stopPullDownRefresh();
  55. }, 800);
  56. });
  57. onPageScroll(() => {});
  58. </script>
  59. <style></style>