product-list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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"
  31. v-for="(item,index) in tabList"
  32. @click='handleChild(item)'
  33. :key="index"
  34. :class="currentID2 ==index?'addstyle':' '">
  35. {{item.name}}
  36. </view>
  37. </view>
  38. <view class="shopList" :style="{'overflow':(showSkeleton? 'hidden' : 'auto'),'height': (showSkeleton? windowHeight + 'px' : 'auto')}">
  39. <scroll-view :style="{'height':scrollHeight+'px'}" @scrolltolower="scrolltolower" scroll-y v-if="tabchildList.length > 0">
  40. <view class="Listitem" v-if="isShow" v-for="(item, index) in tabchildList" :key="index" :class="item.sold==1?'activeImg':''"
  41. :productid="item.productId" @click.stop="navToDetailPage(item.productId)">
  42. <view class="itemImg onhref" >
  43. <image :src="item.imageList[0]" class="bigImg"></image>
  44. <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>
  45. </view>
  46. <view class="ItemInfo">
  47. <text class="infotag news" v-if="item.sold==0&&item.newAdded==1">新</text>
  48. <view class="productname" href="" :style="item.sold==0&&item.newAdded==1?'text-indent:60rpx':''">
  49. {{item.name}}
  50. </view>
  51. <view class="targetprice">
  52. <text v-if="item.detailTalkFlag ==2 && !hasLogin">¥价格详聊</text>
  53. <text v-else-if="!hasLogin" class="priceparam" @click.stop="NavigatorLogin(item)">
  54. <text v-if="item.sold==1">已售二手商品不公开价格</text>
  55. <text v-else>登录查看价格></text>
  56. </text>
  57. <text v-else-if="hasLogin && item.detailTalkFlag==2">
  58. <text v-if="item.sold == 1">已售二手商品不公开价格</text>
  59. <text v-else>¥价格详聊</text>
  60. </text>
  61. <text v-else>
  62. <text v-if="item.sold == 1">已售二手商品不公开价格</text>
  63. <text v-else>¥{{ item.price | NumFormat}}</text>
  64. </text>
  65. </view>
  66. <view class="shijian">
  67. <text class="iconfont icon-shijian"></text> {{item.onLineDateStr}}
  68. </view>
  69. <view class="dizhi">
  70. <view class="dizhi_left">
  71. <text class="iconfont icon-dizhi1"></text>
  72. {{item.provinceCityDistrict}}
  73. </view>
  74. <view class="liulan_right">
  75. <text class="iconfont icon-kejian1"></text>
  76. {{item.viewingNum ? item.viewingNum : '0'}}
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. <view v-if="showLoading && tabchildList.length > 4">
  82. <view class="loading-wrapper loading-wrapper-now" v-if="loadingNow">{{loadingText}}<text v-if="loadingText === '已至底部'">‧ ‧ ‧</text></view>
  83. <view class="loading-wrapper loading-wrapper-btm" v-else>———<text class="btm-text">已至底部</text>———</view>
  84. </view>
  85. </scroll-view>
  86. <view class="no-content" v-show="showflag" :class="showflag?'show':''">
  87. <image src="https://static.caimei365.com/app/img/bg/kong_m.png" />
  88. <view class="error-message">
  89. <view>该分类下面没有商品,请更换其它分类</view>
  90. </view>
  91. </view>
  92. </view>
  93. <view class="fabu" :style="{ paddingBottom :isIphoneX ? '68rpx' : '0rpx' }" v-if="identity == 1">
  94. <text class="intro long" @click.stop="navigator('/pages/second/form/introduce')" >二手市场介绍</text>
  95. </view>
  96. <view class="fabu" :style="{ paddingBottom :isIphoneX ? '68rpx' : '0rpx' }" v-else>
  97. <text class="intro" @click.stop="navigator('/pages/second/form/introduce')" >二手市场介绍</text>
  98. <text class="release" @click.stop="NavigatorRelease" >我要发布</text>
  99. </view>
  100. <!-- 透明模态层 -->
  101. <modal-layer v-if='isModallayer'></modal-layer>
  102. </view>
  103. </view>
  104. </template>
  105. <script>
  106. import authorize from '@/common/config/authorize.js'
  107. import wxLogin from "@/common/config/wxLogin.js"
  108. import modalLayer from "@/components/modal-layer"
  109. import { mapState,mapMutations } from 'vuex';
  110. export default{
  111. name:'secondList',
  112. components:{
  113. modalLayer
  114. },
  115. data(){
  116. return{
  117. userId:0,
  118. isIphoneX:this.$store.state.isIphoneX,
  119. clickPath:'/pages/search/search-second',
  120. isShowClose:false,
  121. isModallayer:false,
  122. currentId:1,
  123. currentID2:0,
  124. isShow:false,
  125. requestFlag: true,
  126. showflag:false,
  127. mainflag:false,
  128. tabTitleName:'二手仪器',
  129. tabTitle: [
  130. {value:'1',name:'二手仪器'},
  131. {value:'2',name:'临期产品'},
  132. {value:'3',name:'其他'}
  133. ],
  134. tabList : [
  135. {value:'0',name:'全部'},
  136. {value:'1',name:'美容仪器'}
  137. ],
  138. pageNum:1,
  139. pageSize:10,
  140. name:'',
  141. tabchildList:[],
  142. productsList:[],
  143. tabchild:{},
  144. params:{},
  145. hasNextPage:false ,
  146. showLoading: false,
  147. loadingNow: true,
  148. loadingText: '上拉加载更多',
  149. pullFlag: true,
  150. isShowEmpty: false,
  151. showSkeleton:true,
  152. windowHeight: '',
  153. scrollHeight: '',
  154. searchHide:true,
  155. }
  156. },
  157. created() {
  158. this.setScrollHeight();
  159. this.$api.getStorage().then((resolve) => {
  160. this.userId = resolve.userId ? resolve.userId : '';
  161. this.gettabList();
  162. })
  163. },
  164. computed: {
  165. ...mapState(['hasLogin','userInfo','isWxAuthorize','identity'])
  166. },
  167. filters: {
  168. NumFormat:function(text) {//处理金额
  169. return Number(text).toFixed(2);
  170. },
  171. },
  172. onLoad(option) {
  173. if(option.type =='share'){
  174. wxLogin.wxLoginAuthorize()
  175. }
  176. },
  177. methods:{
  178. scrolltolower() {
  179. if(this.hasNextPage && this.pullFlag) {
  180. this.gettabList(true);
  181. }
  182. },
  183. setScrollHeight() {
  184. const {windowHeight, pixelRatio} = wx.getSystemInfoSync();
  185. this.windowHeight = windowHeight - 1;
  186. this.scrollHeight = windowHeight - 1;
  187. },
  188. handle: function (index) {//一級分类
  189. const _this = this;
  190. _this.currentId = index;
  191. _this.tabTitleName = '二手仪器';
  192. this.pageNum = 1
  193. if ( _this.currentId == '1'){
  194. _this.mainflag = !_this.mainflag;
  195. }else {
  196. _this.mainflag=false;
  197. _this.currentID2 = 0;
  198. }
  199. _this.gettabList();
  200. },
  201. handleChild:function(item){ //二级分类
  202. const _this = this;
  203. _this.currentID2 = item.value;
  204. _this.tabTitleName = item.name;
  205. if (_this.currentID2==item.value){
  206. _this.mainflag=false;
  207. }
  208. _this.gettabList();
  209. },
  210. navigator(url){
  211. this.$api.navigateTo(url)
  212. },
  213. navToDetailPage:function(id) {
  214. this.isModallayer = true;
  215. this.$api.navigateTo(`/pages/second/product/product-details?id=${id}`);
  216. this.isModallayer = false;
  217. },
  218. gettabList:function (loadMore) {
  219. this.showLoading = true;
  220. this.loadingNow = true;
  221. this.loadingText = '加载中';
  222. this.isShowEmpty = false;
  223. if(loadMore) {this.pageNum += 1;}
  224. let params = {
  225. userId:this.userId,
  226. secondHandType:this.currentId,
  227. instrumentType:this.currentID2,
  228. name:this.name,
  229. pageNum:this.pageNum,
  230. pageSize:this.pageSize
  231. }
  232. this.SecondService.SeconHandProductList(params).then(res =>{
  233. if (res.code == 0) {
  234. const data = res.data;
  235. if(data.results.length == 0){
  236. this.tabchildList = [];
  237. this.showflag = true;
  238. this.listRecord = data.totalRecord;
  239. }else {
  240. this.showflag = false;
  241. this.isShow = true;
  242. let results = data.results;
  243. if(loadMore) {
  244. this.tabchildList = [...this.tabchildList,...results];
  245. } else {
  246. this.tabchildList = [...results];
  247. this.showSkeleton = false;
  248. }
  249. this.hasNextPage = data.hasNextPage;
  250. this.listRecord = data.totalRecord;
  251. }
  252. // 防上拉暴滑
  253. this.pullFlag = false;
  254. setTimeout(()=>{ this.pullFlag = true; },500)
  255. // 底部提示文案
  256. if(this.hasNextPage) {
  257. this.loadingText = '上拉加载更多';
  258. } else {
  259. this.showLoading = true;
  260. this.loadingNow = false;
  261. this.loadingText = '已至底部';
  262. }
  263. }else{
  264. this.$util.msg(error.msg,2000);
  265. }
  266. this.requestFlag = true;
  267. })
  268. },
  269. NavigatorLogin(pros){// 登录查看价格
  270. // 友盟埋点二手市场列表登录查看价格点击事件
  271. if(process.env.NODE_ENV != 'development'){
  272. this.$uma.trackEvent('Um_Event_SecondListLoginSubmit', {
  273. Um_Key_ProductId: `${pros.productId}`,
  274. Um_Key_PageName: '二手市场登录查看价格',
  275. Um_Key_SourcePage: '二手市场列表',
  276. })
  277. }
  278. this.$api.navigateTo('/pages/login/login')
  279. },
  280. NavigatorRelease(){// 我要发布
  281. // 友盟埋点二手市场列表我要发布点击事件
  282. if(process.env.NODE_ENV != 'development'){
  283. this.$uma.trackEvent('Um_Event_SecondReleaseSubmit', {
  284. Um_Key_PageName: '我要发布',
  285. Um_Key_SourcePage: '二手市场列表',
  286. })
  287. }
  288. this.$api.navigateTo('/pages/second/form/form')
  289. }
  290. },
  291. onShareAppMessage(res){//分享转发
  292. if (res.from === 'button') {
  293. // 来自页面内转发按钮
  294. }
  295. return {
  296. title: `欢迎来到采美二手市场~`,
  297. path: `pages/search/search-instrument?keyWord=${this.listQuery.keyword}`
  298. }
  299. },
  300. onShow() {
  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. position: fixed;
  528. bottom: 0;
  529. width: 100%;
  530. background: #fff;
  531. padding-top: 20rpx;
  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. &.intro{
  542. background: #ffe6dc;
  543. color: #e15616;
  544. &.long{
  545. width: 600rpx;
  546. display: block;
  547. margin: 0 auto;
  548. }
  549. }
  550. &.release{
  551. background: $btn-confirm;
  552. color: #ffffff;
  553. width: 402rpx;
  554. }
  555. }
  556. }
  557. </style>