product-list.vue 15 KB

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