product-list.vue 14 KB

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