product-list.vue 14 KB

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