index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  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. .swiper-ban {
  434. background-color: #FFFFFF;
  435. padding: 0 3px;
  436. .uni-padding-wrap {
  437. width: 95%;
  438. height: 120px;
  439. margin: 0 auto;
  440. border-radius: 10rpx;
  441. overflow: hidden;
  442. }
  443. }
  444. .uni-padding-wrap img {
  445. width: 100%;
  446. height: 100%;
  447. }
  448. .classificationBox {
  449. background-color: #FFFFFF;
  450. display: grid;
  451. grid-template-columns: 1fr 1fr 1fr 1fr;
  452. font-size: 12px;
  453. .ificationBox-mar {
  454. margin: 0 auto;
  455. text-align: center;
  456. margin-top: 10px;
  457. margin-bottom: 10px;
  458. }
  459. }
  460. .ificationBox-mar img {
  461. width: 44px;
  462. height: 44px;
  463. border-radius: 29px;
  464. }
  465. .sticky-wrap {
  466. .sticky-nav {
  467. border: 1px;
  468. border-radius: 20rpx 20rpx 0 0;
  469. background-color: #FFFFFF;
  470. margin: 20rpx 20rpx 0 20rpx;
  471. .sticky-nav-name {
  472. color: #2f2f2f;
  473. font-size: 18px;
  474. line-height: 25px;
  475. display: inline-block;
  476. padding: 8px;
  477. }
  478. .sticky-nav-all {
  479. width: 128px;
  480. height: 40px;
  481. text-align: right;
  482. line-height: 40px;
  483. color: #9c9c9c;
  484. float: right;
  485. display: grid;
  486. grid-template-columns: 1fr 1fr;
  487. }
  488. }
  489. .sticky-content-wrap {
  490. margin: 0 20rpx;
  491. border-radius: 0 0 20rpx 20rpx;
  492. overflow: hidden;
  493. .sticky-content-list {
  494. width: 100%;
  495. background-color: #FFFFFF;
  496. justify-content: space-around;
  497. flex-wrap: wrap;
  498. padding-top: 20rpx;
  499. &-item {
  500. box-sizing: border-box;
  501. width: 320rpx;
  502. height: 502rpx;
  503. background-color: #FFFFFF;
  504. border-radius: 10rpx;
  505. margin-bottom: 30rpx;
  506. .iamge-wrap {
  507. image {
  508. border-radius: 10rpx 10rpx 0 0;
  509. width: 320rpx;
  510. height: 320rpx;
  511. margin-bottom: 6rpx;
  512. }
  513. }
  514. .title {
  515. padding: 0 14rpx;
  516. font-size: 28rpx;;
  517. overflow: hidden;
  518. text-overflow: ellipsis;
  519. display: -webkit-box;
  520. -webkit-box-orient: vertical;
  521. -webkit-line-clamp: 2;
  522. }
  523. .bean {
  524. padding: 0 14rpx;
  525. display: flex;
  526. align-items: center;
  527. font-size: 32rpx;
  528. line-height: 44rpx;
  529. color: rgba(235, 112, 9, 100);
  530. margin-top: 12rpx;
  531. image {
  532. width: 42rpx;
  533. height: 42rpx;
  534. margin-right: 16rpx;
  535. }
  536. }
  537. }
  538. &-item:last-child {
  539. padding: 0;
  540. height: 0;
  541. }
  542. }
  543. }
  544. .sticky-content-wrap:last-child {
  545. margin-bottom: 20rpx;
  546. }
  547. }
  548. .screen-coin-shopin {
  549. color: #2f2f2f;
  550. font-size: 36rpx;
  551. line-height: 16rpx;
  552. display: inline-block;
  553. padding: 18px 8px 0px 8px;
  554. }
  555. .screen-coin-select-text {
  556. color: #848484;
  557. }
  558. .screen-coin-select-line {
  559. border-right: 3rpx solid #bbbbbb;
  560. width: 26rpx;
  561. height: 26rpx;
  562. }
  563. .screen-coin {
  564. width: 100%;
  565. z-index: 10;
  566. background-color: #FFFFFF;
  567. border-top: 1px solid #F8F8F8;
  568. box-shadow: 0 4rpx 10rpx 0 rgba(151, 151, 151, 0.24);
  569. &-select {
  570. height: 86rpx;
  571. line-height: 86rpx;
  572. width: 100%;
  573. justify-content: flex-start;
  574. .title {
  575. padding-left: 20rpx;
  576. margin-right: 10rpx;
  577. }
  578. }
  579. &-list {
  580. width: 100%;
  581. background-color: #FFFFFF;
  582. border-top: 1px solid #F8F8F8;
  583. &-item {
  584. height: 86rpx;
  585. line-height: 86rpx;
  586. background-color: #FFFFFF;
  587. border-bottom: 1px solid #F8F8F8;
  588. }
  589. &-item:last-child {
  590. border: 0;
  591. }
  592. .action {
  593. color: $uni-text-color;
  594. }
  595. }
  596. }
  597. .core {
  598. margin: 20rpx 0;
  599. &-list {
  600. justify-content: space-evenly;
  601. flex-wrap: wrap;
  602. &-item {
  603. box-sizing: border-box;
  604. width: 340rpx;
  605. height: 502rpx;
  606. background-color: #FFFFFF;
  607. border-radius: 10rpx;
  608. margin-bottom: 30rpx;
  609. .iamge-wrap {
  610. image {
  611. border-top-left-radius: 10rpx;
  612. border-top-right-radius: 10rpx;
  613. width: 340rpx;
  614. height: 340rpx;
  615. margin-bottom: 6rpx;
  616. }
  617. }
  618. .title {
  619. padding: 0 14rpx;
  620. font-size: 28rpx;
  621. // line-height: 40rpx;
  622. overflow: hidden;
  623. text-overflow: ellipsis;
  624. display: -webkit-box;
  625. -webkit-box-orient: vertical;
  626. -webkit-line-clamp: 2;
  627. }
  628. .bean {
  629. padding: 0 14rpx;
  630. display: flex;
  631. align-items: center;
  632. font-size: 32rpx;
  633. line-height: 44rpx;
  634. color: rgba(235, 112, 9, 100);
  635. margin-top: 12rpx;
  636. image {
  637. width: 42rpx;
  638. height: 42rpx;
  639. margin-right: 16rpx;
  640. }
  641. }
  642. }
  643. &-item:last-child {
  644. padding: 0;
  645. height: 0;
  646. }
  647. }
  648. .empty {
  649. height: 60vh;
  650. }
  651. }
  652. </style>
  653. <style lang="scss" scoped>
  654. </style>