敢为人鲜小程序前端代码仓库
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.

192 lines
3.7 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <navbar title="商品列表"
  5. leftClick
  6. @leftClick="$utils.navigateBack"
  7. bgColor="#E3441A"
  8. color="#fff" />
  9. <!-- 搜索栏 -->
  10. <view class="search">
  11. <uv-search placeholder="搜你喜欢的产品" bgColor="#fff"
  12. @search="search"
  13. @change="search"
  14. @custom="search"
  15. v-model="queryParams.title"></uv-search>
  16. </view>
  17. <!-- 商品列表 -->
  18. <view style="position: 20rpx;"
  19. v-if="queryParams.title">
  20. <productList :list="list" />
  21. </view>
  22. <!-- 分类商品列表 -->
  23. <view class="category"
  24. v-else>
  25. <uv-vtabs
  26. :list="category"
  27. :current="current"
  28. keyName="name"
  29. @change="change">
  30. <view class="list">
  31. <uv-vtabs-item>
  32. <view class="category-item"
  33. v-for="(item, index) in category[current].children" :key="index">
  34. <view class="category-title">
  35. {{ item.name }}
  36. </view>
  37. <productItem :item="pro"
  38. v-for="(pro, i) in item.shopList" :key="i"
  39. @click="$utils.navigateTo(`/pages_order/product/productDetail?id=${pro.id}`)" />
  40. </view>
  41. <uv-empty mode="list" v-if="category[current].children.length == 0"></uv-empty>
  42. </uv-vtabs-item>
  43. </view>
  44. </uv-vtabs>
  45. </view>
  46. <!-- tabbar -->
  47. <tabber select="category" />
  48. </view>
  49. </template>
  50. <script>
  51. import productItem from '@/components/product/productItem.vue';
  52. import mixinsList from '@/mixins/list.js'
  53. import {
  54. mapState
  55. } from 'vuex'
  56. import tabber from '@/components/base/tabbar.vue'
  57. import productList from '@/components/user/productList.vue'
  58. export default {
  59. mixins: [mixinsList],
  60. components: {
  61. productItem,
  62. tabber,
  63. productList,
  64. },
  65. data() {
  66. return {
  67. mixinsListApi: 'getClassShopPageList',
  68. current : 0,
  69. }
  70. },
  71. computed: {
  72. ...mapState(['category'])
  73. },
  74. onLoad({
  75. search,
  76. cid
  77. }) {
  78. if (search) {
  79. this.queryParams.title = search
  80. }
  81. // this.$store.commit('getCategoryList')
  82. if(this.category.length > 0 && cid){
  83. this.category.forEach((n, i) => {
  84. if(n.id == cid){
  85. this.current = i
  86. }
  87. })
  88. // this.queryParams.classId = cid
  89. }else if (this.category.length > 0) {
  90. // this.queryParams.classId = this.category[0].id
  91. }
  92. },
  93. methods: {
  94. change(e) {
  95. // this.queryParams.classId = this.category[e].id
  96. this.current = e
  97. },
  98. search(){
  99. for(let i = 0;i < 10;i++){
  100. delete this.queryParams[i]
  101. }
  102. this.queryParams.pageSize = 10
  103. this.getData()
  104. },
  105. }
  106. }
  107. </script>
  108. <style scoped lang="scss">
  109. .page {
  110. /deep/ .uv-vtabs {
  111. height: calc(100vh - 470rpx) !important;
  112. }
  113. /deep/ .uv-vtabs__bar {
  114. height: calc(100vh - 470rpx) !important;
  115. }
  116. /deep/ .uv-vtabs__content {
  117. height: calc(100vh - 470rpx) !important;
  118. }
  119. .search {
  120. position: relative;
  121. background: #FFFFFF;
  122. margin: 20rpx;
  123. border-radius: 41rpx;
  124. padding: 10rpx 20rpx;
  125. display: flex;
  126. align-items: center;
  127. /deep/ .uv-search__action {
  128. background-color: $uni-color;
  129. color: #FFFFFF;
  130. padding: 10rpx 20rpx;
  131. border-radius: 30rpx;
  132. }
  133. }
  134. &::v-deep .uv-vtabs__content {
  135. background: transparent !important;
  136. overflow: hidden;
  137. }
  138. }
  139. .category {
  140. font-size: 30rpx;
  141. color: #333;
  142. .category-title{
  143. position: relative;
  144. display: flex;
  145. justify-content: center;
  146. align-items: center;
  147. height: 120rpx;
  148. &::before,
  149. &::after {
  150. position: absolute;
  151. top: 50%;
  152. content: '';
  153. width: 10%;
  154. border-top: 2rpx solid black;
  155. }
  156. &::before {
  157. left: 25%;
  158. }
  159. &::after {
  160. right: 25%;
  161. }
  162. }
  163. &::v-deep .uv-vtabs {
  164. width: 750rpx;
  165. overflow: hidden;
  166. }
  167. .list {
  168. width: 100%;
  169. padding: 0rpx 20rpx;
  170. box-sizing: border-box;
  171. }
  172. }
  173. </style>