product-list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562
  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. uni.setStorageSync('pageLabel','二手市场')
  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: 265rpx;
  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>