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

244 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
  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. queryParams: {
  95. pageNo: 1,
  96. pageSize: 10,
  97. title: null,
  98. },
  99. }
  100. },
  101. computed: {
  102. ...mapState(['category']),
  103. },
  104. onLoad({
  105. search,
  106. cid
  107. }) {
  108. if (search) {
  109. this.queryParams.title = search
  110. }
  111. // todo: check
  112. return
  113. // this.$store.commit('getCategoryList')
  114. if(this.category.length > 0 && cid){
  115. this.category.forEach((n, i) => {
  116. if(n.id == cid){
  117. this.current = i
  118. }
  119. })
  120. // this.queryParams.classId = cid
  121. }else if (this.category.length > 0) {
  122. // this.queryParams.classId = this.category[0].id
  123. }
  124. },
  125. methods: {
  126. change(e) {
  127. // this.queryParams.classId = this.category[e].id
  128. this.current = e
  129. },
  130. search(){
  131. for(let i = 0;i < 10;i++){
  132. delete this.queryParams[i]
  133. }
  134. this.queryParams.pageSize = 10
  135. this.getData()
  136. },
  137. }
  138. }
  139. </script>
  140. <style scoped lang="scss">
  141. .page {
  142. background-color: #FFFFFF;
  143. /deep/ .nav-bar__view {
  144. background-image: linear-gradient(#84A73F, #D8FF8F);
  145. }
  146. .search {
  147. position: relative;
  148. background: #F5F5F5;
  149. margin: 15rpx 30rpx;
  150. border-radius: 41rpx;
  151. padding: 10rpx 20rpx;
  152. display: flex;
  153. align-items: center;
  154. }
  155. $search-height: 108rpx;
  156. $list-height: calc(#{$body-height} - #{$search-height});
  157. /deep/ .uv-vtabs,
  158. /deep/ .uv-vtabs__bar,
  159. /deep/ .uv-vtabs__content {
  160. height: $list-height !important;
  161. }
  162. /deep/ .uv-vtabs {
  163. background-color: #F5F5F5;
  164. overflow: hidden;
  165. }
  166. /deep/ .uv-vtabs__bar {
  167. // box-shadow: 0rpx 3rpx 6rpx 0rpx rgba(0,0,0,0.16);
  168. box-shadow: 0px 3px 6px 0px rgba(0,0,0,0.16);
  169. }
  170. /deep/ .uv-vtabs__content {
  171. margin-left: 6px;
  172. margin-right: 10rpx;
  173. }
  174. /deep/ .uv-vtabs__bar-item {
  175. padding: 25rpx 0 !important;
  176. text-align: center;
  177. }
  178. &::v-deep .uv-vtabs__content {
  179. background: #F5F5F5 !important;
  180. // overflow: hidden;
  181. }
  182. }
  183. .category {
  184. font-size: 30rpx;
  185. color: #333;
  186. .category-title{
  187. position: relative;
  188. display: flex;
  189. justify-content: center;
  190. align-items: center;
  191. height: 120rpx;
  192. &::before,
  193. &::after {
  194. position: absolute;
  195. top: 50%;
  196. content: '';
  197. width: 10%;
  198. border-top: 2rpx solid black;
  199. }
  200. &::before {
  201. left: 25%;
  202. }
  203. &::after {
  204. right: 25%;
  205. }
  206. }
  207. &::v-deep .uv-vtabs {
  208. width: 750rpx;
  209. overflow: hidden;
  210. }
  211. .list {
  212. width: 100%;
  213. padding: 0rpx 20rpx;
  214. box-sizing: border-box;
  215. }
  216. }
  217. </style>