index.vue 2.9 KB

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