推拿小程序前端代码仓库
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.

235 lines
4.5 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
  1. <template>
  2. <view class="page">
  3. <!-- 导航栏 -->
  4. <navbar title="商品" class="nav-bar"
  5. leftClick
  6. @leftClick="$utils.navigateBack"
  7. bgColor="#E3441A"
  8. color="#fff"
  9. />
  10. <!-- 搜索栏 -->
  11. <view class="search">
  12. <uv-search
  13. v-model="queryParams.title"
  14. placeholder="搜索项目名称"
  15. bgColor="#F5F5F5"
  16. inputAlign="center"
  17. :showAction="false"
  18. @search="search"
  19. @change="search"
  20. @custom="search"
  21. ></uv-search>
  22. </view>
  23. <!-- 商品列表 -->
  24. <view v-if="queryParams.title" >
  25. <productCard v-for="item in list" :data="item" :key="item.id"></productCard>
  26. </view>
  27. <!-- 分类商品列表 -->
  28. <!-- todo: check chain? -->
  29. <view v-else class="" >
  30. <uv-vtabs
  31. :list="category"
  32. keyName="name"
  33. :current="current"
  34. :chain="true"
  35. @change="change"
  36. barWidth="177rpx"
  37. barBgColor="#F5F5F5"
  38. :barItemStyle="{
  39. color: '#000000',
  40. fontSize: '28rpx',
  41. fontWeight: 700,
  42. }"
  43. :barItemActiveStyle="{
  44. color: '#84A73F',
  45. backgroundColor: '#FFFFFF',
  46. }"
  47. :barItemActiveLineStyle="{
  48. backgroundImage: 'linear-gradient(#84A73F, #D8FF8F)',
  49. margin: '25rpx 3rpx',
  50. }"
  51. >
  52. <template v-for="(item, index) in category">
  53. <uv-vtabs-item :index="index" :key="item.id">
  54. <template v-if="item.childrens.length">
  55. <productCard
  56. v-for="product in item.childrens"
  57. :key="product.id"
  58. :data="product"
  59. direction="vertical"
  60. ></productCard>
  61. </template>
  62. <template v-else>
  63. <uv-empty text="还没有呢"/>
  64. </template>
  65. </uv-vtabs-item>
  66. </template>
  67. </uv-vtabs>
  68. </view>
  69. <!-- tabbar -->
  70. <tabber select="category" />
  71. </view>
  72. </template>
  73. <script>
  74. import productCard from '@/components/product/productCard.vue'
  75. import productItem from '@/components/product/productItem.vue';
  76. import mixinsList from '@/mixins/list.js'
  77. import {
  78. mapState
  79. } from 'vuex'
  80. import tabber from '@/components/base/tabbar.vue'
  81. import productList from '@/components/user/productList.vue'
  82. export default {
  83. mixins: [mixinsList],
  84. components: {
  85. productCard,
  86. tabber,
  87. productItem,
  88. productList,
  89. },
  90. data() {
  91. return {
  92. mixinsListApi: 'queryItemList',
  93. current : 0,
  94. }
  95. },
  96. computed: {
  97. ...mapState(['category']),
  98. },
  99. onLoad({
  100. search,
  101. cid
  102. }) {
  103. if (search) {
  104. this.queryParams.title = search
  105. }
  106. // this.$store.commit('getCategoryList')
  107. if(this.category.length > 0 && cid){
  108. this.category.forEach((n, i) => {
  109. if(n.id == cid){
  110. this.current = i
  111. }
  112. })
  113. // this.queryParams.classId = cid
  114. }else if (this.category.length > 0) {
  115. // this.queryParams.classId = this.category[0].id
  116. }
  117. },
  118. methods: {
  119. change(e) {
  120. // this.queryParams.classId = this.category[e].id
  121. this.current = e
  122. },
  123. search(){
  124. for(let i = 0;i < 10;i++){
  125. delete this.queryParams[i]
  126. }
  127. this.queryParams.pageSize = 10
  128. this.getData()
  129. },
  130. }
  131. }
  132. </script>
  133. <style scoped lang="scss">
  134. .page {
  135. background-color: #FFFFFF;
  136. /deep/ .nav-bar__view {
  137. background-image: linear-gradient(#84A73F, #D8FF8F);
  138. }
  139. .search {
  140. position: relative;
  141. background: #F5F5F5;
  142. margin: 15rpx 30rpx;
  143. border-radius: 41rpx;
  144. padding: 10rpx 20rpx;
  145. display: flex;
  146. align-items: center;
  147. }
  148. $search-height: 108rpx;
  149. $list-height: calc(#{$body-height} - #{$search-height});
  150. /deep/ .uv-vtabs,
  151. /deep/ .uv-vtabs__bar,
  152. /deep/ .uv-vtabs__content {
  153. height: $list-height !important;
  154. }
  155. /deep/ .uv-vtabs {
  156. background-color: #F5F5F5;
  157. overflow: hidden;
  158. }
  159. /deep/ .uv-vtabs__bar {
  160. // box-shadow: 0rpx 3rpx 6rpx 0rpx rgba(0,0,0,0.16);
  161. box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.16);
  162. }
  163. /deep/ .uv-vtabs__content {
  164. margin-left: 6px;
  165. margin-right: 10rpx;
  166. }
  167. /deep/ .uv-vtabs__bar-item {
  168. padding: 25rpx 0 !important;
  169. text-align: center;
  170. }
  171. &::v-deep .uv-vtabs__content {
  172. background: #F5F5F5 !important;
  173. // overflow: hidden;
  174. }
  175. }
  176. .category {
  177. font-size: 30rpx;
  178. color: #333;
  179. .category-title{
  180. position: relative;
  181. display: flex;
  182. justify-content: center;
  183. align-items: center;
  184. height: 120rpx;
  185. &::before,
  186. &::after {
  187. position: absolute;
  188. top: 50%;
  189. content: '';
  190. width: 10%;
  191. border-top: 2rpx solid black;
  192. }
  193. &::before {
  194. left: 25%;
  195. }
  196. &::after {
  197. right: 25%;
  198. }
  199. }
  200. &::v-deep .uv-vtabs {
  201. width: 750rpx;
  202. overflow: hidden;
  203. }
  204. .list {
  205. width: 100%;
  206. padding: 0rpx 20rpx;
  207. box-sizing: border-box;
  208. }
  209. }
  210. </style>