index.vue 2.8 KB

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