product-list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539
  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. <view class="secondTitle">
  23. <view class="ClassA" @click="handle('1')">
  24. {{ tabTitleName }}
  25. <text class="iconfont" :class="mainflag ? 'icon-xiangxiajiantou':'icon-xiangshangjiantou'"></text>
  26. <view class="line" v-if="currentId == '1'"></view>
  27. </view>
  28. <view class="ClassA" @click="handle('2')" :class="[currentId == '2' ? 'active':'',currentId == '2' ? 'off':'']">
  29. 临期产品
  30. <view class="line" v-if="currentId == '2'"></view>
  31. </view>
  32. <view class="ClassA" @click="handle('3')" :class="[currentId == '3' ? 'active':'',currentId == '3' ? 'off':'']">
  33. 其他
  34. <view class="line" v-if="currentId == '3'"></view>
  35. </view>
  36. </ul>
  37. </view>
  38. <view class="mainTab" v-if="mainflag" v-show="searchHide">
  39. <view class="li" v-for="(item,index) in tabList" @click='handleChild(item)' :key="index" :class="currentID2 ==index?'addstyle':' '">{{item.name}}</view>
  40. </view>
  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. <view 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. </view>
  49. <view class="ItemInfo">
  50. <text class="infotag news" v-if="item.sold==0&&item.newAdded==1">新</text>
  51. <view class="productname" href="" :style="item.sold==0&&item.newAdded==1?'text-indent:60rpx':''">
  52. {{item.name}}
  53. </view>
  54. <view class="targetprice" >
  55. <text v-if="item.detailTalkFlag ==2 && hasLogin==false">价格详聊</text>
  56. <text v-else-if="!hasLogin" class="priceparam">登录查看价格</text>
  57. <text v-else-if="hasLogin && item.detailTalkFlag==2">价格详聊</text>
  58. <text v-else>¥{{item.price1Str}}</text>
  59. </view>
  60. <view class="shijian">
  61. <text class="iconfont icon-shijian"></text> {{item.onLineDateStr}}
  62. </view>
  63. <view class="dizhi">
  64. <view class="dizhi_left">
  65. <text class="iconfont icon-dizhi1"></text>
  66. {{item.provinceCityDistrict}}
  67. </view>
  68. <view class="liulan_right">
  69. <text class="iconfont icon-kejian1"></text>
  70. {{item.viewingNum}}
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. <view v-if="showLoading && tabchildList.length > 4">
  76. <view class="loading-wrapper loading-wrapper-now" v-if="loadingNow">{{loadingText}}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view>
  77. <view class="loading-wrapper loading-wrapper-btm" v-else>———<text class="btm-text">已至底部</text>———</view>
  78. </view>
  79. </scroll-view>
  80. <view class="no-content" v-show="showflag" :class="showflag?'show':''">
  81. <image src="https://admin-b.caimei365.com/userfiles/1/images/photo/2020/11/kong_m.png" />
  82. <view class="error-message">
  83. <view>此分类下面没有商品,换其它分类瞅瞅</view>
  84. </view>
  85. </view>
  86. </view>
  87. <view class="fabu" :style="{ paddingBottom :isIphoneX ? '68rpx' : '0rpx' }">
  88. <text class="intro" @click.stop="gotointro" >市场介绍</text>
  89. <text class="release" @click.stop="gotoform" >我要发布</text>
  90. </view>
  91. <!-- 透明模态层 -->
  92. <modal-layer v-if='isModallayer'></modal-layer>
  93. </view>
  94. </view>
  95. </template>
  96. <script>
  97. import modalLayer from "@/components/modal-layer"
  98. import { mapState,mapMutations } from 'vuex';
  99. export default{
  100. name:'secondList',
  101. components:{
  102. modalLayer
  103. },
  104. data(){
  105. return{
  106. isShowClose:false,
  107. isModallayer:false,
  108. currentId:1,
  109. currentID2:0,
  110. isShow:false,
  111. requestFlag: true,
  112. showflag:false,
  113. mainflag:false,
  114. tabTitleName:'二手仪器',
  115. tabTitle: [
  116. {value:'1',name:'二手仪器'},
  117. {value:'2',name:'临期产品'},
  118. {value:'3',name:'其他'}
  119. ],
  120. tabList : [
  121. {value:'0',name:'全部'},
  122. {value:'1',name:'轻光电'},
  123. {value:'2',name:'重光电'},
  124. {value:'3',name:'耗材配件'},
  125. ],
  126. // listQuery:{
  127. pageNum:1,
  128. pageSize:10,
  129. name:'',
  130. // },
  131. tabchildList:[],
  132. productsList:[],
  133. tabchild:{},
  134. params:{},
  135. hasNextPage:false ,
  136. showLoading: false,
  137. loadingNow: true,
  138. loadingText: '上拉加载更多',
  139. pullFlag: true,
  140. isFocus:false,
  141. isShowEmpty: false,
  142. isShowEmptyText: '搜索相关商品',
  143. showSkeleton:true,
  144. windowHeight: '',
  145. scrollHeight: '',
  146. searchHide:true,
  147. }
  148. },
  149. created() {
  150. this.setScrollHeight();
  151. this.gettabList();
  152. this.isFocus = true;
  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. console.log(this.hasLogin)
  203. console.log(this.userInfo)
  204. this.showLoading = true;
  205. this.loadingNow = true;
  206. this.loadingText = '加载中';
  207. this.isShowEmpty = false;
  208. if(loadMore) {this.pageNum += 1;}
  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: 20rpx 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 {
  383. .li{
  384. height: 80rpx;
  385. line-height: 80rpx;
  386. text-align: center;
  387. color: #627386;
  388. cursor: pointer;
  389. }
  390. .line {
  391. width: 75rpx;
  392. margin: 0 auto;
  393. height: 4rpx;
  394. background-color: #e15616;
  395. display: block;
  396. }
  397. }
  398. .no-content{
  399. width: 100%;
  400. text-align: center;
  401. top: 50%;
  402. position: absolute;
  403. }
  404. .no-content img{
  405. width: 306rpx;
  406. height: 212rpx;
  407. }
  408. .error-message{
  409. font-size: 24rpx;
  410. color: #b2b2b2;
  411. }
  412. .Listitem {
  413. height: 202rpx;
  414. padding: 20rpx;
  415. border-bottom: 2rpx solid #F0F2F4;
  416. }
  417. .itemImg {
  418. width: 180rpx;
  419. height: 180rpx;
  420. float: left;
  421. background: #000;
  422. position: relative;
  423. .bigImg {
  424. width: 100%;
  425. height: 100%;
  426. }
  427. }
  428. .activeImg {
  429. opacity: 0.5;
  430. }
  431. .ItemInfo {
  432. float: right;
  433. width:500rpx;
  434. .dizhi{
  435. font-size: 24rpx;
  436. color: #999999;
  437. margin-top: 10rpx;
  438. }
  439. .shijian{
  440. font-size: 24rpx;
  441. color: #999999;
  442. margin-top: 10rpx;
  443. }
  444. }
  445. .infotag{
  446. font-size: 20rpx;
  447. padding: 5rpx 15rpx;
  448. background: #f94b4b;
  449. color: #fff;
  450. position: absolute;
  451. border-radius: 6rpx;
  452. }
  453. .productname{
  454. display: inline-block;
  455. font-size: 28rpx;
  456. color: #333333;
  457. vertical-align: top;
  458. text-overflow: -o-ellipsis-lastline;
  459. overflow: hidden;
  460. text-overflow: ellipsis;
  461. display: -webkit-box;
  462. -webkit-line-clamp: 2;
  463. line-clamp: 2;
  464. -webkit-box-orient: vertical;
  465. width: 500rpx;
  466. }
  467. .targetprice {
  468. font-size: 26rpx;
  469. color: #f94b4b;
  470. cursor: pointer;
  471. margin: 15rpx 0;
  472. }
  473. .icon-shijian{
  474. font-size: 30rpx;
  475. color: #999999;
  476. margin-right: 10rpx;
  477. }
  478. .icon-kejian1{
  479. font-size: 30rpx;
  480. color: #999999;
  481. margin-right: 10rpx;
  482. }
  483. .icon-dizhi1{
  484. font-size: 30rpx;
  485. color: #999999;
  486. margin-right: 10rpx;
  487. }
  488. .dizhi_left{
  489. float: left;
  490. }
  491. .liulan_right{
  492. float: right;
  493. margin-right: 25rpx;
  494. }
  495. .itemImg {
  496. .yishou_bg{
  497. width: 90rpx;
  498. height: 90rpx;
  499. position: absolute;
  500. top: 50%;
  501. left: 50%;
  502. transform: translate(-50%, -50%)
  503. }
  504. }
  505. .fabu {
  506. text{
  507. display: inline-block;
  508. width: 280rpx;
  509. height: 84rpx;
  510. line-height: 84rpx;
  511. text-align: center;
  512. border-radius: 42rpx;
  513. margin: 15rpx;
  514. font-size: 30rpx;
  515. }
  516. }
  517. .fabu{
  518. position: fixed;
  519. bottom: 0;
  520. width: 100%;
  521. background: #fff;
  522. .intro{
  523. background: #ffe6dc;
  524. color: #e15616;
  525. }
  526. .release{
  527. background: $btn-confirm;
  528. color: #ffffff;
  529. width: 402rpx;
  530. }
  531. }
  532. </style>