index.vue 2.2 KB

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