classification.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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;">
  41. 库存:{{Number(itemTwo.inventory) > 10?'充足':Number(itemTwo.inventory)}}
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. <u-loadmore v-if="page.total !== 0" :status="status" />
  49. </view>
  50. </scroll-view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import {
  56. listAll,
  57. goodsList
  58. } from '@/api/tabBar/classification.js'
  59. import {
  60. details,
  61. } from '@/api/views/personalInformation/index.js'
  62. export default {
  63. data() {
  64. return {
  65. current: 0, // 预设当前项的值
  66. tabbar: [],
  67. dataList: [],
  68. show: false,
  69. status: 'loadmore',
  70. filesList: [],
  71. tabbarTwo: [],
  72. name: '',
  73. page: {
  74. total: 0,
  75. size: 10,
  76. current: 1
  77. },
  78. search: {},
  79. checkStatus:null,
  80. }
  81. },
  82. onShow() {
  83. // 获取审核状态
  84. details().then(res => {
  85. this.checkStatus = res.data.checkStatus
  86. uni.setStorageSync('checkStatus', res.data.checkStatus);
  87. if (this.checkStatus != '通过') {
  88. // uni.showToast({
  89. // title: "当前用户未授权,请联系客服",
  90. // icon: "none",
  91. // mask:true
  92. // });
  93. uni.switchTab({
  94. url:'/pages/tabBar/home'
  95. })
  96. return
  97. }
  98. })
  99. listAll({type:'PP', enableOrNot:'1'}).then(res => {
  100. this.tabbarTwo = res.data
  101. this.page = {
  102. total: 0,
  103. size: 10,
  104. current: 1
  105. }
  106. this.search = {
  107. brandId: this.tabbarTwo[this.current].id
  108. }
  109. this.dataList = []
  110. this.onSearch()
  111. })
  112. },
  113. methods: {
  114. selectProduct(item) {
  115. uni.$u.route('/pages/views/buyGoods/commodityDetails', {
  116. id: item.id
  117. });
  118. },
  119. lowerBottom(){
  120. this.status = 'loading'
  121. if (this.dataList.length < this.page.total) {
  122. this.page.current++
  123. this.onSearch()
  124. } else {
  125. this.status = 'nomore'
  126. }
  127. },
  128. custom(){
  129. this.current = -1
  130. this.page = {
  131. total: 0,
  132. size: 10,
  133. current: 1
  134. }
  135. this.search = {
  136. cname:this.name
  137. }
  138. this.dataList = []
  139. this.onSearch()
  140. },
  141. swichMenu(index) {
  142. this.current = index;
  143. this.page = {
  144. total: 0,
  145. size: 10,
  146. current: 1
  147. }
  148. this.search = {
  149. brandId: this.tabbarTwo[this.current].id
  150. }
  151. this.dataList = []
  152. this.onSearch()
  153. },
  154. onSearch() {
  155. uni.showLoading({
  156. title: '加载中',
  157. mask: true
  158. });
  159. goodsList({
  160. size: this.page.size,
  161. current: this.page.current,
  162. ...this.search
  163. }).then(res => {
  164. this.dataList = this.dataList.concat(res.data.records)
  165. this.page.total = res.data.total
  166. if (this.dataList.length == res.data.total) {
  167. this.status = 'nomore'
  168. }
  169. uni.hideLoading();
  170. }).catch(err => {
  171. uni.hideLoading();
  172. })
  173. },
  174. }
  175. }
  176. </script>
  177. <style lang="scss" scoped>
  178. .submitBar {
  179. width: 100%;
  180. font-size: 32rpx;
  181. color: #000;
  182. text-align: center;
  183. // border-top: 1rpx solid #f2f2f6;
  184. }
  185. .u-wrap {
  186. height: calc(100vh);
  187. /* #ifdef H5 */
  188. height: calc(100vh - var(--window-top));
  189. /* #endif */
  190. display: flex;
  191. flex-direction: column;
  192. }
  193. .u-search-box {
  194. padding: 10rpx;
  195. padding-top: 0;
  196. background-color: #FD4B09;
  197. }
  198. .u-menu-wrap {
  199. flex: 1;
  200. display: flex;
  201. overflow: hidden;
  202. }
  203. .u-search-inner {
  204. background-color: rgb(234, 234, 234);
  205. border-radius: 100rpx;
  206. display: flex;
  207. align-items: center;
  208. padding: 10rpx 16rpx;
  209. }
  210. .u-search-text {
  211. font-size: 26rpx;
  212. color: $u-tips-color;
  213. margin-left: 10rpx;
  214. }
  215. .u-tab-view {
  216. width: 200rpx;
  217. overflow-x: scroll;
  218. white-space: nowrap;
  219. }
  220. .u-tab-item {
  221. height: 110rpx;
  222. background: #f6f6f6;
  223. box-sizing: border-box;
  224. display: flex;
  225. align-items: center;
  226. justify-content: center;
  227. font-size: 26rpx;
  228. color: #444;
  229. font-weight: 400;
  230. line-height: 1;
  231. white-space: normal;
  232. word-break: break-all;
  233. word-wrap: break-word;
  234. overflow: hidden;
  235. text-overflow: ellipsis;
  236. // display: -webkit-box;
  237. -webkit-line-clamp: 2;
  238. -webkit-box-orient: vertical;
  239. }
  240. .u-tab-item-active {
  241. position: relative;
  242. color: #000;
  243. font-size: 30rpx;
  244. font-weight: 600;
  245. background: #fff;
  246. }
  247. .u-tab-item-active::before {
  248. content: "";
  249. position: absolute;
  250. border-left: 4px solid #FD4B09;
  251. height: 32rpx;
  252. left: 0;
  253. top: 39rpx;
  254. }
  255. .u-tab-view {
  256. height: 100%;
  257. }
  258. .right-box {
  259. width: 100%;
  260. background-color: rgb(250, 250, 250);
  261. padding-bottom: 20rpx;
  262. }
  263. .page-view {
  264. padding: 16rpx;
  265. }
  266. .class-item {
  267. // margin-bottom: 30rpx;
  268. background-color: #fff;
  269. padding: 16rpx;
  270. border-radius: 8rpx;
  271. }
  272. // .class-item:last-child {
  273. // min-height: 100vh;
  274. // }
  275. .item-title {
  276. font-size: 26rpx;
  277. color: $u-main-color;
  278. font-weight: bold;
  279. }
  280. .item-menu-name {
  281. font-weight: normal;
  282. font-size: 24rpx;
  283. color: $u-main-color;
  284. }
  285. .item-container {
  286. display: flex;
  287. flex-wrap: wrap;
  288. }
  289. .thumb-box {
  290. width: 33.33333%;
  291. display: flex;
  292. align-items: center;
  293. justify-content: center;
  294. flex-direction: column;
  295. margin-top: 20rpx;
  296. }
  297. .thumb {
  298. width: 100%;
  299. align-items: center;
  300. margin: 10rpx auto;
  301. }
  302. .thumb-text {
  303. font-size: 26rpx;
  304. white-space: normal;
  305. word-break: break-all;
  306. word-wrap: break-word;
  307. overflow: hidden;
  308. text-overflow: ellipsis;
  309. display: -webkit-box;
  310. -webkit-line-clamp: 2;
  311. -webkit-box-orient: vertical;
  312. }
  313. .thumb ::v-deep .u-cell__body {
  314. padding: 20rpx 0;
  315. }
  316. .item-menu-image {
  317. width: 150rpx;
  318. height: 150rpx;
  319. border-radius: 20rpx;
  320. }
  321. ::v-deep .u-popup {
  322. flex: 0;
  323. }
  324. </style>