supplyMarket.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. <!-- 供应市场 -->
  2. <template>
  3. <view style="background: #f6f6f6;height: 100vh;">
  4. <view class="searchBox" style="margin-top: 10rpx;">
  5. <view class="search" style="margin-top: 10rpx;background: #F6F6F6;width: 630rpx;">
  6. <u-search bgColor='#F6F6F6' placeholder="请输入关键词"
  7. :showAction='false' @custom="searchList" v-model="searchword"></u-search>
  8. <view @click="searchList" class="searchBtn">搜索</view>
  9. </view>
  10. <!-- <view @click="changeMode">
  11. <u--image width="48rpx" height="48rpx" :src="Modeimg" ></u--image>
  12. </view> -->
  13. </view>
  14. <view class="margintb tabwiew" >
  15. <view>
  16. <u-tabs keyName='subIdName' @click="changeMode" :list="list1"></u-tabs>
  17. </view>
  18. <view style="font-size: 32rpx;width: 100%;" class="flex flexfend">
  19. <view @click="checkType('1')" :class="ischeck=='1'?'check':''">
  20. 综合
  21. </view>
  22. <view class="flex" style="align-items: center;" @click="checkType('2')" :class="ischeck=='2'?'check':''">
  23. 价格 <view>
  24. <u-icon name="arrow-up-fill" :color="checkup?'#46A6FF':'#ccc'" size="8"></u-icon>
  25. <u-icon name="arrow-down-fill" :color="!checkup?'#46A6FF':'#ccc'" size="8"></u-icon>
  26. </view>
  27. </view>
  28. <view class="flex" style="align-items: center;" @click="checkType('3')" :class="ischeck=='3'?'check':''">
  29. 数量<view>
  30. <u-icon name="arrow-up-fill" :color="checkup2?'#46A6FF':'#ccc'" size="8"></u-icon>
  31. <u-icon name="arrow-down-fill" :color="!checkup2?'#46A6FF':'#ccc'" size="8"></u-icon>
  32. </view>
  33. </view>
  34. <view @click="openTabs()" class="selectTypebox">
  35. {{selectType}}<u--image style="margin-top: 10rpx;" width="40rpx" height="40rpx" src="/static/market/btn_screening.png" ></u--image>
  36. </view>
  37. </view>
  38. </view>
  39. <u-popup :closeable='true' :round="10" :show="showTabs" @close="close" @open="open">
  40. <view class="popupView">
  41. <view class="scrollview">
  42. <view class="popupTitle">品类</view>
  43. <view class="btnList" >
  44. <view @click="changeType(index)"
  45. :class="item.plain ?'btnview': 'checkbtnview'"
  46. v-for="(item,index) in tabsList" :key="index">
  47. {{ item.dictValue }}
  48. </view>
  49. </view>
  50. <view class="popupTitle">价格区间</view>
  51. <view class="popupInput">
  52. <u--input
  53. type="number"
  54. placeholder="最低价"
  55. v-model="minNum"
  56. maxlength="10"
  57. ></u--input>
  58. -
  59. <u--input
  60. type="number"
  61. placeholder="最高价"
  62. v-model="maxNum"
  63. maxlength="10"
  64. ></u--input>
  65. </view>
  66. <view class="popupTitle">数量区间</view>
  67. <view class="popupInput">
  68. <u--input
  69. type="number"
  70. placeholder="1"
  71. v-model="minPrice"
  72. maxlength="10"
  73. ></u--input>
  74. -
  75. <u--input
  76. type="number"
  77. placeholder="9999"
  78. v-model="maxPrice"
  79. maxlength="10"
  80. ></u--input>
  81. </view>
  82. </view>
  83. <view class="btnbox" style="left: 24rpx;">
  84. <view @click="resetpopup" class="btn">
  85. 重置
  86. </view>
  87. <view @click="popupsubmit()" class="btn2">
  88. 确定
  89. </view>
  90. </view>
  91. </view>
  92. </u-popup>
  93. <view v-if="tabCurrent == '0'">
  94. <!-- 供应商列表 -->
  95. <marketItem :listdata="vendorList" :showType="0"></marketItem>
  96. </view>
  97. <view v-if="tabCurrent == '1'">
  98. <!-- 商品列表 -->
  99. <marketItem :listdata="supplierList" :showType="1"></marketItem>
  100. </view>
  101. <view class="loadmore" @click="loadmore()">
  102. {{jiazaitext}}
  103. </view>
  104. </view>
  105. </template>
  106. <script>
  107. import marketItem from './base/marketItem.vue'
  108. import {vendorListOfDeclare,supplierListOfProduct,getCategoryList} from '@/http/api/common.js'
  109. export default {
  110. components: {
  111. marketItem
  112. },
  113. data() {
  114. return {
  115. current:'commodity',
  116. tabCurrent:'0',
  117. checkup:true,
  118. checkup2:true,
  119. showTabs:false,
  120. loadingType:false,
  121. ischeck:'1',
  122. searchword:'',
  123. minNum:'',
  124. maxNum:'',
  125. maxPrice:'',
  126. minPrice:'',
  127. selectType:'筛选',
  128. Modeimg:'/static/market/btn_chanpxx.png',
  129. vendorList:[],//供应商列表
  130. supplierList:[],//产品列表
  131. tabsList:[],
  132. tabsItem:[],
  133. pageNum:1,
  134. jiazaitext:'加载更多',
  135. categoryId:'',
  136. list1:[
  137. {
  138. subIdName: '供应商',
  139. key:'0'
  140. },
  141. {
  142. subIdName: '商品',
  143. key:'1'
  144. }
  145. ],
  146. }
  147. },
  148. async onLoad() {
  149. // 获取商品分类
  150. await this.getcategoriesList()
  151. },
  152. async onShow(){
  153. //每次切换页签初始化请求页签
  154. this.pageNum = 1
  155. this.vendorList = []
  156. this.supplierList = []
  157. //获取商品列表
  158. await this.getProductPage()
  159. },
  160. onReachBottom() {
  161. this.loadmore()
  162. },
  163. methods: {
  164. resetpopup(){
  165. this.changeType(0)
  166. this.minNum=''
  167. this.maxNum=''
  168. this.maxPrice=''
  169. this.minPrice=''
  170. },
  171. async popupsubmit(){
  172. this.pageNum = 1
  173. this.vendorList = []
  174. this.supplierList = []
  175. await this.getProductPage()
  176. this.showTabs = false
  177. },
  178. async getProductPage(categoryId=''){
  179. if (this.loadingType) {
  180. //加载中禁止重复加载
  181. return
  182. }
  183. this.loadingType=true
  184. let data = {
  185. priceSort:'ace', //价格排序 ace 小到大;desc 大到小
  186. numSort:'ace', //数量排序 ace 小到大;desc 大到小
  187. minNum:this.minNum, //最小价格
  188. maxNum:this.maxNum, //最大价格
  189. maxPrice:this.maxPrice,
  190. minPrice:this.minPrice,
  191. name:this.searchword, //标题,副标题搜索
  192. pageSize:10,
  193. pageNum:this.pageNum,
  194. category:this.categoryId //类目id
  195. }
  196. if (this.ischeck == '1') {
  197. //综合
  198. data.priceSort = 'ace'
  199. data.numSort = 'ace'
  200. }else if (this.ischeck == '2') {
  201. //价格
  202. data.priceSort = this.checkup ? 'ace' : 'desc'
  203. } else {
  204. //数量
  205. data.numSort = this.checkup2 ? 'ace' : 'desc'
  206. }
  207. if (this.tabCurrent == '0') {
  208. //供应商
  209. await this.getvendorList(data)
  210. }else{
  211. //商品
  212. await this.getsupplierList(data)
  213. }
  214. },
  215. async getvendorList(data){
  216. //供应商
  217. let res = await vendorListOfDeclare(data)
  218. if (res.data.code == 200) {
  219. let newrows = res.data.data?.rows || []
  220. this.vendorList.push(...newrows)
  221. if(this.vendorList.length!=res.data.data.total){
  222. this.jiazaitext="加载更多"
  223. }else{
  224. this.jiazaitext="已经到底"
  225. }
  226. }
  227. this.loadingType=false
  228. },
  229. async getsupplierList(data){
  230. //商品
  231. let res = await supplierListOfProduct(data)
  232. if (res.data.code == 200) {
  233. let newrows = res.data.data?.rows || []
  234. this.supplierList.push(...newrows)
  235. if(this.supplierList.length!=res.data.data.total){
  236. this.jiazaitext="加载更多"
  237. }else{
  238. this.jiazaitext="已经到底"
  239. }
  240. }
  241. this.loadingType=false
  242. },
  243. async searchList(){
  244. // if (this.searchword == '') {
  245. // return
  246. // }
  247. //每次切换页签初始化请求页签
  248. this.pageNum = 1
  249. this.vendorList = []
  250. this.supplierList = []
  251. await this.getProductPage()
  252. },
  253. //加载更多
  254. loadmore(){
  255. console.log('下拉加载',this.jiazaitext);
  256. if (this.jiazaitext=="加载更多") {
  257. this.pageNum=this.pageNum+1
  258. this.jiazaitext="加载中..."
  259. this.getProductPage()
  260. }
  261. },
  262. async getcategoriesList(){
  263. //获取商品分类
  264. let res = await getCategoryList()
  265. if (res.data.code == 200) {
  266. let list = res.data.data.map(v=>{
  267. return {
  268. ...v,
  269. plain:true
  270. }
  271. })
  272. let a = {
  273. dictValue:'全部',
  274. plain:false
  275. }
  276. this.tabsList.push(a)
  277. this.tabsList.push(...list)
  278. }
  279. },
  280. async openTabs(){
  281. this.showTabs = true
  282. },
  283. changeType(index) {
  284. //选择商品类目
  285. this.tabsList.forEach(item => {
  286. item.plain = true
  287. });
  288. this.tabsList[index].plain = false
  289. this.selectType = this.tabsList[index].name
  290. //每次切换页签初始化请求页签
  291. this.pageNum = 1
  292. this.vendorList = []
  293. this.supplierList = []
  294. this.categoryId = this.tabsList[index]?.dictKey || ''
  295. // this.getProductPage()
  296. // this.showTabs = false
  297. },
  298. checkType(type){
  299. //选择列表排序类型
  300. this.ischeck = type
  301. if (this.ischeck == '2' && this.ischeck == type) {
  302. this.checkup = !this.checkup
  303. }
  304. if (this.ischeck == '3' && this.ischeck == type) {
  305. this.checkup2 = !this.checkup2
  306. }
  307. //每次切换页签初始化请求页签
  308. this.pageNum = 1
  309. this.vendorList = []
  310. this.supplierList = []
  311. this.getProductPage()
  312. },
  313. async changeMode(item){
  314. console.log(item.key);
  315. this.tabCurrent = item.key;
  316. //每次切换页签初始化请求页签
  317. this.pageNum = 1
  318. this.vendorList = []
  319. this.supplierList = []
  320. await this.getProductPage()
  321. },
  322. open() {
  323. // console.log('open');
  324. },
  325. close() {
  326. this.showTabs = false
  327. // console.log('close');
  328. },
  329. }
  330. }
  331. </script>
  332. <style>
  333. .check{
  334. color: #46A6FF;
  335. }
  336. .searchBox{
  337. width: 750rpx;
  338. height: 126rpx;
  339. background: #FFFFFF;
  340. border-radius: 0rpx 0rpx 0rpx 0rpx;
  341. opacity: 1;
  342. display: flex;
  343. align-items: center;
  344. justify-content: space-around;
  345. }
  346. .scrollview{
  347. width: 750rpx;
  348. height: 850rpx;
  349. overflow: auto;
  350. }
  351. .loadmore{
  352. height:200rpx;
  353. text-align: center;
  354. font-size: 28rpx;
  355. font-weight: 400;
  356. color: #999;
  357. padding-top: 24rpx;
  358. }
  359. .btnList{
  360. display: flex;
  361. flex-direction: row;
  362. flex-wrap: wrap;
  363. justify-content: flex-start;
  364. }
  365. .checkbtnview{
  366. width: 206rpx;
  367. height: 80rpx;
  368. background: #46A6FF;
  369. border-radius: 40rpx 40rpx 40rpx 40rpx;
  370. opacity: 1;
  371. font-size: 28rpx;
  372. font-weight: 400;
  373. color: #FFFFFF;
  374. line-height: 80rpx;
  375. text-align: center;
  376. margin: 20rpx;
  377. }
  378. .btnview{
  379. width: 206rpx;
  380. height: 80rpx;
  381. background: #F1F1F1;
  382. border-radius: 40rpx 40rpx 40rpx 40rpx;
  383. opacity: 1;
  384. font-size: 28rpx;
  385. font-weight: 400;
  386. color: #666;
  387. line-height: 80rpx;
  388. text-align: center;
  389. margin: 20rpx;
  390. }
  391. .selectTypebox{
  392. display: flex;
  393. width: 200rpx;
  394. align-items: flex-end;
  395. justify-content: space-evenly;
  396. border-left: 1rpx solid #ccc;
  397. height: 40rpx;
  398. }
  399. .margintb{
  400. margin: 16rpx 0;
  401. }
  402. .tabwiew{
  403. background-color: white;
  404. width: 100vw;
  405. height: 150rpx;
  406. display: flex;
  407. font-size: 32rpx;
  408. flex-direction: column;
  409. align-items: center;
  410. }
  411. .btnbox{
  412. display: flex;
  413. position: fixed;
  414. bottom: 20rpx;
  415. }
  416. .btn{
  417. width: 340rpx;
  418. height: 80rpx;
  419. background: #ffffff;
  420. border: 1rpx solid #dddddd;
  421. border-radius: 64rpx 64rpx 64rpx 64rpx;
  422. opacity: 1;
  423. font-size: 28rpx;
  424. font-weight: 500;
  425. color: #46A6FF;
  426. line-height: 80rpx;
  427. text-align: center;
  428. }
  429. .btn2{
  430. width: 340rpx;
  431. height: 80rpx;
  432. background: #46A6FF;
  433. border-radius: 64rpx 64rpx 64rpx 64rpx;
  434. opacity: 1;
  435. font-size: 28rpx;
  436. font-weight: 500;
  437. color: #FFFFFF;
  438. line-height: 80rpx;
  439. text-align: center;
  440. margin-left: 10rpx;
  441. }
  442. .popupTitle{
  443. font-size: 32rpx;
  444. font-weight: 700;
  445. text-align: left;
  446. color: #000000;
  447. margin-left: 24rpx;
  448. }
  449. .popupInput{
  450. width: 90%;
  451. margin: 24rpx auto;
  452. display: flex;
  453. flex-direction: row;
  454. align-items: center;
  455. }
  456. </style>