index.vue 16 KB

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