index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. <template>
  2. <view class="core-cla">
  3. <u-navbar leftIconSize="0" :placeholder="true" bgColor="#ffffff">
  4. <view class="u-nav-slot" slot="left">
  5. <text>兑换大厅</text>
  6. </view>
  7. </u-navbar>
  8. <!-- swiper开始 -->
  9. <view class="swiper-ban" v-if="imgTop.length">
  10. <view class="uni-padding-wrap">
  11. <view class="page-section swiper">
  12. <view class="page-section-spacing">
  13. <swiper class="swiper" :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval"
  14. :duration="duration">
  15. <swiper-item v-for="(item,index) in imgTop" :key="index"
  16. @click="toCoreRange(item.type,item.type=='link'?item.linkUrl:item.goodsTags, item.name)">
  17. <img :src="item.picUrl" alt="">
  18. </swiper-item>
  19. </swiper>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <!-- 分类部分开始 -->
  25. <view class="classificationBox">
  26. <view v-for="(item,index) in goods" :key="index" @click="toCoreRange('category',item.categoryId, item.name)"
  27. class="ificationBox-mar">
  28. <img :src="item.picUrl" alt="">
  29. <view v-text="item.name" style=" "></view>
  30. </view>
  31. </view>
  32. <!-- 限时秒杀部分开始 -->
  33. <view v-for="(item,index) in exclusiveSingle" :key="index" class="sticky-wrap">
  34. <view class=" sticky-nav">
  35. <text class="sticky-nav-name" v-text="item.name"></text>
  36. <view @click="toCoreRange('tag',item.tagId, item.name)" class="sticky-nav-all">
  37. <view></view>
  38. <view class="flex ">
  39. <text>更多</text>
  40. <u-icon name="arrow-right" color="#9c9c9c" size="16"></u-icon>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="sticky-content-wrap">
  45. <view class="flex sticky-content-list">
  46. <navigator :url="`/pages/goods/detail?id=${ itemExc.goodsId }`" class="sticky-content-list-item"
  47. hover-class="navigator-hover" v-for="(itemExc, indexNum) in item.data" :key="indexNum">
  48. <view class="flex iamge-wrap">
  49. <image :src="itemExc.picUrl" mode=""></image>
  50. </view>
  51. <view class="title">{{ itemExc.title }}</view>
  52. <view class="bean">
  53. <image src="../../static/icon/bean.png" mode="aspectFill"></image>
  54. <view>× {{ itemExc.exchangePrice }}</view>
  55. </view>
  56. </navigator>
  57. <view class="sticky-content-list-item"></view>
  58. </view>
  59. </view>
  60. </view>
  61. <!-- 精选商品筛选 -->
  62. <u-sticky class="offset-Height" :customNavHeight="navHeight" @touchmove.prevent.stop>
  63. <view class="screen-coin uSticky-toTop">
  64. <view class="screen-coin-shopin">精选商品</view>
  65. <view class="flex screen-coin-select">
  66. <view @click="ascSelect" class="flex screen-coin-select-text">
  67. <view class="title">
  68. <text>{{ ascListsingle.text}}</text>
  69. </view>
  70. <u-icon name="arrow-up" color="#848484" size="18" v-if="ascShow"></u-icon>
  71. <u-icon name="arrow-down" color="#848484" size="18" v-else></u-icon>
  72. </view>
  73. <view class="screen-coin-select-line"></view>
  74. <view @click="openSelect" class="flex screen-coin-select-text screen-coin-select-text-two">
  75. <view class="title">
  76. <text v-if="actionInfo.min">{{ actionInfo.min }}</text>
  77. <text v-if="actionInfo.max">-{{ actionInfo.max }}</text>
  78. <text>{{ actionInfo.desc }}</text>
  79. </view>
  80. <u-icon name="arrow-up" color="#848484" size="18" v-if="coinShow"></u-icon>
  81. <u-icon name="arrow-down" color="#848484" size="18" v-else></u-icon>
  82. </view>
  83. </view>
  84. <view class="screen-coin-list" v-if="ascShow">
  85. <view class="flex screen-coin-list-item" v-for="(item, index) in ascList" :key="index"
  86. @click="selectCoinTwo(item, index)">
  87. <text :class="{ 'action': ascListIndex == index }">{{ item.text }}</text>
  88. </view>
  89. </view>
  90. <view class="screen-coin-list" v-if="coinShow">
  91. <view class="flex screen-coin-list-item" v-for="(item, index) in coinList" :key="index"
  92. @click="selectCoin(item, index)">
  93. <text v-if="item.min" :class="{ 'action': actionIndex == index }">{{ item.min }}</text>
  94. <text v-if="item.max" :class="{ 'action': actionIndex == index }">-{{ item.max }}</text>
  95. <text :class="{ 'action': actionIndex == index }">{{ item.desc }}</text>
  96. </view>
  97. </view>
  98. </view>
  99. </u-sticky>
  100. <!-- 精选商品列表 -->
  101. <view class="core">
  102. <view class="flex core-list">
  103. <navigator :url="`/pages/goods/detail?id=${ item.goodsId }`" class="core-list-item"
  104. hover-class="navigator-hover" v-for="(item, index) in list" :key="index">
  105. <view class="flex iamge-wrap">
  106. <image :src="item.picUrl" mode=""></image>
  107. </view>
  108. <view class="title">{{ item.title }}</view>
  109. <view class="bean">
  110. <image src="../../static/icon/bean.png" mode="aspectFill"></image>
  111. <view>× {{ item.exchangePrice }}</view>
  112. </view>
  113. </navigator>
  114. <view class="core-list-item"></view>
  115. </view>
  116. <view class="flex empty" v-if="!list.length">
  117. <u-empty text="数据为空" mode="order" />
  118. </view>
  119. </view>
  120. <custom-tab-bar :activeValue="'core'" />
  121. <!-- 筛选盲豆 -->
  122. <u-overlay :show="coinShow" @click="coinShow = false" zIndex="1" @touchmove.prevent.stop></u-overlay>
  123. <!-- 筛选排序 -->
  124. <u-overlay :show="ascShow" @click="ascShow = false" zIndex="1" @touchmove.prevent.stop></u-overlay>
  125. <custom-tab-bar :activeValue="'core'" />
  126. </view>
  127. </template>
  128. <script>
  129. import env from '../../config/env.js'
  130. import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
  131. import $http from '@/utils/request.js'
  132. export default {
  133. components: {
  134. CustomTabBar,
  135. },
  136. data() {
  137. return {
  138. indicatorDots: true,
  139. autoplay: true,
  140. interval: 3000,
  141. duration: 500,
  142. imgTop: [],
  143. goods: [],
  144. exclusive: [],
  145. exclusiveSingle: [],
  146. pageNum: 1,
  147. total: 0,
  148. list: [],
  149. coinShow: false,
  150. coinList: [{
  151. min: null,
  152. max: null,
  153. desc: '全部价格'
  154. },
  155. {
  156. min: 1,
  157. max: 20,
  158. desc: '盲豆'
  159. },
  160. {
  161. min: 21,
  162. max: 40,
  163. desc: '盲豆'
  164. },
  165. {
  166. min: 41,
  167. max: 60,
  168. desc: '盲豆'
  169. },
  170. {
  171. min: 61,
  172. max: 80,
  173. desc: '盲豆'
  174. },
  175. {
  176. min: 81,
  177. max: 100,
  178. desc: '盲豆'
  179. },
  180. {
  181. min: 101,
  182. max: 200,
  183. desc: '盲豆'
  184. },
  185. {
  186. min: 201,
  187. max: 500,
  188. desc: '盲豆'
  189. },
  190. {
  191. min: 501,
  192. max: 1000,
  193. desc: '盲豆'
  194. },
  195. {
  196. min: 1001,
  197. max: 5000,
  198. desc: '盲豆'
  199. },
  200. {
  201. min: 5000,
  202. max: null,
  203. desc: '盲豆以上'
  204. },
  205. ],
  206. actionInfo: {},
  207. actionIndex: 0,
  208. coinNum: {
  209. startPrice: null,
  210. endPrice: null
  211. },
  212. orderByColumn: '', //默认exchangePrice
  213. isAsc: '', //从低到高asc isAsc:'desc'从高到低
  214. ascShow: false,
  215. ascList: [{
  216. data: '',
  217. text: '默认排序'
  218. },
  219. {
  220. data: 'asc',
  221. text: '价格从低到高'
  222. },
  223. {
  224. data: 'desc',
  225. text: '价格从高到低'
  226. },
  227. ],
  228. ascListsingle: {},
  229. ascListIndex: 0,
  230. // 距顶部位置
  231. navHeight: 0,
  232. };
  233. },
  234. onLoad() {
  235. this.pageList()
  236. this.actionInfo = this.coinList[this.actionIndex]
  237. this.ascListsingle = this.ascList[this.ascListIndex]
  238. this.getSwiper()
  239. this.getListIficationBox()
  240. this.getExclusive()
  241. uni.getSystemInfo({
  242. success: (data) => {
  243. let custom = wx.getMenuButtonBoundingClientRect()
  244. //导航栏高度
  245. this.navHeight = custom.bottom + custom.top - data.statusBarHeight
  246. },
  247. })
  248. },
  249. methods: {
  250. changeIndicatorDots(e) {
  251. this.indicatorDots = true
  252. },
  253. changeAutoplay(e) {
  254. this.autoplay = true
  255. },
  256. intervalChange(e) {
  257. this.interval = e.target.value
  258. },
  259. durationChange(e) {
  260. this.duration = e.target.value
  261. },
  262. // 跳转点击事件
  263. toCoreRange(type, data, name) {
  264. if (type == "link") {
  265. // web-view
  266. } else {
  267. uni.navigateTo({
  268. url: `/pages/coreRange/coreRange?type=${ type }&data=${ data }&name=${ name }`,
  269. })
  270. }
  271. },
  272. //轮播图
  273. getSwiper() {
  274. $http.post(`/api/v1/mp/user/exchange/banner/list`, {
  275. noToken: true,
  276. location: "top"
  277. }).then(res => {
  278. res.data.forEach(item => {
  279. let picUrlArr = item.picUrl.split(',')
  280. item.picUrl = env.filePublic + picUrlArr[0]
  281. })
  282. this.imgTop = this.imgTop.concat(res.data)
  283. })
  284. },
  285. // 分类列表
  286. getListIficationBox() {
  287. $http.post(`/api/v1/mp/user/exchange/category/list`, {
  288. noToken: true
  289. }).then(res => {
  290. res.data.forEach(item => {
  291. let picUrlArr = item.picUrl.split(',')
  292. item.picUrl = env.filePublic + picUrlArr[0]
  293. })
  294. this.goods = this.goods.concat(res.data)
  295. })
  296. },
  297. // 秒杀
  298. async getExclusive() {
  299. let resData = await $http.post(`/api/v1/mp/user/exchange/activity/list`, {
  300. noToken: true
  301. })
  302. let goodsList = []
  303. for (let item of resData.data) {
  304. let resDatas = await $http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=1&pageSize=4`, {
  305. noToken: true,
  306. tagIds: item.tagId
  307. })
  308. goodsList.push({
  309. data: resDatas.rows,
  310. name: item.name,
  311. tagId: item.tagId
  312. })
  313. }
  314. goodsList.forEach(item => {
  315. item.data.forEach(items => {
  316. items.picUrl = env.filePublic + items.picUrl.split(',')[0]
  317. })
  318. })
  319. this.exclusiveSingle = goodsList
  320. },
  321. //精选商品部分
  322. getList() {
  323. uni.showLoading({
  324. title: '加载中'
  325. });
  326. let data = {
  327. categoryId: this.categoryId,
  328. tagIds: this.tagIds,
  329. ...this.coinNum,
  330. noToken: true
  331. }
  332. $http.post(
  333. `/api/v1/mp/user/exchange/goods/list?pageNum=${this.pageNum}&pageSize=20&orderByColumn=${this.orderByColumn}&isAsc=${this.isAsc}`,
  334. data).then(
  335. res => {
  336. uni.hideLoading();
  337. if (res.code == 0) {
  338. res.rows.forEach(item => {
  339. let picUrlArr = item.picUrl.split(',')
  340. item.picUrl = env.filePublic + picUrlArr[0]
  341. })
  342. this.total = res.total
  343. this.list = this.list.concat(res.rows)
  344. }
  345. }).catch(() => {
  346. uni.hideLoading();
  347. })
  348. },
  349. pageList() {
  350. this.pageNum = 1
  351. this.total = 0
  352. this.list = []
  353. this.getList()
  354. },
  355. pageListTwo() {
  356. this.pageNum = 1
  357. this.total = 0
  358. this.list = []
  359. this.getList()
  360. },
  361. openSelect() {
  362. if (this.coinShow == false) {
  363. this.coinShow = true
  364. this.ascShow = false
  365. uni.createSelectorQuery().select(".core-cla").boundingClientRect((res) => {
  366. uni.createSelectorQuery().select(".screen-coin-select-text-two").boundingClientRect((
  367. data) => {
  368. uni.pageScrollTo({
  369. duration: 0,
  370. scrollTop: -res.top + data.top + 350,
  371. })
  372. }).exec()
  373. }).exec()
  374. } else {
  375. this.coinShow = false
  376. }
  377. },
  378. //排序切换
  379. ascSelect() {
  380. if (this.ascShow == false) {
  381. this.ascShow = true
  382. this.coinShow = false
  383. uni.createSelectorQuery().select(".core-cla").boundingClientRect((res) => {
  384. uni.createSelectorQuery().select(".screen-coin-select-text").boundingClientRect((data) => {
  385. uni.pageScrollTo({
  386. duration: 0, //过渡时间必须为0,uniapp bug,否则运行到手机会报错
  387. scrollTop: -res.top + data.top,
  388. })
  389. }).exec()
  390. }).exec()
  391. } else {
  392. this.ascShow = false
  393. }
  394. },
  395. selectCoin(item, index) {
  396. this.actionIndex = index
  397. this.actionInfo = this.coinList[this.actionIndex]
  398. this.coinShow = false
  399. this.coinNum.startPrice = item.min
  400. this.coinNum.endPrice = item.max
  401. this.pageList()
  402. },
  403. selectCoinTwo(item, index) {
  404. this.ascListIndex = index
  405. this.ascListsingle = this.ascList[this.ascListIndex]
  406. this.ascShow = false
  407. if (item.data == '') {
  408. this.orderByColumn = ''
  409. this.isAsc = ''
  410. } else {
  411. this.isAsc = item.data
  412. this.orderByColumn = 'exchangePrice'
  413. }
  414. this.pageListTwo()
  415. },
  416. },
  417. //精选商品
  418. onReachBottom() {
  419. // 判断是否有数据
  420. if (this.total > this.pageNum * 20) {
  421. setTimeout(() => {
  422. ++this.pageNum
  423. this.getList()
  424. }, 500)
  425. } else {
  426. uni.$u.toast('没有更多数据了')
  427. }
  428. },
  429. }
  430. </script>
  431. <style lang="scss" scoped>
  432. .u-nav-slot {
  433. text {
  434. font-size: 32rpx;
  435. }
  436. }
  437. </style>
  438. <style lang="scss" scoped>
  439. .swiper-ban {
  440. background-color: #FFFFFF;
  441. padding: 0 3px;
  442. .uni-padding-wrap {
  443. width: 95%;
  444. margin: 0 auto;
  445. border-radius: 10rpx;
  446. overflow: hidden;
  447. }
  448. }
  449. .uni-padding-wrap image {
  450. width: 100%;
  451. height: 100%;
  452. }
  453. .classificationBox {
  454. background-color: #FFFFFF;
  455. display: grid;
  456. grid-template-columns: 1fr 1fr 1fr 1fr;
  457. font-size: 12px;
  458. .ificationBox-mar {
  459. margin: 0 auto;
  460. text-align: center;
  461. margin-top: 10px;
  462. margin-bottom: 10px;
  463. }
  464. }
  465. .ificationBox-mar img {
  466. width: 44px;
  467. height: 44px;
  468. border-radius: 29px;
  469. }
  470. .sticky-wrap {
  471. .sticky-nav {
  472. border: 1px;
  473. border-radius: 20rpx 20rpx 0 0;
  474. background-color: #FFFFFF;
  475. margin: 20rpx 20rpx 0 20rpx;
  476. .sticky-nav-name {
  477. color: #2f2f2f;
  478. font-size: 18px;
  479. line-height: 25px;
  480. display: inline-block;
  481. padding: 8px;
  482. }
  483. .sticky-nav-all {
  484. width: 128px;
  485. height: 40px;
  486. text-align: right;
  487. line-height: 40px;
  488. color: #848484;
  489. float: right;
  490. display: grid;
  491. grid-template-columns: 1fr 1fr;
  492. }
  493. }
  494. .sticky-content-wrap {
  495. margin: 0 20rpx;
  496. border-radius: 0 0 20rpx 20rpx;
  497. overflow: hidden;
  498. .sticky-content-list {
  499. width: 100%;
  500. background-color: #FFFFFF;
  501. justify-content: space-around;
  502. flex-wrap: wrap;
  503. padding-top: 20rpx;
  504. &-item {
  505. box-sizing: border-box;
  506. width: 320rpx;
  507. height: 460rpx;
  508. background-color: #FFFFFF;
  509. border-radius: 10rpx;
  510. margin-bottom: 30rpx;
  511. .iamge-wrap {
  512. image {
  513. border-radius: 10rpx;
  514. width: 320rpx;
  515. height: 320rpx;
  516. margin-bottom: 6rpx;
  517. }
  518. }
  519. .title {
  520. padding: 0 14rpx;
  521. font-size: 28rpx;
  522. ;
  523. overflow: hidden;
  524. text-overflow: ellipsis;
  525. display: -webkit-box;
  526. -webkit-box-orient: vertical;
  527. -webkit-line-clamp: 2;
  528. }
  529. .bean {
  530. padding: 0 14rpx;
  531. display: flex;
  532. align-items: center;
  533. font-size: 32rpx;
  534. line-height: 44rpx;
  535. color: rgba(235, 112, 9, 100);
  536. margin-top: 12rpx;
  537. image {
  538. width: 42rpx;
  539. height: 42rpx;
  540. margin-right: 16rpx;
  541. }
  542. }
  543. }
  544. &-item:last-child {
  545. padding: 0;
  546. height: 0;
  547. }
  548. }
  549. }
  550. .sticky-content-wrap:last-child {
  551. margin-bottom: 20rpx;
  552. }
  553. }
  554. .screen-coin-shopin {
  555. color: #2f2f2f;
  556. font-size: 36rpx;
  557. line-height: 16rpx;
  558. display: inline-block;
  559. padding: 18px 8px 0px 8px;
  560. }
  561. .screen-coin-select-text {
  562. color: #848484;
  563. }
  564. .screen-coin-select-line {
  565. border-right: 3rpx solid #848484;
  566. width: 26rpx;
  567. height: 26rpx;
  568. }
  569. .screen-coin {
  570. width: 100%;
  571. z-index: 10;
  572. background-color: #FFFFFF;
  573. border-top: 1px solid #F8F8F8;
  574. box-shadow: 0 4rpx 10rpx 0 rgba(151, 151, 151, 0.24);
  575. &-select {
  576. height: 86rpx;
  577. line-height: 86rpx;
  578. width: 100%;
  579. justify-content: flex-start;
  580. .title {
  581. padding-left: 20rpx;
  582. margin-right: 10rpx;
  583. }
  584. }
  585. &-list {
  586. width: 100%;
  587. background-color: #FFFFFF;
  588. border-top: 1px solid #F8F8F8;
  589. &-item {
  590. height: 86rpx;
  591. line-height: 86rpx;
  592. background-color: #FFFFFF;
  593. border-bottom: 1px solid #F8F8F8;
  594. }
  595. &-item:last-child {
  596. border: 0;
  597. }
  598. .action {
  599. color: $uni-text-color;
  600. }
  601. }
  602. }
  603. .core {
  604. margin: 20rpx 0;
  605. &-list {
  606. justify-content: space-evenly;
  607. flex-wrap: wrap;
  608. &-item {
  609. box-sizing: border-box;
  610. width: 340rpx;
  611. height: 502rpx;
  612. background-color: #FFFFFF;
  613. border-radius: 10rpx;
  614. margin-bottom: 30rpx;
  615. .iamge-wrap {
  616. image {
  617. border-top-left-radius: 10rpx;
  618. border-top-right-radius: 10rpx;
  619. width: 340rpx;
  620. height: 340rpx;
  621. margin-bottom: 6rpx;
  622. }
  623. }
  624. .title {
  625. padding: 0 14rpx;
  626. font-size: 28rpx;
  627. // line-height: 40rpx;
  628. overflow: hidden;
  629. text-overflow: ellipsis;
  630. display: -webkit-box;
  631. -webkit-box-orient: vertical;
  632. -webkit-line-clamp: 2;
  633. }
  634. .bean {
  635. padding: 0 14rpx;
  636. display: flex;
  637. align-items: center;
  638. font-size: 32rpx;
  639. line-height: 44rpx;
  640. color: rgba(235, 112, 9, 100);
  641. margin-top: 12rpx;
  642. image {
  643. width: 42rpx;
  644. height: 42rpx;
  645. margin-right: 16rpx;
  646. }
  647. }
  648. }
  649. &-item:last-child {
  650. padding: 0;
  651. height: 0;
  652. }
  653. }
  654. .empty {
  655. height: 60vh;
  656. }
  657. }
  658. </style>
  659. <style lang="scss" scoped>
  660. </style>