product-list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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="searchKeyword"
  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">
  19. <image src="/static/second/banner.png" class="banner-img"></image>
  20. </view>
  21. <view class="main-content">
  22. <ul class="secondTitle">
  23. <li class="ClassA mIcon off" @click="handle('1')" :class="currentId == '1' ? 'active':''">
  24. {{ tabTitleName }}
  25. <span class="line" v-if="currentId == '1'"></span>
  26. </li>
  27. <li class="ClassA" @click="handle('2')" :class="[currentId == '2' ? 'active':'',currentId == '2' ? 'off':'']">
  28. 临期产品
  29. <span class="line" v-if="currentId == '2'"></span>
  30. </li>
  31. <li class="ClassA" @click="handle('3')" :class="[currentId == '3' ? 'active':'',currentId == '3' ? 'off':'']">
  32. 其他
  33. <span class="line" v-if="currentId == '3'"></span>
  34. </li>
  35. </ul>
  36. </view>
  37. <ul class="mainTab" v-if="mainflag">
  38. <li v-for="(item,index) in tabList" @click='handleChild(item)' :key="index" :class="currentID2 ==index?'addstyle':' '">{{item.name}}</li>
  39. </ul>
  40. <view class="shopList" :style="{'overflow':(showSkeleton? 'hidden' : 'auto'),'height': (showSkeleton? windowHeight + 'px' : 'auto')}">
  41. <scroll-view :style="{'height':scrollHeight+'px'}" @scrolltolower="scrolltolower" scroll-y v-if="tabchildList.length > 0">
  42. <view class="Listitem" v-if="isShow" v-for="(item, index) in tabchildList" :key="index" :class="item.sold==1?'activeImg':''">
  43. <a class="itemImg onhref" >
  44. <image :src="item.mainImage" class="bigImg"></image>
  45. <image src="../../../static/second/yishou.png" class="yishou_bg" v-if="item.sold==1&&item.newAdded==1||item.sold==1&&item.newAdded==0"></image>
  46. </a>
  47. <view class="ItemInfo">
  48. <span class="infotag news" v-if="item.sold==0&&item.newAdded==1">新</span>
  49. <!-- <span class="infotag sold" v-if="item.sold==1&&item.newAdded==1||item.sold==1&&item.newAdded==0">已售</span> -->
  50. <a class="productname" href="" :style="item.sold==0&&item.newAdded==1?'text-indent:60rpx':''">
  51. {{item.name}}
  52. </a>
  53. <view class="targetprice" >
  54. <span v-if="item.detailTalkFlag ==2 && userID==null">价格详聊</span>
  55. <span v-else-if="userID==null" class="priceparam" @click="toLogin">登录查看价格></span>
  56. <span v-else-if="userID!=null && item.detailTalkFlag==2">价格详聊</span>
  57. <span v-else>¥{{item.price1Str}}</span>
  58. </view>
  59. <view class="shijian">
  60. <i class="icon shijian"></i> {{item.onLineDateStr}}
  61. </view>
  62. <view class="dizhi">
  63. <view class="dizhi_left">
  64. <i class="icon mIcon dizhi"></i>
  65. {{item.provinceCityDistrict}}
  66. </view>
  67. <view class="liulan_right">
  68. <i class="icon mIcon liulanliang"></i> {{item.viewingNum}}
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. <view v-if="showLoading && tabchildList.length > 4">
  74. <view class="loading-wrapper loading-wrapper-now" v-if="loadingNow">{{loadingText}}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view>
  75. <view class="loading-wrapper loading-wrapper-btm" v-else>———<text class="btm-text">已至底部</text>———</view>
  76. </view>
  77. </scroll-view>
  78. <view class="no-content" v-show="showflag" :class="showflag?'show':''">
  79. <img src="/static/second/kong_m.png" />
  80. <view class="error-message">
  81. <p>此分类下面没有商品,换其它分类瞅瞅</p>
  82. </view>
  83. </view>
  84. </view>
  85. <view class="fabu">
  86. <a href="second/pages/form/introduce" class="intro">市场介绍</a>
  87. <a href="second/pages/form/form" class="release">我要发布</a>
  88. </view>
  89. </view>
  90. </view>
  91. </template>
  92. <script>
  93. import modalLayer from "@/components/modal-layer"
  94. import { mapState,mapMutations } from 'vuex';
  95. export default{
  96. name:'secondList',
  97. components:{
  98. },
  99. data(){
  100. return{
  101. isShowClose:false,
  102. currentId:1,
  103. currentID2:0,
  104. isShow:false,
  105. requestFlag: true,
  106. showflag:false,
  107. mainflag:false,
  108. tabTitleName:'二手仪器',
  109. tabTitle: [
  110. {value:'1',name:'二手仪器'},
  111. {value:'2',name:'临期产品'},
  112. {value:'3',name:'其他'}
  113. ],
  114. tabList : [
  115. {value:'0',name:'全部'},
  116. {value:'1',name:'轻光电'},
  117. {value:'2',name:'重光电'},
  118. {value:'3',name:'耗材配件'},
  119. ],
  120. listQuery:{
  121. pageNum:1,
  122. pageSize:10,
  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. searchKeyword:'',//搜索关键字
  136. isShowEmptyText: '搜索相关商品',
  137. showSkeleton:true,
  138. windowHeight: '',
  139. scrollHeight: '',
  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.listQuery.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. gettabList:function (loadMore) {
  184. const _this = this;
  185. this.showLoading = true;
  186. this.loadingNow = true;
  187. this.loadingText = '加载中';
  188. this.isShowEmpty = false;
  189. if(loadMore) {this.listQuery.pageNum += 1;}
  190. const params = Object.assign({secondHandType: _this.currentId,instrumentType:_this.currentID2}, _this.listQuery);
  191. this.SecondService.SeconHandProductList(params).then(res =>{
  192. if (res.code == 0) {
  193. const data = res.data;
  194. if(data.results.length == 0){
  195. _this.tabchildList = [];
  196. _this.showflag = true;
  197. _this.listRecord = data.totalRecord;
  198. }else {
  199. _this.showflag = false;
  200. _this.isShow = true;
  201. _this.hasNextPage = data.hasNextPage;
  202. _this.listRecord = data.totalRecord;
  203. _this.tabchildList = data.results;
  204. }
  205. // 防上拉暴滑
  206. this.pullFlag = false;
  207. setTimeout(()=>{ this.pullFlag = true; },500)
  208. // 底部提示文案
  209. if(this.hasNextPage) {
  210. this.loadingText = '上拉加载更多';
  211. } else {
  212. this.showLoading = true;
  213. this.loadingNow = false;
  214. this.loadingText = '已至底部';
  215. }
  216. }else{
  217. this.$util.msg(error.msg,2000);
  218. }
  219. _this.requestFlag = true;
  220. })
  221. },
  222. onShowClose () {//输入框失去焦点时触发
  223. if(this.searchKeyword != ''){
  224. this.isShowClose = true
  225. }else{
  226. this.isShowClose = false
  227. }
  228. },
  229. searchOpertor(){//搜索商品
  230. if(this.searchKeyword == ''){
  231. this.$util.msg('请输入商品关键词',2000)
  232. this.secondHandType = 1
  233. this.instrumentType=''
  234. this.gettabList();
  235. }else{
  236. this.listQuery.pageNum = 1
  237. this.showSkeleton = true;
  238. this.gettabList();
  239. this.isFocus = false
  240. }
  241. },
  242. },
  243. }
  244. </script>
  245. <style>
  246. .warp-container{
  247. width: 100%;
  248. height: 100%;
  249. }
  250. .good-search-top{
  251. width: 702rpx;
  252. height: 70rpx;
  253. flex: 1;
  254. margin: 32rpx auto;
  255. }
  256. .search-from{
  257. width: 702rpx;
  258. height: 66rpx;
  259. background: #F7F7F7;
  260. border-radius: 40rpx;
  261. float: left;
  262. position: relative;
  263. }
  264. .input{
  265. width: 340rpx;
  266. height: 66rpx;
  267. float: left;
  268. line-height: 66rpx;
  269. color: $text-color;
  270. font-size: 28rpx;
  271. }
  272. .icon-iconfonticonfontsousuo1{
  273. width: 64rpx;
  274. height: 66rpx;
  275. line-height: 66rpx;
  276. text-align: center;
  277. display: block;
  278. font-size: 38rpx;
  279. float: left;
  280. color: #999999;
  281. }
  282. .icon-shanchu1{
  283. font-size:32rpx;
  284. color: #999999;
  285. position: absolute;
  286. width: 120rpx;
  287. height: 70rpx;
  288. line-height: 70rpx;
  289. top: 0;
  290. right: 0;
  291. text-align: center;
  292. z-index: 10;
  293. }
  294. .ListImg{
  295. width: 750rpx;
  296. height: 266rpx;
  297. }
  298. .banner-img{
  299. width: 100%;
  300. height: 100%;
  301. }
  302. .secondTitle {
  303. width: 100%;
  304. height:90rpx;
  305. background-color: #ffffff;
  306. border-bottom: 2rpx solid #F0F2F4;
  307. position: relative;
  308. }
  309. .ClassA.active {
  310. color: #E15621;
  311. }
  312. .ClassA {
  313. width: 240rpx;
  314. height: 90rpx;
  315. display: inline-block;
  316. text-align: center;
  317. line-height: 90rpx;
  318. font-size: 30rpx;
  319. cursor: pointer;
  320. color: #666666;
  321. border: 0;
  322. position: relative;
  323. }
  324. .mainTab {
  325. background: #fff;
  326. width: 29vw;
  327. position: absolute;
  328. z-index: 1;
  329. }
  330. .mainTab li.addstyle {
  331. color: #e15616;
  332. }
  333. .mainTab li {
  334. height: 9.6vw;
  335. line-height: 9.6vw;
  336. text-align: center;
  337. color: #627386;
  338. cursor: pointer;
  339. }
  340. .line {
  341. width: 75rpx;
  342. margin: 0 auto;
  343. height: 4rpx;
  344. background-color: #e15616;
  345. display: block;
  346. }
  347. .no-content{
  348. width: 100%;
  349. text-align: center;
  350. top: 50%;
  351. position: absolute;
  352. }
  353. .no-content img{
  354. width: 306rpx;
  355. height: 212rpx;
  356. }
  357. .error-message{
  358. font-size: 24rpx;
  359. color: #b2b2b2;
  360. }
  361. .Listitem {
  362. height: 202rpx;
  363. padding: 20rpx;
  364. border-bottom: 2rpx solid #F0F2F4;
  365. }
  366. .itemImg {
  367. width: 180rpx;
  368. height: 180rpx;
  369. float: left;
  370. background: #000;
  371. position: relative;
  372. }
  373. .itemImg .bigImg {
  374. width: 100%;
  375. height: 100%;
  376. }
  377. .activeImg {
  378. opacity: 0.5;
  379. }
  380. .ItemInfo {
  381. float: right;
  382. width:500rpx;
  383. }
  384. .infotag{
  385. font-size: 20rpx;
  386. padding: 5rpx 15rpx;
  387. background: #f94b4b;
  388. color: #fff;
  389. position: absolute;
  390. border-radius: 6rpx;
  391. }
  392. .productname{
  393. display: inline-block;
  394. font-size: 28rpx;
  395. color: #333333;
  396. vertical-align: top;
  397. text-overflow: -o-ellipsis-lastline;
  398. overflow: hidden;
  399. text-overflow: ellipsis;
  400. display: -webkit-box;
  401. -webkit-line-clamp: 2;
  402. line-clamp: 2;
  403. -webkit-box-orient: vertical;
  404. width: 500rpx;
  405. }
  406. .targetprice {
  407. font-size: 26rpx;
  408. color: #f94b4b;
  409. cursor: pointer;
  410. margin: 15rpx 0;
  411. }
  412. .icon.shijian::before {
  413. background-position: 20rpx;
  414. width: 50rpx;
  415. height: 50rpx;
  416. position: absolute;
  417. right: 2rpx;
  418. top: -10rpx;
  419. }
  420. .shijian,.dizhi{
  421. font-size: 20rpx;
  422. color: #999999;
  423. margin-top: 5rpx;
  424. }
  425. .dizhi_left{
  426. float: left;
  427. }
  428. .liulan_right{
  429. float: right;
  430. margin-right: 25rpx;
  431. }
  432. .itemImg .yishou_bg{
  433. width: 90rpx;
  434. height: 90rpx;
  435. position: absolute;
  436. top: 50%;
  437. left: 50%;
  438. transform: translate(-50%, -50%)
  439. }
  440. .fabu a{
  441. display: inline-block;
  442. width: 280rpx;
  443. height: 84rpx;
  444. line-height: 84rpx;
  445. text-align: center;
  446. border-radius: 42rpx;
  447. margin: 15rpx;
  448. font-size: 30rpx;
  449. }
  450. .fabu{
  451. position: fixed;
  452. bottom: 0;
  453. width: 100%;
  454. background: #fff
  455. }
  456. .fabu .intro{
  457. background: #ffe6dc;
  458. color: #e15616;
  459. }
  460. .fabu .release{
  461. background-image: linear-gradient(315deg,
  462. #f28f31 0%,
  463. #e15616 100%);
  464. color: #ffffff;
  465. width: 402rpx;
  466. }
  467. </style>