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

211 lines
4.2 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
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. <view class="tabs">
  26. <uv-tabs
  27. :list="category"
  28. :activeStyle="{color : '#f00', fontWeight : 600}"
  29. lineColor="#f00"
  30. :inactiveStyle="{color: 'rgba(0,0,0,.8)'}"
  31. lineHeight="8rpx"
  32. lineWidth="50rpx"
  33. :current="current"
  34. @click="clickTabs"></uv-tabs>
  35. </view>
  36. <uv-vtabs
  37. :list="category[current].children"
  38. :current="currentChildren"
  39. keyName="name"
  40. :chain="true"
  41. @change="change">
  42. <!-- <view class="list"> -->
  43. <template v-for="(item, index) in category[current].children">
  44. <uv-vtabs-item :index="index" :key="index">
  45. <view class="category-item">
  46. <view class="category-title">
  47. {{ item.name }}
  48. </view>
  49. <productItem :item="pro"
  50. v-for="(pro, i) in item.shopList" :key="i"
  51. @click="$utils.navigateTo(`/pages_order/product/productDetail?id=${pro.id}`)" />
  52. </view>
  53. </uv-vtabs-item>
  54. </template>
  55. <uv-empty mode="list" v-if="category[current].children.length == 0"></uv-empty>
  56. <!-- </view> -->
  57. </uv-vtabs>
  58. </view>
  59. <!-- tabbar -->
  60. <tabber select="category" />
  61. </view>
  62. </template>
  63. <script>
  64. import productItem from '@/components/product/productItem.vue';
  65. import mixinsList from '@/mixins/list.js'
  66. import {
  67. mapState
  68. } from 'vuex'
  69. import tabber from '@/components/base/tabbar.vue'
  70. import productList from '@/components/user/productList.vue'
  71. export default {
  72. mixins: [mixinsList],
  73. components: {
  74. productItem,
  75. tabber,
  76. productList,
  77. },
  78. data() {
  79. return {
  80. mixinsListApi: 'getClassShopPageList',
  81. current : 0,
  82. currentChildren : 0,
  83. }
  84. },
  85. computed: {
  86. ...mapState(['category'])
  87. },
  88. onLoad({
  89. search,
  90. cid
  91. }) {
  92. if (search) {
  93. this.queryParams.title = search
  94. }
  95. // this.$store.commit('getCategoryList')
  96. if(this.category.length > 0 && cid){
  97. this.category.forEach((n, i) => {
  98. if(n.id == cid){
  99. this.current = i
  100. }
  101. })
  102. // this.queryParams.classId = cid
  103. }else if (this.category.length > 0) {
  104. // this.queryParams.classId = this.category[0].id
  105. }
  106. },
  107. methods: {
  108. change(e) {
  109. // this.queryParams.classId = this.category[e].id
  110. this.currentChildren = e
  111. },
  112. clickTabs({index}){
  113. this.current = index
  114. this.currentChildren = 0
  115. },
  116. search(){
  117. for(let i = 0;i < 10;i++){
  118. delete this.queryParams[i]
  119. }
  120. this.queryParams.pageSize = 10
  121. this.getData()
  122. },
  123. }
  124. }
  125. </script>
  126. <style scoped lang="scss">
  127. .page {
  128. /deep/ .uv-vtabs {
  129. height: calc(100vh - 600rpx) !important;
  130. }
  131. /deep/ .uv-vtabs__bar {
  132. height: calc(100vh - 600rpx) !important;
  133. }
  134. /deep/ .uv-vtabs__content {
  135. height: calc(100vh - 600rpx) !important;
  136. }
  137. .search {
  138. position: relative;
  139. background: #FFFFFF;
  140. margin: 20rpx;
  141. border-radius: 41rpx;
  142. padding: 10rpx 20rpx;
  143. display: flex;
  144. align-items: center;
  145. /deep/ .uv-search__action {
  146. background-color: $uni-color;
  147. color: #FFFFFF;
  148. padding: 10rpx 20rpx;
  149. border-radius: 30rpx;
  150. }
  151. }
  152. &::v-deep .uv-vtabs__content {
  153. background: transparent !important;
  154. overflow: hidden;
  155. }
  156. }
  157. .category {
  158. font-size: 30rpx;
  159. color: #333;
  160. .category-title{
  161. position: relative;
  162. display: flex;
  163. justify-content: center;
  164. align-items: center;
  165. height: 120rpx;
  166. &::before,
  167. &::after {
  168. position: absolute;
  169. top: 50%;
  170. content: '';
  171. width: 10%;
  172. border-top: 2rpx solid black;
  173. }
  174. &::before {
  175. left: 25%;
  176. }
  177. &::after {
  178. right: 25%;
  179. }
  180. }
  181. &::v-deep .uv-vtabs {
  182. width: 750rpx;
  183. overflow: hidden;
  184. }
  185. .list {
  186. width: 100%;
  187. padding: 0rpx 20rpx;
  188. box-sizing: border-box;
  189. }
  190. }
  191. </style>