product-list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. <template name="secondList">
  2. <view class="container">
  3. <view class="good-search-top">
  4. <view class="search-from name">
  5. <text class="iconfont icon-iconfonticonfontsousuo1"></text>
  6. <input class="input"
  7. type="text"
  8. :focus="isFocus"
  9. confirm-type="search"
  10. v-model="name"
  11. placeholder="请输入商品关键词"
  12. @input="onShowClose"
  13. @confirm="searchOpertor"
  14. maxlength="20"/>
  15. <text class="iconfont icon-shanchu1" v-if="isShowClose" @click="delInputText"></text>
  16. </view>
  17. </view>
  18. <view class="ListImg" v-if="searchHide">
  19. <image src="https://admin-b.caimei365.com/userfiles/1/images/photo/2020/11/banner.png" class="banner-img"></image>
  20. </view>
  21. <view class="main-content" v-if="searchHide">
  22. <ul class="secondTitle">
  23. <li class="ClassA mIcon off" @click="handle('1')" :class="currentId == '1' ? 'active':''">
  24. {{ tabTitleName }}
  25. <text class="iconfont" :class="mainflag?'icon-xiangxiajiantou':'icon-xiangshangjiantou'"></text>
  26. <label class="line" v-if="currentId == '1'"></label>
  27. </li>
  28. <li class="ClassA" @click="handle('2')" :class="[currentId == '2' ? 'active':'',currentId == '2' ? 'off':'']">
  29. 临期产品
  30. <label class="line" v-if="currentId == '2'"></label>
  31. </li>
  32. <li class="ClassA" @click="handle('3')" :class="[currentId == '3' ? 'active':'',currentId == '3' ? 'off':'']">
  33. 其他
  34. <label class="line" v-if="currentId == '3'"></label>
  35. </li>
  36. </ul>
  37. </view>
  38. <ul class="mainTab" v-if="mainflag" v-show="searchHide">
  39. <li v-for="(item,index) in tabList" @click='handleChild(item)' :key="index" :class="currentID2 ==index?'addstyle':' '">{{item.name}}</li>
  40. </ul>
  41. <view class="shopList" :style="{'overflow':(showSkeleton? 'hidden' : 'auto'),'height': (showSkeleton? windowHeight + 'px' : 'auto')}">
  42. <scroll-view :style="{'height':scrollHeight+'px'}" @scrolltolower="scrolltolower" scroll-y v-if="tabchildList.length > 0">
  43. <view class="Listitem" v-if="isShow" v-for="(item, index) in tabchildList" :key="index" :class="item.sold==1?'activeImg':''"
  44. :productid="item.productID" @click.stop="navToDetailPage(item.productID)">
  45. <a class="itemImg onhref" >
  46. <image :src="item.imageList[0]" class="bigImg"></image>
  47. <image src="https://admin-b.caimei365.com/userfiles/1/images/photo/2020/11/yishou.png" class="yishou_bg" v-if="item.sold==1&&item.newAdded==1||item.sold==1&&item.newAdded==0"></image>
  48. </a>
  49. <view class="ItemInfo">
  50. <span class="infotag news" v-if="item.sold==0&&item.newAdded==1">新</span>
  51. <a class="productname" href="" :style="item.sold==0&&item.newAdded==1?'text-indent:60rpx':''">
  52. {{item.name}}
  53. </a>
  54. <view class="targetprice" >
  55. <span v-if="item.detailTalkFlag ==2 && hasLogin==false">价格详聊</span>
  56. <span v-else-if="hasLogin==false" class="priceparam">登录查看价格></span>
  57. <span v-else-if="hasLogin && item.detailTalkFlag==2">价格详聊</span>
  58. <span v-else>¥{{item.price1Str}}</span>
  59. </view>
  60. <view class="shijian">
  61. <i class="icon shijian"></i> {{item.onLineDateStr}}
  62. </view>
  63. <view class="dizhi">
  64. <view class="dizhi_left">
  65. <i class="icon mIcon dizhi"></i>
  66. {{item.provinceCityDistrict}}
  67. </view>
  68. <view class="liulan_right">
  69. <i class="icon mIcon liulanliang"></i> {{item.viewingNum}}
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <view v-if="showLoading && tabchildList.length > 4">
  75. <view class="loading-wrapper loading-wrapper-now" v-if="loadingNow">{{loadingText}}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view>
  76. <view class="loading-wrapper loading-wrapper-btm" v-else>———<text class="btm-text">已至底部</text>———</view>
  77. </view>
  78. </scroll-view>
  79. <view class="no-content" v-show="showflag" :class="showflag?'show':''">
  80. <img src="https://admin-b.caimei365.com/userfiles/1/images/photo/2020/11/kong_m.png" />
  81. <view class="error-message">
  82. <p>此分类下面没有商品,换其它分类瞅瞅</p>
  83. </view>
  84. </view>
  85. </view>
  86. <view class="fabu">
  87. <span class="intro" @click.stop="gotointro">市场介绍</span>
  88. <span class="release" @click.stop="gotoform">我要发布</span>
  89. </view>
  90. <!-- 透明模态层 -->
  91. <modal-layer v-if='isModallayer'></modal-layer>
  92. </view>
  93. </view>
  94. </template>
  95. <script>
  96. import modalLayer from "@/components/modal-layer"
  97. import { mapState,mapMutations } from 'vuex';
  98. export default{
  99. name:'secondList',
  100. components:{
  101. modalLayer
  102. },
  103. data(){
  104. return{
  105. isShowClose:false,
  106. isModallayer:false,
  107. currentId:1,
  108. currentID2:0,
  109. isShow:false,
  110. requestFlag: true,
  111. showflag:false,
  112. mainflag:false,
  113. tabTitleName:'二手仪器',
  114. tabTitle: [
  115. {value:'1',name:'二手仪器'},
  116. {value:'2',name:'临期产品'},
  117. {value:'3',name:'其他'}
  118. ],
  119. tabList : [
  120. {value:'0',name:'全部'},
  121. {value:'1',name:'轻光电'},
  122. {value:'2',name:'重光电'},
  123. {value:'3',name:'耗材配件'},
  124. ],
  125. // listQuery:{
  126. pageNum:1,
  127. pageSize:10,
  128. name:'',
  129. // },
  130. tabchildList:[],
  131. productsList:[],
  132. tabchild:{},
  133. params:{},
  134. hasNextPage:false ,
  135. showLoading: false,
  136. loadingNow: true,
  137. loadingText: '上拉加载更多',
  138. pullFlag: true,
  139. isFocus:false,
  140. isShowEmpty: false,
  141. isShowEmptyText: '搜索相关商品',
  142. showSkeleton:true,
  143. windowHeight: '',
  144. scrollHeight: '',
  145. searchHide:true,
  146. }
  147. },
  148. created() {
  149. this.setScrollHeight();
  150. this.gettabList();
  151. this.isFocus = true;
  152. console.log(this.hasLogin)
  153. },
  154. computed: {
  155. ...mapState(['hasLogin','userInfo'])
  156. },
  157. methods:{
  158. scrolltolower() {
  159. if(this.hasNextPage && this.pullFlag) {
  160. this.gettabList(true);
  161. }
  162. },
  163. setScrollHeight() {
  164. const {windowHeight, pixelRatio} = wx.getSystemInfoSync();
  165. this.windowHeight = windowHeight - 1;
  166. this.scrollHeight = windowHeight - 1;
  167. },
  168. handle: function (index) {//一級分类
  169. const _this = this;
  170. _this.currentId = index;
  171. _this.tabTitleName = '二手仪器';
  172. this.pageNum = 1
  173. if ( _this.currentId == '1'){
  174. _this.mainflag = true;
  175. }else {
  176. _this.mainflag=false;
  177. _this.currentID2 = 0;
  178. }
  179. _this.gettabList();
  180. },
  181. handleChild:function(item){ //二级分类
  182. const _this = this;
  183. _this.currentID2 = item.value;
  184. _this.tabTitleName = item.name;
  185. if (_this.currentID2==item.value){
  186. _this.mainflag=false;
  187. }
  188. _this.gettabList();
  189. },
  190. gotointro:function(){
  191. this.$api.navigateTo('/second/pages/form/introduce');
  192. },
  193. gotoform:function(){
  194. this.$api.navigateTo('/second/pages/form/form');
  195. },
  196. navToDetailPage:function(id) {
  197. this.isModallayer = true;
  198. this.$api.navigateTo(`/second/pages/product/product-details?id=${id}`);
  199. this.isModallayer = false;
  200. },
  201. gettabList:function (loadMore) {
  202. this.showLoading = true;
  203. this.loadingNow = true;
  204. this.loadingText = '加载中';
  205. this.isShowEmpty = false;
  206. // if(loadMore) {this.listQuery.pageNum += 1;}
  207. if(loadMore) {this.pageNum += 1;}
  208. // const params = Object.assign({secondHandType: _this.currentId,instrumentType:_this.currentID2}, _this.listQuery);
  209. let params = {
  210. secondHandType:this.currentId,
  211. instrumentType:this.currentID2,
  212. name:this.name,
  213. pageNum:this.pageNum,
  214. pageSize:this.pageSize
  215. }
  216. this.SecondService.SeconHandProductList(params).then(res =>{
  217. if (res.code == 0) {
  218. const data = res.data;
  219. if(data.results.length == 0){
  220. this.tabchildList = [];
  221. this.showflag = true;
  222. this.listRecord = data.totalRecord;
  223. }else {
  224. this.showflag = false;
  225. this.isShow = true;
  226. let results = data.results;
  227. if(loadMore) {
  228. this.tabchildList = [...this.tabchildList,...results];
  229. } else {
  230. this.tabchildList = [...results];
  231. this.showSkeleton = false;
  232. }
  233. this.hasNextPage = data.hasNextPage;
  234. this.listRecord = data.totalRecord;
  235. }
  236. // 防上拉暴滑
  237. this.pullFlag = false;
  238. setTimeout(()=>{ this.pullFlag = true; },500)
  239. // 底部提示文案
  240. if(this.hasNextPage) {
  241. this.loadingText = '上拉加载更多';
  242. } else {
  243. this.showLoading = true;
  244. this.loadingNow = false;
  245. this.loadingText = '已至底部';
  246. }
  247. }else{
  248. this.$util.msg(error.msg,2000);
  249. }
  250. this.requestFlag = true;
  251. })
  252. },
  253. onShowClose () {//输入框失去焦点时触发
  254. if(this.name != ''){
  255. this.isShowClose = true;
  256. }else{
  257. this.isShowClose = false
  258. }
  259. },
  260. delInputText(){//清除输入框内容
  261. this.name = '';
  262. this.tabchildList =[];
  263. this.isFocus = true
  264. this.isShowClose = false;
  265. this.loadingNow = false;
  266. this.isShowEmpty = true;
  267. this.secondHandType = 1;
  268. this.instrumentType='';
  269. this.gettabList();
  270. this.searchHide = true;
  271. },
  272. searchOpertor(){//搜索商品
  273. if(this.name == ''){
  274. this.$util.msg('请输入商品关键词',2000)
  275. this.secondHandType = 1
  276. this.instrumentType=''
  277. // this.gettabList();
  278. this.searchHide = true;
  279. }else{
  280. this.pageNum = 1
  281. this.showSkeleton = true;
  282. this.gettabList();
  283. this.isFocus = false;
  284. this.searchHide = false;
  285. }
  286. },
  287. },
  288. }
  289. </script>
  290. <style lang="scss">
  291. .ClassA .iconfont{
  292. position: absolute;
  293. right: 20rpx;
  294. }
  295. .warp-container{
  296. width: 100%;
  297. height: 100%;
  298. }
  299. .good-search-top{
  300. width: 702rpx;
  301. height: 70rpx;
  302. flex: 1;
  303. margin: 32rpx auto;
  304. }
  305. .search-from{
  306. width: 702rpx;
  307. height: 66rpx;
  308. background: #F7F7F7;
  309. border-radius: 40rpx;
  310. float: left;
  311. position: relative;
  312. }
  313. .input{
  314. width: 340rpx;
  315. height: 66rpx;
  316. float: left;
  317. line-height: 66rpx;
  318. color: $text-color;
  319. font-size: 28rpx;
  320. }
  321. .icon-iconfonticonfontsousuo1{
  322. width: 64rpx;
  323. height: 66rpx;
  324. line-height: 66rpx;
  325. text-align: center;
  326. display: block;
  327. font-size: 38rpx;
  328. float: left;
  329. color: #999999;
  330. }
  331. .icon-shanchu1{
  332. font-size:32rpx;
  333. color: #999999;
  334. position: absolute;
  335. width: 120rpx;
  336. height: 70rpx;
  337. line-height: 70rpx;
  338. top: 0;
  339. right: 0;
  340. text-align: center;
  341. z-index: 10;
  342. }
  343. .ListImg{
  344. width: 750rpx;
  345. height: 266rpx;
  346. }
  347. .banner-img{
  348. width: 100%;
  349. height: 100%;
  350. }
  351. .secondTitle {
  352. width: 100%;
  353. height:90rpx;
  354. background-color: #ffffff;
  355. border-bottom: 2rpx solid #F0F2F4;
  356. position: relative;
  357. }
  358. .ClassA.active {
  359. color: #E15621;
  360. }
  361. .ClassA {
  362. width: 240rpx;
  363. height: 90rpx;
  364. display: inline-block;
  365. text-align: center;
  366. line-height: 90rpx;
  367. font-size: 30rpx;
  368. cursor: pointer;
  369. color: #666666;
  370. border: 0;
  371. position: relative;
  372. }
  373. .mainTab {
  374. background: #fff;
  375. width: 29vw;
  376. position: absolute;
  377. z-index: 1;
  378. }
  379. .mainTab li.addstyle {
  380. color: #e15616;
  381. }
  382. .mainTab li {
  383. height: 9.6vw;
  384. line-height: 9.6vw;
  385. text-align: center;
  386. color: #627386;
  387. cursor: pointer;
  388. }
  389. .line {
  390. width: 75rpx;
  391. margin: 0 auto;
  392. height: 4rpx;
  393. background-color: #e15616;
  394. display: block;
  395. }
  396. .no-content{
  397. width: 100%;
  398. text-align: center;
  399. top: 50%;
  400. position: absolute;
  401. }
  402. .no-content img{
  403. width: 306rpx;
  404. height: 212rpx;
  405. }
  406. .error-message{
  407. font-size: 24rpx;
  408. color: #b2b2b2;
  409. }
  410. .Listitem {
  411. height: 202rpx;
  412. padding: 20rpx;
  413. border-bottom: 2rpx solid #F0F2F4;
  414. }
  415. .itemImg {
  416. width: 180rpx;
  417. height: 180rpx;
  418. float: left;
  419. background: #000;
  420. position: relative;
  421. }
  422. .itemImg .bigImg {
  423. width: 100%;
  424. height: 100%;
  425. }
  426. .activeImg {
  427. opacity: 0.5;
  428. }
  429. .ItemInfo {
  430. float: right;
  431. width:500rpx;
  432. }
  433. .infotag{
  434. font-size: 20rpx;
  435. padding: 5rpx 15rpx;
  436. background: #f94b4b;
  437. color: #fff;
  438. position: absolute;
  439. border-radius: 6rpx;
  440. }
  441. .productname{
  442. display: inline-block;
  443. font-size: 28rpx;
  444. color: #333333;
  445. vertical-align: top;
  446. text-overflow: -o-ellipsis-lastline;
  447. overflow: hidden;
  448. text-overflow: ellipsis;
  449. display: -webkit-box;
  450. -webkit-line-clamp: 2;
  451. line-clamp: 2;
  452. -webkit-box-orient: vertical;
  453. width: 500rpx;
  454. }
  455. .targetprice {
  456. font-size: 26rpx;
  457. color: #f94b4b;
  458. cursor: pointer;
  459. margin: 15rpx 0;
  460. }
  461. .icon.shijian::before {
  462. background-position: 20rpx;
  463. width: 50rpx;
  464. height: 50rpx;
  465. position: absolute;
  466. right: 2rpx;
  467. top: -10rpx;
  468. }
  469. .shijian,.dizhi{
  470. font-size: 20rpx;
  471. color: #999999;
  472. margin-top: 5rpx;
  473. }
  474. .dizhi_left{
  475. float: left;
  476. }
  477. .liulan_right{
  478. float: right;
  479. margin-right: 25rpx;
  480. }
  481. .itemImg .yishou_bg{
  482. width: 90rpx;
  483. height: 90rpx;
  484. position: absolute;
  485. top: 50%;
  486. left: 50%;
  487. transform: translate(-50%, -50%)
  488. }
  489. .fabu span{
  490. display: inline-block;
  491. width: 280rpx;
  492. height: 84rpx;
  493. line-height: 84rpx;
  494. text-align: center;
  495. border-radius: 42rpx;
  496. margin: 15rpx;
  497. font-size: 30rpx;
  498. }
  499. .fabu{
  500. position: fixed;
  501. bottom: 0;
  502. width: 100%;
  503. background: #fff
  504. }
  505. .fabu .intro{
  506. background: #ffe6dc;
  507. color: #e15616;
  508. }
  509. .fabu .release{
  510. background: $btn-confirm;
  511. color: #ffffff;
  512. width: 402rpx;
  513. }
  514. </style>