product-list.vue 14 KB

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