product-list.vue 14 KB

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