classification.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <view class="u-wrap">
  3. <view class="u-search-box">
  4. <u-tabs :list="tabbar" @click="click" lineColor="#fff" :activeStyle="{ color: '#fff' }"
  5. :inactiveStyle="{ color: '#ffffff80' }">></u-tabs>
  6. <view style="padding: 10rpx;">
  7. <u-search placeholder="请输入商品名称" :actionStyle="{ color: '#fff' }" v-model="name"
  8. @search="custom" @custom="custom" :animation="true"></u-search>
  9. </view>
  10. </view>
  11. <view class="u-menu-wrap">
  12. <view class="u-tab-view">
  13. <view v-for="(item,index) in tabbarTwo" :key="index" class="u-tab-item"
  14. :class="[current == index ? 'u-tab-item-active' : '']" @tap.stop="swichMenu(index)">
  15. <text class="u-line-1" style="text-align: center;">{{item.cname}}</text>
  16. </view>
  17. </view>
  18. <scroll-view @scrolltolower="lowerBottom" scroll-y="true" class="scrollHeight" style="max-height: 100vh;">
  19. <view class="right-box">
  20. <view class="page-view">
  21. <view class="class-item">
  22. <!-- <view class="item-title">
  23. <text>{{item.type}}</text>
  24. </view> -->
  25. <view class="item-container">
  26. <view class="thumb" style="display: flex;justify-content: space-between;"
  27. v-for="(itemTwo, indexTwo) in dataList" :key="indexTwo"
  28. @click="selectProduct(itemTwo)">
  29. <view>
  30. <image v-for="(itemThree,indexThree) in itemTwo.filesList" :key="indexThree"
  31. v-if="itemThree.version === '0'" class="item-menu-image"
  32. :src="itemThree.url">
  33. </image>
  34. </view>
  35. <view style="margin-left: 10rpx;width: 368rpx;">
  36. <view class="thumb-text">
  37. {{itemTwo.cname}}
  38. </view>
  39. <view style="color: #707070;font-size: 24rpx;">{{itemTwo.mallPrice}}</view>
  40. <view style="color: #FD4B09;font-size: 24rpx;">库存:{{itemTwo.inventory}}</view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <u-loadmore v-if="page.total !== 0" :status="status" />
  47. </view>
  48. </scroll-view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import {
  54. listAll,
  55. goodsList
  56. } from '@/api/tabBar/classification.js'
  57. export default {
  58. data() {
  59. return {
  60. current: 0, // 预设当前项的值
  61. tabbar: [],
  62. dataList: [],
  63. show: false,
  64. status: 'loadmore',
  65. filesList: [],
  66. tabbarTwo: [],
  67. name: '',
  68. page: {
  69. total: 0,
  70. size: 10,
  71. current: 1
  72. },
  73. search: {}
  74. }
  75. },
  76. onShow() {
  77. listAll().then(res => {
  78. this.tabbarTwo = res.data
  79. this.page = {
  80. total: 0,
  81. size: 10,
  82. current: 1
  83. }
  84. this.search = {
  85. brandId: this.tabbarTwo[this.current].id
  86. }
  87. this.dataList = []
  88. this.onSearch()
  89. })
  90. },
  91. methods: {
  92. selectProduct(item) {
  93. uni.$u.route('/pages/views/buyGoods/commodityDetails', {
  94. id: item.id
  95. });
  96. },
  97. lowerBottom(){
  98. this.status = 'loading'
  99. if (this.dataList.length < this.page.total) {
  100. this.page.current++
  101. this.onSearch()
  102. } else {
  103. this.status = 'nomore'
  104. }
  105. },
  106. custom(){
  107. this.current = -1
  108. this.page = {
  109. total: 0,
  110. size: 10,
  111. current: 1
  112. }
  113. this.search = {
  114. cname:this.name
  115. }
  116. this.dataList = []
  117. this.onSearch()
  118. },
  119. swichMenu(index) {
  120. this.current = index;
  121. this.page = {
  122. total: 0,
  123. size: 10,
  124. current: 1
  125. }
  126. this.search = {
  127. brandId: this.tabbarTwo[this.current].id
  128. }
  129. this.dataList = []
  130. this.onSearch()
  131. },
  132. onSearch() {
  133. uni.showLoading({
  134. title: '加载中',
  135. mask: true
  136. });
  137. goodsList({
  138. size: this.page.size,
  139. current: this.page.current,
  140. ...this.search
  141. }).then(res => {
  142. this.dataList = this.dataList.concat(res.data.records)
  143. this.page.total = res.data.total
  144. if (this.dataList.length == res.data.total) {
  145. this.status = 'nomore'
  146. }
  147. uni.hideLoading();
  148. }).catch(err => {
  149. uni.hideLoading();
  150. })
  151. },
  152. }
  153. }
  154. </script>
  155. <style lang="scss" scoped>
  156. .submitBar {
  157. width: 100%;
  158. font-size: 32rpx;
  159. color: #000;
  160. text-align: center;
  161. // border-top: 1rpx solid #f2f2f6;
  162. }
  163. .u-wrap {
  164. height: calc(100vh);
  165. /* #ifdef H5 */
  166. height: calc(100vh - var(--window-top));
  167. /* #endif */
  168. display: flex;
  169. flex-direction: column;
  170. }
  171. .u-search-box {
  172. padding: 10rpx;
  173. padding-top: 0;
  174. background-color: #FD4B09;
  175. }
  176. .u-menu-wrap {
  177. flex: 1;
  178. display: flex;
  179. overflow: hidden;
  180. }
  181. .u-search-inner {
  182. background-color: rgb(234, 234, 234);
  183. border-radius: 100rpx;
  184. display: flex;
  185. align-items: center;
  186. padding: 10rpx 16rpx;
  187. }
  188. .u-search-text {
  189. font-size: 26rpx;
  190. color: $u-tips-color;
  191. margin-left: 10rpx;
  192. }
  193. .u-tab-view {
  194. width: 200rpx;
  195. overflow-x: scroll;
  196. white-space: nowrap;
  197. }
  198. .u-tab-item {
  199. height: 110rpx;
  200. background: #f6f6f6;
  201. box-sizing: border-box;
  202. display: flex;
  203. align-items: center;
  204. justify-content: center;
  205. font-size: 26rpx;
  206. color: #444;
  207. font-weight: 400;
  208. line-height: 1;
  209. white-space: normal;
  210. word-break: break-all;
  211. word-wrap: break-word;
  212. overflow: hidden;
  213. text-overflow: ellipsis;
  214. // display: -webkit-box;
  215. -webkit-line-clamp: 2;
  216. -webkit-box-orient: vertical;
  217. }
  218. .u-tab-item-active {
  219. position: relative;
  220. color: #000;
  221. font-size: 30rpx;
  222. font-weight: 600;
  223. background: #fff;
  224. }
  225. .u-tab-item-active::before {
  226. content: "";
  227. position: absolute;
  228. border-left: 4px solid #FD4B09;
  229. height: 32rpx;
  230. left: 0;
  231. top: 39rpx;
  232. }
  233. .u-tab-view {
  234. height: 100%;
  235. }
  236. .right-box {
  237. width: 100%;
  238. background-color: rgb(250, 250, 250);
  239. padding-bottom: 20rpx;
  240. }
  241. .page-view {
  242. padding: 16rpx;
  243. }
  244. .class-item {
  245. // margin-bottom: 30rpx;
  246. background-color: #fff;
  247. padding: 16rpx;
  248. border-radius: 8rpx;
  249. }
  250. // .class-item:last-child {
  251. // min-height: 100vh;
  252. // }
  253. .item-title {
  254. font-size: 26rpx;
  255. color: $u-main-color;
  256. font-weight: bold;
  257. }
  258. .item-menu-name {
  259. font-weight: normal;
  260. font-size: 24rpx;
  261. color: $u-main-color;
  262. }
  263. .item-container {
  264. display: flex;
  265. flex-wrap: wrap;
  266. }
  267. .thumb-box {
  268. width: 33.33333%;
  269. display: flex;
  270. align-items: center;
  271. justify-content: center;
  272. flex-direction: column;
  273. margin-top: 20rpx;
  274. }
  275. .thumb {
  276. width: 100%;
  277. align-items: center;
  278. margin: 10rpx auto;
  279. }
  280. .thumb-text {
  281. font-size: 26rpx;
  282. white-space: normal;
  283. word-break: break-all;
  284. word-wrap: break-word;
  285. overflow: hidden;
  286. text-overflow: ellipsis;
  287. display: -webkit-box;
  288. -webkit-line-clamp: 2;
  289. -webkit-box-orient: vertical;
  290. }
  291. .thumb ::v-deep .u-cell__body {
  292. padding: 20rpx 0;
  293. }
  294. .item-menu-image {
  295. width: 150rpx;
  296. height: 150rpx;
  297. border-radius: 20rpx;
  298. }
  299. ::v-deep .u-popup {
  300. flex: 0;
  301. }
  302. </style>