index.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <view class="container">
  3. <view class="search-box">
  4. <uni-search-bar radius="5" placeholder="搜索" clearButton="auto" cancelButton="none" bgColor="#F8F8F8" @confirm="search" class="search-bar"/>
  5. </view>
  6. <scroll-view :show-scrollbar="0" show-scrollbar="true" scroll-y="true" class="sort-left-box">
  7. <view class="sort-left-row" :class="sortFirstCode == item.code ? 'sort-left-row-active' : ''" v-for="(item,index) in sortFirstList" @click="checkFirstSort(item)" :key="index">
  8. <text>{{item.label}}</text>
  9. </view>
  10. </scroll-view>
  11. <view class="sort-right-box">
  12. <scroll-view :scroll-left="0" show-scrollbar="true" scroll-x="true" class="sort-right-row">
  13. <view class="sort-right-col" :class="sortSecondCode == item.code ? 'sort-right-col-active' : ''"
  14. v-for="(item,index) in sortSecondList" :key="index" @click="checkSecondSort(item)">{{item.label}}</view>
  15. </scroll-view>
  16. <scroll-view :show-scrollbar="0" show-scrollbar="true" scroll-y="true" class="goods-box">
  17. <view class="goods-row" v-for="item in goodsList" @click="">
  18. <cover-image class="goods-img" @click="" :src="item.url"></cover-image>
  19. <view class="goods-info">
  20. <view class="goods-name">{{item.name}}</view>
  21. <view class="goods-details">{{item.details}}</view>
  22. <view class="goods-number">
  23. <!-- <text class="goods-icon">¥</text> -->
  24. <text class="goods-spec">{{item.spec}}</text>
  25. <text class="goods-sales">{{item.sales}}人付款</text>
  26. </view>
  27. </view>
  28. <view class="goods-cart"></view>
  29. </view>
  30. </scroll-view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. sortFirstCode: '1',
  39. sortFirstList: [
  40. {label: '有机蔬菜有蔬菜', code: 1},
  41. {label: '有机蔬菜', code: 2},
  42. {label: '有机蔬菜', code: 3}
  43. ],
  44. sortSecondCode: '1',
  45. sortSecondList: [
  46. {label: '叶菜类', code: 1},
  47. {label: '叶菜类', code: 2},
  48. {label: '叶菜类', code: 3}
  49. ],
  50. goodsList: [
  51. {name: '优质白菜', details: '优质白菜优质白菜优质白菜', spec: '¥80.00/kg', sales: 10},
  52. {name: '优质白菜', details: '优质白菜优质白菜优质白菜', spec: '¥80.00/kg', sales: 10},
  53. {name: '优质白菜', details: '优质白菜优质白菜优质白菜', spec: '¥80.00/kg', sales: 10},
  54. {name: '优质白菜', details: '优质白菜优质白菜优质白菜', spec: '¥80.00/kg', sales: 10},
  55. {name: '优质白菜', details: '优质白菜优质白菜优质白菜', spec: '¥80.00/kg', sales: 10},
  56. {name: '优质白菜', details: '优质白菜优质白菜优质白菜', spec: '¥80.00/kg', sales: 10}
  57. ],
  58. }
  59. },
  60. onLoad(){
  61. },
  62. methods: {
  63. // 切换一级分类
  64. checkFirstSort(item) {
  65. this.sortFirstCode = item.code
  66. this.sortSecondList = this.sortSecondList
  67. this.sortSecondCode = this.sortSecondList.length ? this.sortSecondList[0].code : ''
  68. this.goodsList = this.goodsList
  69. },
  70. // 切换二级分类
  71. checkSecondSort(item) {
  72. this.sortSecondCode = item.code
  73. this.goodsList = this.goodsList
  74. },
  75. search(data) {
  76. },
  77. }
  78. }
  79. </script>
  80. <style lang="less" scoped>
  81. page{
  82. width: 100%;
  83. height: 100%;
  84. }
  85. .container{
  86. width: 100%;
  87. height: 100%;
  88. .search-box{
  89. width: 100%;
  90. height: 58px;
  91. box-sizing: border-box;
  92. padding: 2px 12px 1px 12px;
  93. border-bottom: 1px solid #DDDDDD;
  94. /deep/.search-bar{
  95. .uni-searchbar__box{
  96. border-color: #F8F8F8;
  97. }
  98. }
  99. }
  100. .sort-left-box{
  101. width: 80px;
  102. height: calc(100% - 58px);
  103. border-right: 1px solid #DDDDDD;
  104. float: left;
  105. .sort-left-row{
  106. width: 100%;
  107. height: 45px;
  108. box-sizing: border-box;
  109. padding-left: 9px;
  110. border-left: 3px solid #FFFFFF;
  111. font-size: 15px;
  112. font-family: PingFang SC;
  113. color: #333333;
  114. line-height: 16px;
  115. align-items: center;
  116. display: flex;
  117. }
  118. .sort-left-row-active{
  119. color: #51A539;
  120. border-left: 3px solid #51A539;
  121. }
  122. }
  123. .sort-right-box{
  124. width: calc(100% - 81px);
  125. height: calc(100% - 58px);
  126. float: left;
  127. .sort-right-row{
  128. width: 100%;
  129. height: 44px;
  130. padding: 9px 2px 0px 7px;
  131. box-sizing: border-box;
  132. white-space: nowrap;
  133. .sort-right-col{
  134. height: 26px;
  135. margin-right: 10px;
  136. display: inline-block;
  137. border: 1px solid #DCDCDC;
  138. border-radius: 13px;
  139. padding: 0 25px;
  140. box-sizing: border-box;
  141. font-size: 12px;
  142. font-family: PingFang SC;
  143. color: #666666;
  144. line-height: 24px;
  145. }
  146. .sort-right-col-active{
  147. color: #FFFFFF;
  148. background: #52A63A;
  149. border: 1px solid #51A539;
  150. }
  151. }
  152. .goods-box{
  153. width: 100%;
  154. height: calc(100% - 44px);
  155. padding: 6px 0 0px 0;
  156. box-sizing: border-box;
  157. .goods-row{
  158. width: calc(100% - 24px);
  159. height: 104px;
  160. padding: 11px 11px 11px 7px;
  161. box-sizing: border-box;
  162. margin: 4px 0 12px 12px;
  163. background: #FFFFFF;
  164. box-shadow: 0px 1px 5px 0px rgba(102, 102, 102, 0.43);
  165. border-radius: 15px;
  166. .goods-img{
  167. width: 84px;
  168. height: 84px;
  169. float: left;
  170. }
  171. .goods-info{
  172. width: calc(100% - 104px);
  173. height: 84px;
  174. float: left;
  175. .goods-name{
  176. height: 18px;
  177. font-size: 15px;
  178. font-family: PingFang SC;
  179. color: #333333;
  180. line-height: 18px;
  181. white-space: nowrap;
  182. text-overflow: ellipsis;
  183. overflow: hidden;
  184. }
  185. .goods-details{
  186. height: 28px;
  187. font-size: 12px;
  188. font-family: PingFang SC;
  189. color: #999999;
  190. line-height: 14px;
  191. overflow: hidden;
  192. text-overflow: ellipsis;
  193. display: -webkit-box;
  194. -webkit-line-clamp: 2;
  195. -webkit-box-orient: vertical;
  196. word-wrap: break-word;
  197. margin: 4px 0 12px 0;
  198. }
  199. .goods-number{
  200. height: 16px;
  201. font-family: PingFang SC;
  202. line-height: 16px;
  203. .goods-icon{
  204. font-size: 12px;
  205. color: #52A63A;
  206. }
  207. .goods-spec{
  208. font-size: 15px;
  209. color: #52A63A;
  210. margin-right: 15px;
  211. }
  212. .goods-sales{
  213. font-size: 12px;
  214. color: #999999;
  215. }
  216. }
  217. }
  218. .goods-cart{
  219. width: 20px;
  220. height: 84px;
  221. float: left;
  222. }
  223. }
  224. }
  225. }
  226. }
  227. </style>