index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  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. <image :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 -6
  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. uni.navigateTo({
  266. url: `/pages/webview/index?url=${ data }`,
  267. })
  268. } else {
  269. uni.navigateTo({
  270. url: `/pages/coreRange/coreRange?type=${ type }&data=${ data }&name=${ name }`,
  271. })
  272. }
  273. },
  274. //轮播图
  275. getSwiper() {
  276. $http.post(`/api/v1/mp/user/exchange/banner/list`, {
  277. noToken: true,
  278. location: "top"
  279. }).then(res => {
  280. res.data.forEach(item => {
  281. let picUrlArr = item.picUrl.split(',')
  282. item.picUrl = env.filePublic + picUrlArr[0]
  283. })
  284. this.imgTop = this.imgTop.concat(res.data)
  285. })
  286. },
  287. // 分类列表
  288. getListIficationBox() {
  289. $http.post(`/api/v1/mp/user/exchange/category/list`, {
  290. noToken: true
  291. }).then(res => {
  292. res.data.forEach(item => {
  293. let picUrlArr = item.picUrl.split(',')
  294. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/340'
  295. })
  296. this.goods = this.goods.concat(res.data)
  297. })
  298. },
  299. // 秒杀
  300. async getExclusive() {
  301. let resData = await $http.post(`/api/v1/mp/user/exchange/activity/list`, {
  302. noToken: true
  303. })
  304. let goodsList = []
  305. for (let item of resData.data) {
  306. let resDatas = await $http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=1&pageSize=4`, {
  307. noToken: true,
  308. tagIds: item.tagId
  309. })
  310. goodsList.push({
  311. data: resDatas.rows,
  312. name: item.name,
  313. tagId: item.tagId
  314. })
  315. }
  316. goodsList.forEach(item => {
  317. item.data.forEach(items => {
  318. items.picUrl = env.filePublic + items.picUrl.split(',')[0] + '?imageView2/2/w/340'
  319. })
  320. })
  321. this.exclusiveSingle = goodsList
  322. },
  323. //精选商品部分
  324. getList() {
  325. uni.showLoading({
  326. title: '加载中'
  327. });
  328. let data = {
  329. categoryId: this.categoryId,
  330. tagIds: this.tagIds,
  331. ...this.coinNum,
  332. noToken: true
  333. }
  334. $http.post(
  335. `/api/v1/mp/user/exchange/goods/list?pageNum=${this.pageNum}&pageSize=20&orderByColumn=${this.orderByColumn}&isAsc=${this.isAsc}`,
  336. data).then(
  337. res => {
  338. uni.hideLoading();
  339. if (res.code == 0) {
  340. res.rows.forEach(item => {
  341. let picUrlArr = item.picUrl.split(',')
  342. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/340'
  343. })
  344. this.total = res.total
  345. this.list = this.list.concat(res.rows)
  346. }
  347. }).catch(() => {
  348. uni.hideLoading();
  349. })
  350. },
  351. pageList() {
  352. this.pageNum = 1
  353. this.total = 0
  354. this.list = []
  355. this.getList()
  356. },
  357. pageListTwo() {
  358. this.pageNum = 1
  359. this.total = 0
  360. this.list = []
  361. this.getList()
  362. },
  363. openSelect() {
  364. if (this.coinShow == false) {
  365. this.coinShow = true
  366. this.ascShow = false
  367. uni.createSelectorQuery().select(".core-cla").boundingClientRect((res) => {
  368. uni.createSelectorQuery().select(".screen-coin-select-text-two").boundingClientRect((
  369. data) => {
  370. uni.pageScrollTo({
  371. duration: 0,
  372. scrollTop: -res.top + data.top + 350,
  373. })
  374. }).exec()
  375. }).exec()
  376. } else {
  377. this.coinShow = false
  378. }
  379. },
  380. //排序切换
  381. ascSelect() {
  382. if (this.ascShow == false) {
  383. this.ascShow = true
  384. this.coinShow = false
  385. uni.createSelectorQuery().select(".core-cla").boundingClientRect((res) => {
  386. uni.createSelectorQuery().select(".screen-coin-select-text").boundingClientRect((data) => {
  387. uni.pageScrollTo({
  388. duration: 0, //过渡时间必须为0,uniapp bug,否则运行到手机会报错
  389. scrollTop: -res.top + data.top,
  390. })
  391. }).exec()
  392. }).exec()
  393. } else {
  394. this.ascShow = false
  395. }
  396. },
  397. selectCoin(item, index) {
  398. this.actionIndex = index
  399. this.actionInfo = this.coinList[this.actionIndex]
  400. this.coinShow = false
  401. this.coinNum.startPrice = item.min
  402. this.coinNum.endPrice = item.max
  403. this.pageList()
  404. },
  405. selectCoinTwo(item, index) {
  406. this.ascListIndex = index
  407. this.ascListsingle = this.ascList[this.ascListIndex]
  408. this.ascShow = false
  409. if (item.data == '') {
  410. this.orderByColumn = ''
  411. this.isAsc = ''
  412. } else {
  413. this.isAsc = item.data
  414. this.orderByColumn = 'exchangePrice'
  415. }
  416. this.pageListTwo()
  417. },
  418. },
  419. //精选商品
  420. onReachBottom() {
  421. // 判断是否有数据
  422. if (this.total > this.pageNum * 20) {
  423. setTimeout(() => {
  424. ++this.pageNum
  425. this.getList()
  426. }, 500)
  427. } else {
  428. uni.$u.toast('没有更多数据了')
  429. }
  430. },
  431. onShareAppMessage(res) {
  432. return {
  433. title: '盲票,玩的就是有趣',
  434. path: '/pages/index/index'
  435. }
  436. }
  437. }
  438. </script>
  439. <style lang="scss" scoped>
  440. .u-nav-slot {
  441. text {
  442. font-size: 32rpx;
  443. }
  444. }
  445. </style>
  446. <style lang="scss" scoped>
  447. .swiper-ban {
  448. background-color: #FFFFFF;
  449. padding: 0 3px;
  450. .uni-padding-wrap {
  451. width: 95%;
  452. margin: 0 auto;
  453. border-radius: 10rpx;
  454. overflow: hidden;
  455. }
  456. }
  457. .uni-padding-wrap image {
  458. width: 100%;
  459. height: 100%;
  460. }
  461. .classificationBox {
  462. background-color: #FFFFFF;
  463. display: grid;
  464. grid-template-columns: 1fr 1fr 1fr 1fr;
  465. font-size: 12px;
  466. .ificationBox-mar {
  467. margin: 0 auto;
  468. text-align: center;
  469. margin-top: 10px;
  470. margin-bottom: 10px;
  471. }
  472. }
  473. .ificationBox-mar img {
  474. width: 44px;
  475. height: 44px;
  476. border-radius: 29px;
  477. }
  478. .sticky-wrap {
  479. .sticky-nav {
  480. border: 1px;
  481. border-radius: 20rpx 20rpx 0 0;
  482. background-color: #FFFFFF;
  483. margin: 20rpx 20rpx 0 20rpx;
  484. .sticky-nav-name {
  485. color: #2f2f2f;
  486. font-size: 18px;
  487. line-height: 25px;
  488. display: inline-block;
  489. padding: 8px;
  490. }
  491. .sticky-nav-all {
  492. width: 128px;
  493. height: 40px;
  494. text-align: right;
  495. line-height: 40px;
  496. color: #848484;
  497. float: right;
  498. display: grid;
  499. grid-template-columns: 1fr 1fr;
  500. }
  501. }
  502. .sticky-content-wrap {
  503. margin: 0 20rpx;
  504. border-radius: 0 0 20rpx 20rpx;
  505. overflow: hidden;
  506. .sticky-content-list {
  507. width: 100%;
  508. background-color: #FFFFFF;
  509. justify-content: space-around;
  510. flex-wrap: wrap;
  511. padding-top: 20rpx;
  512. &-item {
  513. box-sizing: border-box;
  514. width: 320rpx;
  515. height: 460rpx;
  516. background-color: #FFFFFF;
  517. border-radius: 10rpx;
  518. margin-bottom: 30rpx;
  519. .iamge-wrap {
  520. image {
  521. border-radius: 10rpx;
  522. width: 320rpx;
  523. height: 320rpx;
  524. margin-bottom: 6rpx;
  525. }
  526. }
  527. .title {
  528. padding: 0 14rpx;
  529. font-size: 28rpx;
  530. ;
  531. overflow: hidden;
  532. text-overflow: ellipsis;
  533. display: -webkit-box;
  534. -webkit-box-orient: vertical;
  535. -webkit-line-clamp: 2;
  536. }
  537. .bean {
  538. padding: 0 14rpx;
  539. display: flex;
  540. align-items: center;
  541. font-size: 32rpx;
  542. line-height: 44rpx;
  543. color: rgba(235, 112, 9, 100);
  544. margin-top: 12rpx;
  545. image {
  546. width: 42rpx;
  547. height: 42rpx;
  548. margin-right: 16rpx;
  549. }
  550. }
  551. }
  552. &-item:last-child {
  553. padding: 0;
  554. height: 0;
  555. }
  556. }
  557. }
  558. .sticky-content-wrap:last-child {
  559. margin-bottom: 20rpx;
  560. }
  561. }
  562. .screen-coin-shopin {
  563. color: #2f2f2f;
  564. font-size: 36rpx;
  565. line-height: 16rpx;
  566. display: inline-block;
  567. padding: 18px 8px 0px 8px;
  568. }
  569. .screen-coin-select-text {
  570. color: #848484;
  571. }
  572. .screen-coin-select-line {
  573. border-right: 3rpx solid #848484;
  574. width: 26rpx;
  575. height: 26rpx;
  576. }
  577. .screen-coin {
  578. width: 100%;
  579. z-index: 10;
  580. background-color: #FFFFFF;
  581. border-top: 1px solid #F8F8F8;
  582. box-shadow: 0 4rpx 10rpx 0 rgba(151, 151, 151, 0.24);
  583. &-select {
  584. height: 86rpx;
  585. line-height: 86rpx;
  586. width: 100%;
  587. justify-content: flex-start;
  588. .title {
  589. padding-left: 20rpx;
  590. margin-right: 10rpx;
  591. }
  592. }
  593. &-list {
  594. width: 100%;
  595. background-color: #FFFFFF;
  596. border-top: 1px solid #F8F8F8;
  597. &-item {
  598. height: 86rpx;
  599. line-height: 86rpx;
  600. background-color: #FFFFFF;
  601. border-bottom: 1px solid #F8F8F8;
  602. }
  603. &-item:last-child {
  604. border: 0;
  605. }
  606. .action {
  607. color: $uni-text-color;
  608. }
  609. }
  610. }
  611. .core {
  612. margin: 20rpx 0;
  613. &-list {
  614. justify-content: space-evenly;
  615. flex-wrap: wrap;
  616. &-item {
  617. box-sizing: border-box;
  618. width: 340rpx;
  619. height: 502rpx;
  620. background-color: #FFFFFF;
  621. border-radius: 10rpx;
  622. margin-bottom: 30rpx;
  623. .iamge-wrap {
  624. image {
  625. border-top-left-radius: 10rpx;
  626. border-top-right-radius: 10rpx;
  627. width: 340rpx;
  628. height: 340rpx;
  629. margin-bottom: 6rpx;
  630. }
  631. }
  632. .title {
  633. padding: 0 14rpx;
  634. font-size: 28rpx;
  635. // line-height: 40rpx;
  636. overflow: hidden;
  637. text-overflow: ellipsis;
  638. display: -webkit-box;
  639. -webkit-box-orient: vertical;
  640. -webkit-line-clamp: 2;
  641. }
  642. .bean {
  643. padding: 0 14rpx;
  644. display: flex;
  645. align-items: center;
  646. font-size: 32rpx;
  647. line-height: 44rpx;
  648. color: rgba(235, 112, 9, 100);
  649. margin-top: 12rpx;
  650. image {
  651. width: 42rpx;
  652. height: 42rpx;
  653. margin-right: 16rpx;
  654. }
  655. }
  656. }
  657. &-item:last-child {
  658. padding: 0;
  659. height: 0;
  660. }
  661. }
  662. .empty {
  663. height: 60vh;
  664. }
  665. }
  666. </style>
  667. <style lang="scss" scoped>
  668. </style>