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

223 lines
4.6 KiB

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