product-list.vue 15 KB

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