product-list.vue 20 KB

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