product-list.vue 14 KB

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