index.vue 2.3 KB

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