product-list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  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. </view>
  8. </view>
  9. <view class="ListImg" v-if="searchHide">
  10. <image src="https://static.caimei365.com/app/img/bg/banner.png" class="banner-img"></image>
  11. </view>
  12. <view class="main-content" v-if="searchHide">
  13. <view class="secondTitle">
  14. <view class="ClassA" @click="handle('1')" :class="[currentId == '1' ? 'active':'',currentId == '1' ? 'off':'']">
  15. {{ tabTitleName }}
  16. <text class="iconfont" :class="mainflag ? 'icon-xiangshangjiantou':'icon-xiangxiajiantou'"></text>
  17. <view class="line" v-if="currentId == '1'"></view>
  18. </view>
  19. <!-- <view class="ClassA" @click="handle('2')" :class="[currentId == '2' ? 'active':'',currentId == '2' ? 'off':'']">
  20. 临期产品
  21. <view class="line" v-if="currentId == '2'"></view>
  22. </view> -->
  23. <view class="ClassA" @click="handle('3')" :class="[currentId == '3' ? 'active':'',currentId == '3' ? 'off':'']">
  24. 其他
  25. <view class="line" v-if="currentId == '3'"></view>
  26. </view>
  27. </ul>
  28. </view>
  29. <view class="mainTab" v-if="mainflag" v-show="searchHide">
  30. <view class="li" v-for="(item,index) in tabList" @click='handleChild(item)' :key="index" :class="currentID2 ==index?'addstyle':' '">{{item.name}}</view>
  31. </view>
  32. <view class="shopList" :style="{'overflow':(showSkeleton? 'hidden' : 'auto'),'height': (showSkeleton? windowHeight + 'px' : 'auto')}">
  33. <scroll-view :style="{'height':scrollHeight+'px'}" @scrolltolower="scrolltolower" scroll-y v-if="tabchildList.length > 0">
  34. <view class="Listitem" v-if="isShow" v-for="(item, index) in tabchildList" :key="index" :class="item.sold==1?'activeImg':''"
  35. :productid="item.productId" @click.stop="navToDetailPage(item.productId)">
  36. <view class="itemImg onhref" >
  37. <image :src="item.imageList[0]" class="bigImg"></image>
  38. <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>
  39. </view>
  40. <view class="ItemInfo">
  41. <text class="infotag news" v-if="item.sold==0&&item.newAdded==1">新</text>
  42. <view class="productname" href="" :style="item.sold==0&&item.newAdded==1?'text-indent:60rpx':''">
  43. {{item.name}}
  44. </view>
  45. <view class="targetprice" >
  46. <text v-if="item.detailTalkFlag ==2 && hasLogin==false">¥详聊</text>
  47. <text v-else-if="!hasLogin" class="priceparam" @click.stop="this.$api.navigateTo('/pages/login/login')">登录查看价格></text>
  48. <text v-else-if="hasLogin && item.detailTalkFlag==2">¥详聊</text>
  49. <text v-else>¥{{ item.price | NumFormat}}</text>
  50. </view>
  51. <view class="shijian">
  52. <text class="iconfont icon-shijian"></text> {{item.onLineDateStr}}
  53. </view>
  54. <view class="dizhi">
  55. <view class="dizhi_left">
  56. <text class="iconfont icon-dizhi1"></text>
  57. {{item.provinceCityDistrict}}
  58. </view>
  59. <view class="liulan_right">
  60. <text class="iconfont icon-kejian1"></text>
  61. {{item.viewingNum ? item.viewingNum : '0'}}
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. <view v-if="showLoading && tabchildList.length > 4">
  67. <view class="loading-wrapper loading-wrapper-now" v-if="loadingNow">{{loadingText}}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view>
  68. <view class="loading-wrapper loading-wrapper-btm" v-else>———<text class="btm-text">已至底部</text>———</view>
  69. </view>
  70. </scroll-view>
  71. <view class="no-content" v-show="showflag" :class="showflag?'show':''">
  72. <image src="https://static.caimei365.com/app/img/bg/kong_m.png" />
  73. <view class="error-message">
  74. <view>该分类下面没有商品,请更换其它分类</view>
  75. </view>
  76. </view>
  77. </view>
  78. <view class="fabu" :style="{ paddingBottom :isIphoneX ? '68rpx' : '0rpx' }" v-if="identity == 1">
  79. <text class="intro long" @click.stop="navigator('/second/pages/form/introduce')" >二手市场介绍</text>
  80. </view>
  81. <view class="fabu" :style="{ paddingBottom :isIphoneX ? '68rpx' : '0rpx' }" v-else>
  82. <text class="intro" @click.stop="navigator('/second/pages/form/introduce')" >二手市场介绍</text>
  83. <text class="release" @click.stop="navigator('/second/pages/form/form')" >我要发布</text>
  84. </view>
  85. <!-- 透明模态层 -->
  86. <modal-layer v-if='isModallayer'></modal-layer>
  87. </view>
  88. </view>
  89. </template>
  90. <script>
  91. import authorize from '@/common/config/authorize.js'
  92. import wxLogin from "@/common/config/wxLogin.js"
  93. import modalLayer from "@/components/modal-layer"
  94. import { mapState,mapMutations } from 'vuex';
  95. export default{
  96. name:'secondList',
  97. components:{
  98. modalLayer
  99. },
  100. data(){
  101. return{
  102. isIphoneX:this.$store.state.isIphoneX,
  103. clickPath:'/search/pages/search/search-second',
  104. isShowClose:false,
  105. isModallayer:false,
  106. currentId:1,
  107. currentID2:0,
  108. isShow:false,
  109. requestFlag: true,
  110. showflag:false,
  111. mainflag:false,
  112. tabTitleName:'二手仪器',
  113. tabTitle: [
  114. {value:'1',name:'二手仪器'},
  115. {value:'2',name:'临期产品'},
  116. {value:'3',name:'其他'}
  117. ],
  118. tabList : [
  119. {value:'0',name:'全部'},
  120. {value:'1',name:'轻光电'},
  121. {value:'2',name:'重光电'},
  122. {value:'3',name:'耗材配件'},
  123. ],
  124. pageNum:1,
  125. pageSize:10,
  126. name:'',
  127. tabchildList:[],
  128. productsList:[],
  129. tabchild:{},
  130. params:{},
  131. hasNextPage:false ,
  132. showLoading: false,
  133. loadingNow: true,
  134. loadingText: '上拉加载更多',
  135. pullFlag: true,
  136. isShowEmpty: false,
  137. showSkeleton:true,
  138. windowHeight: '',
  139. scrollHeight: '',
  140. searchHide:true,
  141. }
  142. },
  143. created() {
  144. this.setScrollHeight();
  145. this.gettabList();
  146. },
  147. computed: {
  148. ...mapState(['hasLogin','userInfo','isWxAuthorize','identity'])
  149. },
  150. filters: {
  151. NumFormat:function(text) {//处理金额
  152. return Number(text).toFixed(2);
  153. },
  154. },
  155. onLoad(option) {
  156. if(option.type =='share'){
  157. authorize.getSetting().then(res =>{
  158. console.log('用户是否授权过',res)
  159. if(res == 1){
  160. wxLogin.wxLoginAuthorize()
  161. }else{
  162. console.log(new Date +'用户未授权微信信息')
  163. }
  164. })
  165. }
  166. },
  167. methods:{
  168. scrolltolower() {
  169. if(this.hasNextPage && this.pullFlag) {
  170. this.gettabList(true);
  171. }
  172. },
  173. setScrollHeight() {
  174. const {windowHeight, pixelRatio} = wx.getSystemInfoSync();
  175. this.windowHeight = windowHeight - 1;
  176. this.scrollHeight = windowHeight - 1;
  177. },
  178. handle: function (index) {//一級分类
  179. const _this = this;
  180. _this.currentId = index;
  181. _this.tabTitleName = '二手仪器';
  182. this.pageNum = 1
  183. if ( _this.currentId == '1'){
  184. _this.mainflag = !_this.mainflag;
  185. }else {
  186. _this.mainflag=false;
  187. _this.currentID2 = 0;
  188. }
  189. _this.gettabList();
  190. },
  191. handleChild:function(item){ //二级分类
  192. const _this = this;
  193. _this.currentID2 = item.value;
  194. _this.tabTitleName = item.name;
  195. if (_this.currentID2==item.value){
  196. _this.mainflag=false;
  197. }
  198. _this.gettabList();
  199. },
  200. navigator(url){
  201. this.$api.navigateTo(url)
  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. },
  259. onShareAppMessage(res){//分享转发
  260. if (res.from === 'button') {
  261. // 来自页面内转发按钮
  262. }
  263. return {
  264. title: `欢迎来到采美二手市场~`,
  265. path: `search/pages/search-instrument?keyWord=${this.listQuery.keyword}`
  266. }
  267. },
  268. onShow() {
  269. }
  270. }
  271. </script>
  272. <style lang="scss">
  273. .ClassA .iconfont{
  274. position: absolute;
  275. right: 20rpx;
  276. }
  277. .warp-container{
  278. width: 100%;
  279. height: 100%;
  280. }
  281. .good-search-top{
  282. width: 702rpx;
  283. height: 70rpx;
  284. flex: 1;
  285. margin: 20rpx auto;
  286. }
  287. .search-from{
  288. width: 702rpx;
  289. height: 66rpx;
  290. background: #F7F7F7;
  291. border-radius: 40rpx;
  292. float: left;
  293. position: relative;
  294. }
  295. .input{
  296. width: 340rpx;
  297. height: 66rpx;
  298. float: left;
  299. line-height: 66rpx;
  300. color: #b2b2b2;
  301. font-size: 28rpx;
  302. }
  303. .icon-iconfonticonfontsousuo1{
  304. width: 64rpx;
  305. height: 66rpx;
  306. line-height: 66rpx;
  307. text-align: center;
  308. display: block;
  309. font-size: 38rpx;
  310. float: left;
  311. color: #999999;
  312. }
  313. .icon-shanchu1{
  314. font-size:32rpx;
  315. color: #999999;
  316. position: absolute;
  317. width: 120rpx;
  318. height: 70rpx;
  319. line-height: 70rpx;
  320. top: 0;
  321. right: 0;
  322. text-align: center;
  323. z-index: 10;
  324. }
  325. .ListImg{
  326. width: 750rpx;
  327. height: 266rpx;
  328. }
  329. .banner-img{
  330. width: 100%;
  331. height: 100%;
  332. }
  333. .secondTitle {
  334. width: 100%;
  335. height:90rpx;
  336. background-color: #ffffff;
  337. border-bottom: 2rpx solid #F0F2F4;
  338. position: relative;
  339. }
  340. .ClassA.active {
  341. color: #E15621;
  342. }
  343. .ClassA {
  344. width: 240rpx;
  345. height: 90rpx;
  346. display: inline-block;
  347. text-align: center;
  348. line-height: 90rpx;
  349. font-size: 30rpx;
  350. cursor: pointer;
  351. color: #666666;
  352. border: 0;
  353. position: relative;
  354. .line {
  355. width: 10vw;
  356. margin: 0 auto;
  357. height: .48vw;
  358. background-color: #e15616;
  359. display: block;
  360. }
  361. }
  362. .mainTab {
  363. background: #fff;
  364. width: 29vw;
  365. position: absolute;
  366. z-index: 1;
  367. border-radius: 6rpx;
  368. box-shadow:0rpx 6rpx 12rpx 0rpx rgba(0, 0, 0, 0.07);
  369. .li{
  370. height: 80rpx;
  371. line-height: 80rpx;
  372. text-align: center;
  373. color: #627386;
  374. cursor: pointer;
  375. &.addstyle{
  376. color: #e15616;
  377. }
  378. }
  379. .line {
  380. width: 75rpx;
  381. margin: 0 auto;
  382. height: 4rpx;
  383. background-color: #e15616;
  384. display: block;
  385. }
  386. }
  387. .no-content{
  388. width: 100%;
  389. text-align: center;
  390. top: 50%;
  391. position: absolute;
  392. image{
  393. width: 306rpx;
  394. height: 212rpx;
  395. }
  396. }
  397. .error-message{
  398. font-size: 24rpx;
  399. color: #b2b2b2;
  400. }
  401. .Listitem {
  402. height: 202rpx;
  403. padding:30rpx 20rpx;
  404. border-bottom: 2rpx solid #F0F2F4;
  405. }
  406. .itemImg {
  407. width: 180rpx;
  408. height: 180rpx;
  409. float: left;
  410. background: #000;
  411. position: relative;
  412. .bigImg {
  413. width: 100%;
  414. height: 100%;
  415. }
  416. }
  417. .activeImg {
  418. opacity: 0.5;
  419. }
  420. .ItemInfo {
  421. float: right;
  422. width:500rpx;
  423. .dizhi{
  424. font-size: 24rpx;
  425. color: #999999;
  426. margin-top: 10rpx;
  427. }
  428. .shijian{
  429. font-size: 24rpx;
  430. color: #999999;
  431. margin-top: 10rpx;
  432. }
  433. }
  434. .infotag{
  435. font-size: 20rpx;
  436. padding: 5rpx 15rpx;
  437. background: #f94b4b;
  438. color: #fff;
  439. position: absolute;
  440. border-radius: 6rpx;
  441. }
  442. .productname{
  443. display: inline-block;
  444. font-size: 28rpx;
  445. color: #333333;
  446. vertical-align: top;
  447. text-overflow: -o-ellipsis-lastline;
  448. overflow: hidden;
  449. text-overflow: ellipsis;
  450. display: -webkit-box;
  451. -webkit-line-clamp: 2;
  452. line-clamp: 2;
  453. -webkit-box-orient: vertical;
  454. width: 500rpx;
  455. }
  456. .targetprice {
  457. font-size: 26rpx;
  458. color: #f94b4b;
  459. cursor: pointer;
  460. margin: 15rpx 0;
  461. }
  462. .icon-shijian{
  463. font-size: 30rpx;
  464. color: #999999;
  465. margin-right: 10rpx;
  466. }
  467. .icon-kejian1{
  468. font-size: 30rpx;
  469. color: #999999;
  470. margin-right: 10rpx;
  471. }
  472. .icon-dizhi1{
  473. font-size: 30rpx;
  474. color: #999999;
  475. margin-right: 10rpx;
  476. }
  477. .dizhi_left{
  478. float: left;
  479. }
  480. .liulan_right{
  481. float: right;
  482. margin-right: 25rpx;
  483. }
  484. .itemImg {
  485. .yishou_bg{
  486. width: 90rpx;
  487. height: 90rpx;
  488. position: absolute;
  489. top: 50%;
  490. left: 50%;
  491. transform: translate(-50%, -50%)
  492. }
  493. }
  494. .fabu{
  495. position: fixed;
  496. bottom: 0;
  497. width: 100%;
  498. background: #fff;
  499. padding-top: 20rpx;
  500. text{
  501. display: inline-block;
  502. width: 280rpx;
  503. height: 84rpx;
  504. line-height: 84rpx;
  505. text-align: center;
  506. border-radius: 42rpx;
  507. margin: 15rpx;
  508. font-size: 30rpx;
  509. &.intro{
  510. background: #ffe6dc;
  511. color: #e15616;
  512. &.long{
  513. width: 600rpx;
  514. display: block;
  515. margin: 0 auto;
  516. }
  517. }
  518. &.release{
  519. background: $btn-confirm;
  520. color: #ffffff;
  521. width: 402rpx;
  522. }
  523. }
  524. }
  525. </style>