product-list.vue 15 KB

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