product-list.vue 14 KB

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