index.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <view v-if="template">
  3. <s-layout
  4. :title="$t('index.index.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. uni.setLocale('en');
  29. // #ifdef MP
  30. // 小程序识别二维码
  31. if (options.scene) {
  32. const sceneParams = decodeURIComponent(options.scene).split('=');
  33. options[sceneParams[0]] = sceneParams[1];
  34. }
  35. // #endif
  36. // 预览模板
  37. if (options.templateId) {
  38. sheep.$store('app').init(options.templateId);
  39. }
  40. // 解析分享信息
  41. if (options.spm) {
  42. $share.decryptSpm(options.spm);
  43. }
  44. // 进入指定页面(完整页面路径)
  45. if (options.page) {
  46. sheep.$router.go(decodeURIComponent(options.page));
  47. }
  48. });
  49. // 下拉刷新
  50. onPullDownRefresh(() => {
  51. sheep.$store('app').init();
  52. setTimeout(function () {
  53. uni.stopPullDownRefresh();
  54. }, 800);
  55. });
  56. onPageScroll(() => {});
  57. </script>
  58. <style></style>