product-list.vue 22 KB

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