product-list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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" :style="{ paddingBottom :isIphoneX ? '68rpx' : '0rpx' }">
  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.pageNum += 1;}
  207. let params = {
  208. secondHandType:this.currentId,
  209. instrumentType:this.currentID2,
  210. name:this.name,
  211. pageNum:this.pageNum,
  212. pageSize:this.pageSize
  213. }
  214. this.SecondService.SeconHandProductList(params).then(res =>{
  215. if (res.code == 0) {
  216. const data = res.data;
  217. if(data.results.length == 0){
  218. this.tabchildList = [];
  219. this.showflag = true;
  220. this.listRecord = data.totalRecord;
  221. }else {
  222. this.showflag = false;
  223. this.isShow = true;
  224. let results = data.results;
  225. if(loadMore) {
  226. this.tabchildList = [...this.tabchildList,...results];
  227. } else {
  228. this.tabchildList = [...results];
  229. this.showSkeleton = false;
  230. }
  231. this.hasNextPage = data.hasNextPage;
  232. this.listRecord = data.totalRecord;
  233. }
  234. // 防上拉暴滑
  235. this.pullFlag = false;
  236. setTimeout(()=>{ this.pullFlag = true; },500)
  237. // 底部提示文案
  238. if(this.hasNextPage) {
  239. this.loadingText = '上拉加载更多';
  240. } else {
  241. this.showLoading = true;
  242. this.loadingNow = false;
  243. this.loadingText = '已至底部';
  244. }
  245. }else{
  246. this.$util.msg(error.msg,2000);
  247. }
  248. this.requestFlag = true;
  249. })
  250. },
  251. onShowClose () {//输入框失去焦点时触发
  252. if(this.name != ''){
  253. this.isShowClose = true;
  254. }else{
  255. this.isShowClose = false
  256. }
  257. },
  258. delInputText(){//清除输入框内容
  259. this.name = '';
  260. this.tabchildList =[];
  261. this.isFocus = true
  262. this.isShowClose = false;
  263. this.loadingNow = false;
  264. this.isShowEmpty = true;
  265. this.secondHandType = 1;
  266. this.instrumentType='';
  267. this.gettabList();
  268. this.searchHide = true;
  269. },
  270. searchOpertor(){//搜索商品
  271. if(this.name == ''){
  272. this.$util.msg('请输入商品关键词',2000)
  273. this.secondHandType = 1
  274. this.instrumentType=''
  275. // this.gettabList();
  276. this.searchHide = true;
  277. }else{
  278. this.pageNum = 1
  279. this.showSkeleton = true;
  280. this.gettabList();
  281. this.isFocus = false;
  282. this.searchHide = false;
  283. }
  284. },
  285. },
  286. }
  287. </script>
  288. <style lang="scss">
  289. .ClassA .iconfont{
  290. position: absolute;
  291. right: 20rpx;
  292. }
  293. .warp-container{
  294. width: 100%;
  295. height: 100%;
  296. }
  297. .good-search-top{
  298. width: 702rpx;
  299. height: 70rpx;
  300. flex: 1;
  301. margin: 32rpx auto;
  302. }
  303. .search-from{
  304. width: 702rpx;
  305. height: 66rpx;
  306. background: #F7F7F7;
  307. border-radius: 40rpx;
  308. float: left;
  309. position: relative;
  310. }
  311. .input{
  312. width: 340rpx;
  313. height: 66rpx;
  314. float: left;
  315. line-height: 66rpx;
  316. color: $text-color;
  317. font-size: 28rpx;
  318. }
  319. .icon-iconfonticonfontsousuo1{
  320. width: 64rpx;
  321. height: 66rpx;
  322. line-height: 66rpx;
  323. text-align: center;
  324. display: block;
  325. font-size: 38rpx;
  326. float: left;
  327. color: #999999;
  328. }
  329. .icon-shanchu1{
  330. font-size:32rpx;
  331. color: #999999;
  332. position: absolute;
  333. width: 120rpx;
  334. height: 70rpx;
  335. line-height: 70rpx;
  336. top: 0;
  337. right: 0;
  338. text-align: center;
  339. z-index: 10;
  340. }
  341. .ListImg{
  342. width: 750rpx;
  343. height: 266rpx;
  344. }
  345. .banner-img{
  346. width: 100%;
  347. height: 100%;
  348. }
  349. .secondTitle {
  350. width: 100%;
  351. height:90rpx;
  352. background-color: #ffffff;
  353. border-bottom: 2rpx solid #F0F2F4;
  354. position: relative;
  355. }
  356. .ClassA.active {
  357. color: #E15621;
  358. }
  359. .ClassA {
  360. width: 240rpx;
  361. height: 90rpx;
  362. display: inline-block;
  363. text-align: center;
  364. line-height: 90rpx;
  365. font-size: 30rpx;
  366. cursor: pointer;
  367. color: #666666;
  368. border: 0;
  369. position: relative;
  370. }
  371. .mainTab {
  372. background: #fff;
  373. width: 29vw;
  374. position: absolute;
  375. z-index: 1;
  376. }
  377. .mainTab li.addstyle {
  378. color: #e15616;
  379. }
  380. .mainTab li {
  381. height: 9.6vw;
  382. line-height: 9.6vw;
  383. text-align: center;
  384. color: #627386;
  385. cursor: pointer;
  386. }
  387. .line {
  388. width: 75rpx;
  389. margin: 0 auto;
  390. height: 4rpx;
  391. background-color: #e15616;
  392. display: block;
  393. }
  394. .no-content{
  395. width: 100%;
  396. text-align: center;
  397. top: 50%;
  398. position: absolute;
  399. }
  400. .no-content img{
  401. width: 306rpx;
  402. height: 212rpx;
  403. }
  404. .error-message{
  405. font-size: 24rpx;
  406. color: #b2b2b2;
  407. }
  408. .Listitem {
  409. height: 202rpx;
  410. padding: 20rpx;
  411. border-bottom: 2rpx solid #F0F2F4;
  412. }
  413. .itemImg {
  414. width: 180rpx;
  415. height: 180rpx;
  416. float: left;
  417. background: #000;
  418. position: relative;
  419. }
  420. .itemImg .bigImg {
  421. width: 100%;
  422. height: 100%;
  423. }
  424. .activeImg {
  425. opacity: 0.5;
  426. }
  427. .ItemInfo {
  428. float: right;
  429. width:500rpx;
  430. }
  431. .infotag{
  432. font-size: 20rpx;
  433. padding: 5rpx 15rpx;
  434. background: #f94b4b;
  435. color: #fff;
  436. position: absolute;
  437. border-radius: 6rpx;
  438. }
  439. .productname{
  440. display: inline-block;
  441. font-size: 28rpx;
  442. color: #333333;
  443. vertical-align: top;
  444. text-overflow: -o-ellipsis-lastline;
  445. overflow: hidden;
  446. text-overflow: ellipsis;
  447. display: -webkit-box;
  448. -webkit-line-clamp: 2;
  449. line-clamp: 2;
  450. -webkit-box-orient: vertical;
  451. width: 500rpx;
  452. }
  453. .targetprice {
  454. font-size: 26rpx;
  455. color: #f94b4b;
  456. cursor: pointer;
  457. margin: 15rpx 0;
  458. }
  459. .icon.shijian::before {
  460. background-position: 20rpx;
  461. width: 50rpx;
  462. height: 50rpx;
  463. position: absolute;
  464. right: 2rpx;
  465. top: -10rpx;
  466. }
  467. .shijian,.dizhi{
  468. font-size: 20rpx;
  469. color: #999999;
  470. margin-top: 5rpx;
  471. }
  472. .dizhi_left{
  473. float: left;
  474. }
  475. .liulan_right{
  476. float: right;
  477. margin-right: 25rpx;
  478. }
  479. .itemImg .yishou_bg{
  480. width: 90rpx;
  481. height: 90rpx;
  482. position: absolute;
  483. top: 50%;
  484. left: 50%;
  485. transform: translate(-50%, -50%)
  486. }
  487. .fabu span{
  488. display: inline-block;
  489. width: 280rpx;
  490. height: 84rpx;
  491. line-height: 84rpx;
  492. text-align: center;
  493. border-radius: 42rpx;
  494. margin: 15rpx;
  495. font-size: 30rpx;
  496. }
  497. .fabu{
  498. position: fixed;
  499. bottom: 0;
  500. width: 100%;
  501. background: #fff
  502. }
  503. .fabu .intro{
  504. background: #ffe6dc;
  505. color: #e15616;
  506. }
  507. .fabu .release{
  508. background: $btn-confirm;
  509. color: #ffffff;
  510. width: 402rpx;
  511. }
  512. </style>