product-list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  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="https://static.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-xiangshangjiantou':'icon-xiangxiajiantou'"></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="https://static.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" @click.stop="this.$api.navigateTo('/pages/login/login')">登录查看价格></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 ? item.viewingNum : '0'}}
  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="https://static.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 authorize from '@/common/config/authorize.js'
  90. import wxLogin from "@/common/config/wxLogin.js"
  91. import modalLayer from "@/components/modal-layer"
  92. import { mapState,mapMutations } from 'vuex';
  93. export default{
  94. name:'secondList',
  95. components:{
  96. modalLayer
  97. },
  98. data(){
  99. return{
  100. clickPath:'/search/pages/search/search-second',
  101. isShowClose:false,
  102. isModallayer:false,
  103. currentId:1,
  104. currentID2:0,
  105. isShow:false,
  106. requestFlag: true,
  107. showflag:false,
  108. mainflag:false,
  109. tabTitleName:'二手仪器',
  110. tabTitle: [
  111. {value:'1',name:'二手仪器'},
  112. {value:'2',name:'临期产品'},
  113. {value:'3',name:'其他'}
  114. ],
  115. tabList : [
  116. {value:'0',name:'全部'},
  117. {value:'1',name:'轻光电'},
  118. {value:'2',name:'重光电'},
  119. {value:'3',name:'耗材配件'},
  120. ],
  121. // listQuery:{
  122. pageNum:1,
  123. pageSize:10,
  124. name:'',
  125. // },
  126. tabchildList:[],
  127. productsList:[],
  128. tabchild:{},
  129. params:{},
  130. hasNextPage:false ,
  131. showLoading: false,
  132. loadingNow: true,
  133. loadingText: '上拉加载更多',
  134. pullFlag: true,
  135. isFocus:false,
  136. isShowEmpty: false,
  137. isShowEmptyText: '搜索相关商品',
  138. showSkeleton:true,
  139. windowHeight: '',
  140. scrollHeight: '',
  141. searchHide:true,
  142. }
  143. },
  144. created() {
  145. this.setScrollHeight();
  146. this.gettabList();
  147. this.isFocus = true;
  148. },
  149. onLoad(option) {
  150. if(option.type =='share'){
  151. authorize.checkLogin().then(res => {
  152. wxLogin.wxLoginAuthorize()
  153. })
  154. .catch(err => {
  155. console.log(new Date +'用户未授权微信信息')
  156. })
  157. }
  158. },
  159. computed: {
  160. ...mapState(['hasLogin','userInfo'])
  161. },
  162. methods:{
  163. scrolltolower() {
  164. if(this.hasNextPage && this.pullFlag) {
  165. this.gettabList(true);
  166. }
  167. },
  168. setScrollHeight() {
  169. const {windowHeight, pixelRatio} = wx.getSystemInfoSync();
  170. this.windowHeight = windowHeight - 1;
  171. this.scrollHeight = windowHeight - 1;
  172. },
  173. handle: function (index) {//一級分类
  174. const _this = this;
  175. _this.currentId = index;
  176. _this.tabTitleName = '二手仪器';
  177. this.pageNum = 1
  178. if ( _this.currentId == '1'){
  179. _this.mainflag = !_this.mainflag;
  180. }else {
  181. _this.mainflag=false;
  182. _this.currentID2 = 0;
  183. }
  184. _this.gettabList();
  185. },
  186. handleChild:function(item){ //二级分类
  187. const _this = this;
  188. _this.currentID2 = item.value;
  189. _this.tabTitleName = item.name;
  190. if (_this.currentID2==item.value){
  191. _this.mainflag=false;
  192. }
  193. _this.gettabList();
  194. },
  195. gotointro:function(){
  196. this.$api.navigateTo('/second/pages/form/introduce');
  197. },
  198. gotoform:function(){
  199. this.$api.navigateTo('/second/pages/form/form');
  200. },
  201. navToDetailPage:function(id) {
  202. this.isModallayer = true;
  203. this.$api.navigateTo(`/second/pages/product/product-details?id=${id}`);
  204. this.isModallayer = false;
  205. },
  206. gettabList:function (loadMore) {
  207. this.showLoading = true;
  208. this.loadingNow = true;
  209. this.loadingText = '加载中';
  210. this.isShowEmpty = false;
  211. if(loadMore) {this.pageNum += 1;}
  212. let params = {
  213. secondHandType:this.currentId,
  214. instrumentType:this.currentID2,
  215. name:this.name,
  216. pageNum:this.pageNum,
  217. pageSize:this.pageSize
  218. }
  219. this.SecondService.SeconHandProductList(params).then(res =>{
  220. if (res.code == 0) {
  221. const data = res.data;
  222. if(data.results.length == 0){
  223. this.tabchildList = [];
  224. this.showflag = true;
  225. this.listRecord = data.totalRecord;
  226. }else {
  227. this.showflag = false;
  228. this.isShow = true;
  229. let results = data.results;
  230. if(loadMore) {
  231. this.tabchildList = [...this.tabchildList,...results];
  232. } else {
  233. this.tabchildList = [...results];
  234. this.showSkeleton = false;
  235. }
  236. this.hasNextPage = data.hasNextPage;
  237. this.listRecord = data.totalRecord;
  238. }
  239. // 防上拉暴滑
  240. this.pullFlag = false;
  241. setTimeout(()=>{ this.pullFlag = true; },500)
  242. // 底部提示文案
  243. if(this.hasNextPage) {
  244. this.loadingText = '上拉加载更多';
  245. } else {
  246. this.showLoading = true;
  247. this.loadingNow = false;
  248. this.loadingText = '已至底部';
  249. }
  250. }else{
  251. this.$util.msg(error.msg,2000);
  252. }
  253. this.requestFlag = true;
  254. })
  255. },
  256. onShowClose () {//输入框失去焦点时触发
  257. if(this.name != ''){
  258. this.isShowClose = true;
  259. }else{
  260. this.isShowClose = false
  261. }
  262. },
  263. delInputText(){//清除输入框内容
  264. this.name = '';
  265. this.tabchildList =[];
  266. this.isFocus = true
  267. this.isShowClose = false;
  268. this.loadingNow = false;
  269. this.isShowEmpty = true;
  270. this.secondHandType = 1;
  271. this.instrumentType='';
  272. this.gettabList();
  273. this.searchHide = true;
  274. },
  275. searchOpertor(){//搜索商品
  276. if(this.name == ''){
  277. this.$util.msg('请输入商品关键词',2000)
  278. this.secondHandType = 1
  279. this.instrumentType=''
  280. // this.gettabList();
  281. this.searchHide = true;
  282. }else{
  283. this.pageNum = 1
  284. this.showSkeleton = true;
  285. this.gettabList();
  286. this.isFocus = false;
  287. this.searchHide = false;
  288. }
  289. },
  290. },
  291. onShareAppMessage(res){//分享转发
  292. if (res.from === 'button') {
  293. // 来自页面内转发按钮
  294. }
  295. return {
  296. title: `欢迎来到采美二手市场~`,
  297. path: `search/pages/search-instrument?keyWord=${this.listQuery.keyword}`
  298. }
  299. },
  300. }
  301. </script>
  302. <style lang="scss">
  303. .ClassA .iconfont{
  304. position: absolute;
  305. right: 20rpx;
  306. }
  307. .warp-container{
  308. width: 100%;
  309. height: 100%;
  310. }
  311. .good-search-top{
  312. width: 702rpx;
  313. height: 70rpx;
  314. flex: 1;
  315. margin: 20rpx auto;
  316. }
  317. .search-from{
  318. width: 702rpx;
  319. height: 66rpx;
  320. background: #F7F7F7;
  321. border-radius: 40rpx;
  322. float: left;
  323. position: relative;
  324. }
  325. .input{
  326. width: 340rpx;
  327. height: 66rpx;
  328. float: left;
  329. line-height: 66rpx;
  330. color: #b2b2b2;
  331. font-size: 28rpx;
  332. }
  333. .icon-iconfonticonfontsousuo1{
  334. width: 64rpx;
  335. height: 66rpx;
  336. line-height: 66rpx;
  337. text-align: center;
  338. display: block;
  339. font-size: 38rpx;
  340. float: left;
  341. color: #999999;
  342. }
  343. .icon-shanchu1{
  344. font-size:32rpx;
  345. color: #999999;
  346. position: absolute;
  347. width: 120rpx;
  348. height: 70rpx;
  349. line-height: 70rpx;
  350. top: 0;
  351. right: 0;
  352. text-align: center;
  353. z-index: 10;
  354. }
  355. .ListImg{
  356. width: 750rpx;
  357. height: 266rpx;
  358. }
  359. .banner-img{
  360. width: 100%;
  361. height: 100%;
  362. }
  363. .secondTitle {
  364. width: 100%;
  365. height:90rpx;
  366. background-color: #ffffff;
  367. border-bottom: 2rpx solid #F0F2F4;
  368. position: relative;
  369. }
  370. .ClassA.active {
  371. color: #E15621;
  372. }
  373. .ClassA {
  374. width: 240rpx;
  375. height: 90rpx;
  376. display: inline-block;
  377. text-align: center;
  378. line-height: 90rpx;
  379. font-size: 30rpx;
  380. cursor: pointer;
  381. color: #666666;
  382. border: 0;
  383. position: relative;
  384. .line {
  385. width: 10vw;
  386. margin: 0 auto;
  387. height: .48vw;
  388. background-color: #e15616;
  389. display: block;
  390. }
  391. }
  392. .mainTab {
  393. background: #fff;
  394. width: 29vw;
  395. position: absolute;
  396. z-index: 1;
  397. border-radius: 6rpx;
  398. box-shadow:0rpx 6rpx 12rpx 0rpx rgba(0, 0, 0, 0.07);
  399. .li{
  400. height: 80rpx;
  401. line-height: 80rpx;
  402. text-align: center;
  403. color: #627386;
  404. cursor: pointer;
  405. &.addstyle{
  406. color: #e15616;
  407. }
  408. }
  409. .line {
  410. width: 75rpx;
  411. margin: 0 auto;
  412. height: 4rpx;
  413. background-color: #e15616;
  414. display: block;
  415. }
  416. }
  417. .no-content{
  418. width: 100%;
  419. text-align: center;
  420. top: 50%;
  421. position: absolute;
  422. image{
  423. width: 306rpx;
  424. height: 212rpx;
  425. }
  426. }
  427. .error-message{
  428. font-size: 24rpx;
  429. color: #b2b2b2;
  430. }
  431. .Listitem {
  432. height: 202rpx;
  433. padding:30rpx 20rpx;
  434. border-bottom: 2rpx solid #F0F2F4;
  435. }
  436. .itemImg {
  437. width: 180rpx;
  438. height: 180rpx;
  439. float: left;
  440. background: #000;
  441. position: relative;
  442. .bigImg {
  443. width: 100%;
  444. height: 100%;
  445. }
  446. }
  447. .activeImg {
  448. opacity: 0.5;
  449. }
  450. .ItemInfo {
  451. float: right;
  452. width:500rpx;
  453. .dizhi{
  454. font-size: 24rpx;
  455. color: #999999;
  456. margin-top: 10rpx;
  457. }
  458. .shijian{
  459. font-size: 24rpx;
  460. color: #999999;
  461. margin-top: 10rpx;
  462. }
  463. }
  464. .infotag{
  465. font-size: 20rpx;
  466. padding: 5rpx 15rpx;
  467. background: #f94b4b;
  468. color: #fff;
  469. position: absolute;
  470. border-radius: 6rpx;
  471. }
  472. .productname{
  473. display: inline-block;
  474. font-size: 28rpx;
  475. color: #333333;
  476. vertical-align: top;
  477. text-overflow: -o-ellipsis-lastline;
  478. overflow: hidden;
  479. text-overflow: ellipsis;
  480. display: -webkit-box;
  481. -webkit-line-clamp: 2;
  482. line-clamp: 2;
  483. -webkit-box-orient: vertical;
  484. width: 500rpx;
  485. }
  486. .targetprice {
  487. font-size: 26rpx;
  488. color: #f94b4b;
  489. cursor: pointer;
  490. margin: 15rpx 0;
  491. }
  492. .icon-shijian{
  493. font-size: 30rpx;
  494. color: #999999;
  495. margin-right: 10rpx;
  496. }
  497. .icon-kejian1{
  498. font-size: 30rpx;
  499. color: #999999;
  500. margin-right: 10rpx;
  501. }
  502. .icon-dizhi1{
  503. font-size: 30rpx;
  504. color: #999999;
  505. margin-right: 10rpx;
  506. }
  507. .dizhi_left{
  508. float: left;
  509. }
  510. .liulan_right{
  511. float: right;
  512. margin-right: 25rpx;
  513. }
  514. .itemImg {
  515. .yishou_bg{
  516. width: 90rpx;
  517. height: 90rpx;
  518. position: absolute;
  519. top: 50%;
  520. left: 50%;
  521. transform: translate(-50%, -50%)
  522. }
  523. }
  524. .fabu {
  525. text{
  526. display: inline-block;
  527. width: 280rpx;
  528. height: 84rpx;
  529. line-height: 84rpx;
  530. text-align: center;
  531. border-radius: 42rpx;
  532. margin: 15rpx;
  533. font-size: 30rpx;
  534. }
  535. }
  536. .fabu{
  537. position: fixed;
  538. bottom: 0;
  539. width: 100%;
  540. background: #fff;
  541. .intro{
  542. background: #ffe6dc;
  543. color: #e15616;
  544. }
  545. .release{
  546. background: $btn-confirm;
  547. color: #ffffff;
  548. width: 402rpx;
  549. }
  550. }
  551. </style>