You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

279 lines
6.0 KiB

10 months ago
  1. <template>
  2. <view>
  3. <view class="bg" :style="{display : isSearch ? 'block' : 'none'}"></view>
  4. <view class="flex">
  5. <view
  6. class="languageUpdate"
  7. >
  8. <languageUpdate color="#fff"/>
  9. </view>
  10. <view class="search">
  11. <u-search
  12. v-model="searchKey"
  13. :showAction="false"
  14. @change="changeSearch"
  15. style="position: relative;z-index: 999999999;"
  16. :placeholder="$t('page.home.searchPlaceholder')">
  17. </u-search>
  18. <!-- <u-overlay :show="isSearch"></u-overlay> -->
  19. <!-- <view @tap.stop :class="{'product-box' : true, 'product-box-active' : isSearch && searchList.length}">
  20. <productList :list="searchList"/>
  21. </view> -->
  22. </view>
  23. <u-scroll-list class="classList">
  24. <view
  25. class="classList-item"
  26. :style="{color : class_id == item.id ? '#0f0' : '#fff'}"
  27. v-for="(item, index) in classList"
  28. :key="index" @click="toProductList(item)">
  29. {{item.title}}
  30. </view>
  31. </u-scroll-list>
  32. </view>
  33. <view class="swipe" :style="{display : isSearch ? 'block' : 'none'}">
  34. <u-swiper
  35. :list="banner"
  36. indicator
  37. keyName="image"
  38. indicatorMode="line"
  39. circular
  40. ></u-swiper>
  41. </view>
  42. <u-notice-bar
  43. bgColor="#fff"
  44. color="#e3392f"
  45. :text="notice.keyVal"
  46. class="notice" :style="{display : isSearch ? 'block' : 'none'}"></u-notice-bar>
  47. <view class="product" :style="{display : isSearch ? 'block' : 'none'}">
  48. <view class="title">
  49. <text>{{ $t('page.home.product.flash-sales') }}</text>
  50. </view>
  51. <view class="productFlashSales">
  52. <view class="productFlashSales-top">
  53. <!-- <productFlashSales :list="shopPage.records"/> -->
  54. <productFlashSales :list="productFlashSales"/>
  55. </view>
  56. <!-- <view class="productFlashSales-bottom">
  57. {{ $t('page.home.product.View-more-flash-sales') }}
  58. </view> -->
  59. </view>
  60. </view>
  61. <view class="active-image" :style="{display : isSearch ? 'block' : 'none'}" v-if="IndexImage.keyImage">
  62. <img style="border-radius: 10px;" width="100%" v-for="(item,index) in IndexImage.keyImage.split(',')" :src="item" alt="" />
  63. </view>
  64. <view class="product">
  65. <view class="title">
  66. <text>{{ $t('page.home.product.title1') }}</text>
  67. <!-- <u-icon name="arrow-right" size="17"></u-icon> -->
  68. </view>
  69. <productList :list="searchList"/>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import productList from '@/components/product/productList.vue'
  75. import languageUpdate from '@/components/base/languageUpdate.vue'
  76. import productFlashSales from '@/components/product/productFlashSales.vue'
  77. export default {
  78. components : {
  79. productList,
  80. languageUpdate,
  81. productFlashSales
  82. },
  83. computed : {
  84. searchList(){
  85. if(this.shopPage){
  86. return this.shopPage.filter(n => {
  87. return !this.searchKey || n.title.includes(this.searchKey)
  88. })
  89. }
  90. return []
  91. }
  92. },
  93. data() {
  94. return {
  95. notice : {
  96. keyVal : ''
  97. },
  98. isSearch : true,
  99. searchKey : '',
  100. bgColor : '#000',
  101. banner: [],
  102. classList : [],
  103. productFlashSales : [],
  104. shopPage : [],
  105. IndexImage : {},
  106. class_id : undefined,
  107. }
  108. },
  109. onShow(){
  110. this.getData()
  111. },
  112. methods: {
  113. getData(){
  114. this.request('getBanner').then(res => {
  115. this.banner = parseList(res.result)
  116. })
  117. this.request('getNotice').then(res => {
  118. this.notice = res.result || {}
  119. })
  120. this.request('getIndexImage').then(res => {
  121. this.IndexImage = res.result || {};
  122. })
  123. this.request('getClassList').then(res => {
  124. res.result.unshift({
  125. title : this.$t('page.home.all'),
  126. })
  127. this.classList = parseList(res.result);
  128. })
  129. this.getProduct()
  130. this.request('getShopHost').then(res => {
  131. this.productFlashSales = parseList(res.result)
  132. })
  133. },
  134. getProduct(id){
  135. this.request('getShopPage', {},
  136. {
  137. "classId": id,
  138. "pageSize":999, 
  139. "currentPage": 0
  140. }
  141. )
  142. .then(res => {
  143. this.shopPage = parseList(res.result.records);
  144. })
  145. },
  146. toProductList(item){
  147. // uni.navigateTo({
  148. // url: '/pages/productList/productList?title=' + item.title + '&id=' + item.id
  149. // })
  150. this.class_id = item.id
  151. this.getProduct(item.id)
  152. this.isSearch = !this.searchKey && !this.class_id
  153. },
  154. SearchBlur(){
  155. setTimeout(() => this.isSearch = true, 200)
  156. },
  157. changeSearch(){
  158. this.isSearch = !this.searchKey && !this.class_id
  159. }
  160. }
  161. }
  162. </script>
  163. <style lang="scss" scoped>
  164. .bg{
  165. background-color: #E3392F;
  166. height: 220px;
  167. width: 100%;
  168. top: 0;
  169. left: 0;
  170. z-index: -1;
  171. position: absolute;
  172. border-bottom-left-radius: 25px;
  173. border-bottom-right-radius: 25px;
  174. }
  175. .languageUpdate{
  176. height: 50px;
  177. display: flex;
  178. padding: 0 10px;
  179. }
  180. .flex{
  181. padding: 0 10px;
  182. padding-top: 10px;
  183. position: sticky;
  184. top: 0;
  185. z-index: 99;
  186. background-color: #E3392F;
  187. ::v-deep .u-scroll-list__indicator {
  188. display: none !important;
  189. }
  190. .search{
  191. position: relative;
  192. margin-bottom: 20px;
  193. .product-box{
  194. position: absolute;
  195. top: 110%;
  196. left: -10px;
  197. width: 100vw;
  198. z-index: 99;
  199. height: 0;
  200. overflow: hidden;
  201. overflow-y: auto;
  202. z-index: 999999999;
  203. }
  204. .product-box-active{
  205. height: auto;
  206. min-height: 200px;
  207. max-height: calc(100vh - 50px);
  208. }
  209. }
  210. .classList{
  211. .classList-item{
  212. flex-shrink: 0;
  213. color: #fff;
  214. white-space: nowrap;
  215. padding: 0 10px;
  216. padding-bottom: 10px;
  217. font-size: 26rpx;
  218. }
  219. }
  220. }
  221. .swipe{
  222. width: 100%;
  223. padding: 0 10px;
  224. box-sizing: border-box;
  225. z-index: 6;
  226. }
  227. .notice{
  228. margin: 10px;
  229. border-radius: 15px;
  230. border: 1px solid #FCDEB2;
  231. }
  232. .productFlashSales{
  233. border-radius: 10px;
  234. margin: 10px;
  235. background-color: #fff;
  236. box-shadow: 1px 1px 1px 1px #00000005;
  237. .productFlashSales-top{
  238. }
  239. .productFlashSales-bottom{
  240. border-top: 1px solid #00000024;
  241. margin: 10px;
  242. padding: 15px;
  243. text-align: center;
  244. color: #666666;
  245. font-size: 26rpx;
  246. }
  247. }
  248. .active-image{
  249. margin: 20px 10px;
  250. }
  251. .product{
  252. .title{
  253. border-left: 5px solid #E3392F;
  254. margin: 10px;
  255. padding: 0 5px;
  256. display: flex;
  257. font-weight: 900;
  258. align-items: center;
  259. justify-content: space-between;
  260. color: #E3392F;
  261. }
  262. }
  263. </style>