index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!-- 首页,支持店铺装修 -->
  2. <template>
  3. <view v-if="template">
  4. <s-layout class="ss-w-100 box-sizing" title="首页" navbar="haha" tabbar="/pages/index/index">
  5. <s-block
  6. v-for="(item, index) in template.components"
  7. :key="index"
  8. :styles="item.property.style"
  9. >
  10. <s-block-item :type="item.id" :data="item.property" :styles="item.property.style" />
  11. </s-block>
  12. </s-layout>
  13. </view>
  14. </template>
  15. <script setup>
  16. import { computed } from 'vue';
  17. import { onLoad, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app';
  18. import sheep from '@/sheep';
  19. import $share from '@/sheep/platform/share';
  20. // 隐藏原生tabBar
  21. // uni.hideTabBar();
  22. const template = computed(() => sheep.$store('app').template?.home);
  23. // 在此处拦截改变一下首页轮播图 此处先写死后期复活 放到启动函数里
  24. // (async function() {
  25. // console.log('原代码首页定制化数据',template)
  26. // let {
  27. // data
  28. // } = await index2Api.decorate();
  29. // console.log('首页导航配置化过高无法兼容',JSON.parse(data[1].value))
  30. // 改变首页底部数据 但是没有通过数组id获取商品数据接口
  31. // let {
  32. // data: datas
  33. // } = await index2Api.spids();
  34. // template.value.data[9].data.goodsIds = datas.list.map(item => item.id);
  35. // template.value.data[0].data.list = JSON.parse(data[0].value).map(item => {
  36. // return {
  37. // src: item.picUrl,
  38. // url: item.url,
  39. // title: item.name,
  40. // type: "image"
  41. // }
  42. // })
  43. // }())
  44. onLoad((options) => {
  45. // #ifdef MP
  46. // 小程序识别二维码
  47. if (options.scene) {
  48. const sceneParams = decodeURIComponent(options.scene).split('=');
  49. console.log('sceneParams=>', sceneParams);
  50. options[sceneParams[0]] = sceneParams[1];
  51. }
  52. // #endif
  53. // 预览模板
  54. if (options.templateId) {
  55. sheep.$store('app').init(options.templateId);
  56. }
  57. // 解析分享信息
  58. if (options.spm) {
  59. $share.decryptSpm(options.spm);
  60. }
  61. // 进入指定页面(完整页面路径)
  62. if (options.page) {
  63. sheep.$router.go(decodeURIComponent(options.page));
  64. }
  65. });
  66. // 下拉刷新
  67. onPullDownRefresh(() => {
  68. sheep.$store('app').init();
  69. setTimeout(function () {
  70. uni.stopPullDownRefresh();
  71. }, 800);
  72. });
  73. onPageScroll(() => {});
  74. </script>
  75. <style></style>