index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <!-- 首页,支持店铺装修 -->
  2. <template>
  3. <view v-if="template">
  4. <s-layout title="首页" navbar="custom" tabbar="/pages/index/index" :bgStyle="template.page"
  5. :navbarStyle="template.navigationBar" onShareAppMessage>
  6. <view class="home-top">
  7. <image class="disImg" :src="sheep.$url.static('/static/home/homeTop.png')" />
  8. <view class="search-box">
  9. <u-search placeholder="请输入搜索内容" @search="onSearch" shape="round" v-model="keyword"
  10. :showAction="false"></u-search>
  11. </view>
  12. <!-- <image class="home-xq" :src="sheep.$url.static('/static/home/homexq.png')" /> -->
  13. <view v-for="(item, index) in template.components" :key="index" :styles="item.property.style">
  14. <s-block-item v-if="item.id == 'Carousel'" :type="item.id" :data="item.property"
  15. :styles="item.property.style" />
  16. </view>
  17. </view>
  18. <view class="home-container">
  19. <com-title title="产品服务" />
  20. <productService />
  21. <com-title title="服务优势" />
  22. <serviceAdvantages />
  23. <com-title title="服务案例" />
  24. <view v-for="(item, index) in template.components" :key="index" :styles="item.property.style">
  25. <s-block-item v-if="item.id == 'ProductCard'" :type="item.id" :data="item.property"
  26. :styles="item.property.style" />
  27. </view>
  28. </view>
  29. </s-layout>
  30. </view>
  31. </template>
  32. <script setup>
  33. import uSearch from '@/uni_modules/vk-uview-ui/components/u-search/u-search.vue'
  34. import {
  35. computed,
  36. ref
  37. } from 'vue';
  38. import {
  39. onLoad,
  40. onPageScroll,
  41. onPullDownRefresh
  42. } from '@dcloudio/uni-app';
  43. import comTitle from './com/title.vue';
  44. import productService from './com/productServic.vue';
  45. import serviceAdvantages from './com/serviceAdvantages.vue';
  46. import sheep from '@/sheep';
  47. import $share from '@/sheep/platform/share';
  48. // 隐藏原生tabBar
  49. uni.hideTabBar();
  50. const navigationBar = ref({
  51. "otherCells": [
  52. {
  53. "left": 0,
  54. "right": 8,
  55. "top": 0,
  56. "bottom": 1,
  57. "height": 1,
  58. "width": 8,
  59. "type": "text",
  60. "fontSize": 20,
  61. "fontWeight": "bold",
  62. "textColor": "#1E2129",
  63. "text": "赢伟达"
  64. }
  65. ],
  66. "bgType": "color",
  67. "bgColor": "transparent"
  68. })
  69. const template = computed(() => sheep.$store('app').template?.home);
  70. onLoad((options) => {
  71. // #ifdef MP
  72. // 小程序识别二维码
  73. if (options.scene) {
  74. const sceneParams = decodeURIComponent(options.scene).split('=');
  75. console.log("sceneParams=>", sceneParams);
  76. options[sceneParams[0]] = sceneParams[1];
  77. }
  78. // #endif
  79. // 预览模板
  80. if (options.templateId) {
  81. sheep.$store('app').init(options.templateId);
  82. }
  83. // 解析分享信息
  84. if (options.spm) {
  85. $share.decryptSpm(options.spm);
  86. }
  87. // 进入指定页面(完整页面路径)
  88. if (options.page) {
  89. sheep.$router.go(decodeURIComponent(options.page));
  90. }
  91. });
  92. const keyword = ref("")
  93. const onSearch = (e) => {
  94. if (e) {
  95. sheep.$router.go('/pages/goods/list', { keyword: e });
  96. setTimeout(() => {
  97. keyword.value = '';
  98. }, 100);
  99. }
  100. }
  101. // 下拉刷新
  102. onPullDownRefresh(() => {
  103. sheep.$store('app').init();
  104. setTimeout(function () {
  105. uni.stopPullDownRefresh();
  106. }, 800);
  107. });
  108. onPageScroll(() => { });
  109. </script>
  110. <style lang="scss" scoped>
  111. // #ifdef H5
  112. :deep(.ui-fixed-box) {
  113. position: absolute !important;
  114. background: transparent !important;
  115. .nav-title {
  116. font-weight: bold;
  117. }
  118. }
  119. // #endif
  120. // #ifdef MP
  121. :deep(.ui-fixed-box) {
  122. position: fixed !important;
  123. background: #fff !important;
  124. .nav-title {
  125. font-weight: bold;
  126. }
  127. }
  128. // #endif
  129. .home-container {
  130. width: 100%;
  131. height: 100%;
  132. padding: 0 16px;
  133. }
  134. .home-top {
  135. width: 100%;
  136. position: relative;
  137. height: 230px;
  138. padding-top: 44px;
  139. top: -44px;
  140. z-index: 1;
  141. .search-box {
  142. padding: 0 16px;
  143. margin-top: 12px;
  144. }
  145. .home-xq {
  146. width: calc(100% - 32px);
  147. height: 164px;
  148. padding: 16px;
  149. }
  150. }
  151. .disImg {
  152. width: 100%;
  153. position: absolute;
  154. z-index: -1;
  155. top: 0;
  156. left: 0;
  157. // height: 100%;
  158. }
  159. </style>