index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  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="`/packageGoods/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="`/packageGoods/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: 100,
  158. desc: '盲豆'
  159. },
  160. {
  161. min: 101,
  162. max: 200,
  163. desc: '盲豆'
  164. },
  165. {
  166. min: 201,
  167. max: 500,
  168. desc: '盲豆'
  169. },
  170. {
  171. min: 501,
  172. max: 1000,
  173. desc: '盲豆'
  174. },
  175. {
  176. min: 1001,
  177. max: 5000,
  178. desc: '盲豆'
  179. },
  180. {
  181. min: 5000,
  182. max: null,
  183. desc: '盲豆以上'
  184. },
  185. ],
  186. actionInfo: {},
  187. actionIndex: 0,
  188. coinNum: {
  189. startPrice: null,
  190. endPrice: null
  191. },
  192. orderByColumn: '', //默认exchangePrice
  193. isAsc: '', //从低到高asc isAsc:'desc'从高到低
  194. ascShow: false,
  195. ascList: [{
  196. data: '',
  197. text: '默认排序'
  198. },
  199. {
  200. data: 'asc',
  201. text: '价格从低到高'
  202. },
  203. {
  204. data: 'desc',
  205. text: '价格从高到低'
  206. },
  207. ],
  208. ascListsingle: {},
  209. ascListIndex: 0,
  210. // 距顶部位置
  211. navHeight: 0,
  212. };
  213. },
  214. onLoad() {
  215. this.pageList()
  216. this.actionInfo = this.coinList[this.actionIndex]
  217. this.ascListsingle = this.ascList[this.ascListIndex]
  218. this.getSwiper()
  219. this.getListIficationBox()
  220. this.getExclusive()
  221. uni.getSystemInfo({
  222. success: (data) => {
  223. let custom = wx.getMenuButtonBoundingClientRect()
  224. //导航栏高度
  225. this.navHeight = custom.bottom + custom.top - data.statusBarHeight -6
  226. },
  227. })
  228. },
  229. methods: {
  230. changeIndicatorDots(e) {
  231. this.indicatorDots = true
  232. },
  233. changeAutoplay(e) {
  234. this.autoplay = true
  235. },
  236. intervalChange(e) {
  237. this.interval = e.target.value
  238. },
  239. durationChange(e) {
  240. this.duration = e.target.value
  241. },
  242. // 跳转点击事件
  243. toCoreRange(type, data, name) {
  244. if (type == "link") {
  245. uni.navigateTo({
  246. url: `/packageOperate/webview/index?url=${ data }`,
  247. })
  248. } else {
  249. uni.navigateTo({
  250. url: `/packageGoods/core/index?type=${ type }&data=${ data }&name=${ name }`,
  251. })
  252. }
  253. },
  254. //轮播图
  255. getSwiper() {
  256. $http.post(`/api/v1/mp/user/exchange/banner/list`, {
  257. noToken: true,
  258. location: "top"
  259. }).then(res => {
  260. res.data.forEach(item => {
  261. let picUrlArr = item.picUrl.split(',')
  262. item.picUrl = env.filePublic + picUrlArr[0]
  263. })
  264. this.imgTop = this.imgTop.concat(res.data)
  265. })
  266. },
  267. // 分类列表
  268. getListIficationBox() {
  269. $http.post(`/api/v1/mp/user/exchange/category/list`, {
  270. noToken: true
  271. }).then(res => {
  272. res.data.forEach(item => {
  273. let picUrlArr = item.picUrl.split(',')
  274. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/340'
  275. })
  276. this.goods = this.goods.concat(res.data)
  277. })
  278. },
  279. // 秒杀
  280. async getExclusive() {
  281. let resData = await $http.post(`/api/v1/mp/user/exchange/activity/list`, {
  282. noToken: true
  283. })
  284. let goodsList = []
  285. for (let item of resData.data) {
  286. let resDatas = await $http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=1&pageSize=4`, {
  287. noToken: true,
  288. tagIds: item.tagId
  289. })
  290. goodsList.push({
  291. data: resDatas.rows,
  292. name: item.name,
  293. tagId: item.tagId
  294. })
  295. }
  296. goodsList.forEach(item => {
  297. item.data.forEach(items => {
  298. items.picUrl = env.filePublic + items.picUrl.split(',')[0] + '?imageView2/2/w/340'
  299. })
  300. })
  301. this.exclusiveSingle = goodsList
  302. },
  303. //精选商品部分
  304. getList() {
  305. uni.showLoading({
  306. title: '加载中'
  307. });
  308. let data = {
  309. categoryId: this.categoryId,
  310. tagIds: this.tagIds,
  311. ...this.coinNum,
  312. noToken: true
  313. }
  314. $http.post(
  315. `/api/v1/mp/user/exchange/goods/list?pageNum=${this.pageNum}&pageSize=20&orderByColumn=${this.orderByColumn}&isAsc=${this.isAsc}`,
  316. data).then(
  317. res => {
  318. uni.hideLoading();
  319. if (res.code == 0) {
  320. res.rows.forEach(item => {
  321. let picUrlArr = item.picUrl.split(',')
  322. item.picUrl = env.filePublic + picUrlArr[0] + '?imageView2/2/w/340'
  323. })
  324. this.total = res.total
  325. this.list = this.list.concat(res.rows)
  326. }
  327. }).catch(() => {
  328. uni.hideLoading();
  329. })
  330. },
  331. pageList() {
  332. this.pageNum = 1
  333. this.total = 0
  334. this.list = []
  335. this.getList()
  336. },
  337. pageListTwo() {
  338. this.pageNum = 1
  339. this.total = 0
  340. this.list = []
  341. this.getList()
  342. },
  343. openSelect() {
  344. if (this.coinShow == false) {
  345. this.coinShow = true
  346. this.ascShow = false
  347. uni.createSelectorQuery().select(".core-cla").boundingClientRect((res) => {
  348. uni.createSelectorQuery().select(".screen-coin-select-text-two").boundingClientRect((
  349. data) => {
  350. uni.pageScrollTo({
  351. duration: 0,
  352. scrollTop: -res.top + data.top + 350,
  353. })
  354. }).exec()
  355. }).exec()
  356. } else {
  357. this.coinShow = false
  358. }
  359. },
  360. //排序切换
  361. ascSelect() {
  362. if (this.ascShow == false) {
  363. this.ascShow = true
  364. this.coinShow = false
  365. uni.createSelectorQuery().select(".core-cla").boundingClientRect((res) => {
  366. uni.createSelectorQuery().select(".screen-coin-select-text").boundingClientRect((data) => {
  367. uni.pageScrollTo({
  368. duration: 0, //过渡时间必须为0,uniapp bug,否则运行到手机会报错
  369. scrollTop: -res.top + data.top,
  370. })
  371. }).exec()
  372. }).exec()
  373. } else {
  374. this.ascShow = false
  375. }
  376. },
  377. selectCoin(item, index) {
  378. this.actionIndex = index
  379. this.actionInfo = this.coinList[this.actionIndex]
  380. this.coinShow = false
  381. this.coinNum.startPrice = item.min
  382. this.coinNum.endPrice = item.max
  383. this.pageList()
  384. },
  385. selectCoinTwo(item, index) {
  386. this.ascListIndex = index
  387. this.ascListsingle = this.ascList[this.ascListIndex]
  388. this.ascShow = false
  389. if (item.data == '') {
  390. this.orderByColumn = ''
  391. this.isAsc = ''
  392. } else {
  393. this.isAsc = item.data
  394. this.orderByColumn = 'exchangePrice'
  395. }
  396. this.pageListTwo()
  397. },
  398. },
  399. //精选商品
  400. onReachBottom() {
  401. // 判断是否有数据
  402. if (this.total > this.pageNum * 20) {
  403. setTimeout(() => {
  404. ++this.pageNum
  405. this.getList()
  406. }, 500)
  407. } else {
  408. uni.$u.toast('已经到底了')
  409. }
  410. },
  411. onShareAppMessage(res) {
  412. return {
  413. title: '盲票,玩的就是有趣',
  414. path: '/pages/index/index',
  415. // imageUrl:'../../static/icon/lucky_bg.png',
  416. }
  417. }
  418. }
  419. </script>
  420. <style lang="scss" scoped>
  421. .u-nav-slot {
  422. text {
  423. font-size: 32rpx;
  424. }
  425. }
  426. </style>
  427. <style lang="scss" scoped>
  428. .swiper-ban {
  429. background-color: #FFFFFF;
  430. padding: 0 3px;
  431. .uni-padding-wrap {
  432. width: 95%;
  433. margin: 0 auto;
  434. border-radius: 10rpx;
  435. overflow: hidden;
  436. }
  437. }
  438. .uni-padding-wrap image {
  439. width: 100%;
  440. height: 100%;
  441. }
  442. .classificationBox {
  443. background-color: #FFFFFF;
  444. display: grid;
  445. grid-template-columns: 1fr 1fr 1fr 1fr;
  446. font-size: 12px;
  447. .ificationBox-mar {
  448. margin: 0 auto;
  449. text-align: center;
  450. margin-top: 10px;
  451. margin-bottom: 10px;
  452. }
  453. }
  454. .ificationBox-mar img {
  455. width: 44px;
  456. height: 44px;
  457. border-radius: 29px;
  458. }
  459. .sticky-wrap {
  460. .sticky-nav {
  461. border: 1px;
  462. border-radius: 20rpx 20rpx 0 0;
  463. background-color: #FFFFFF;
  464. margin: 20rpx 20rpx 0 20rpx;
  465. .sticky-nav-name {
  466. color: #2f2f2f;
  467. font-size: 18px;
  468. line-height: 25px;
  469. display: inline-block;
  470. padding: 8px;
  471. }
  472. .sticky-nav-all {
  473. width: 128px;
  474. height: 40px;
  475. text-align: right;
  476. line-height: 40px;
  477. color: #848484;
  478. float: right;
  479. display: grid;
  480. grid-template-columns: 1fr 1fr;
  481. }
  482. }
  483. .sticky-content-wrap {
  484. margin: 0 20rpx;
  485. border-radius: 0 0 20rpx 20rpx;
  486. overflow: hidden;
  487. .sticky-content-list {
  488. width: 100%;
  489. background-color: #FFFFFF;
  490. justify-content: space-around;
  491. flex-wrap: wrap;
  492. padding-top: 20rpx;
  493. &-item {
  494. box-sizing: border-box;
  495. width: 320rpx;
  496. height: 460rpx;
  497. background-color: #FFFFFF;
  498. border-radius: 10rpx;
  499. margin-bottom: 30rpx;
  500. .iamge-wrap {
  501. image {
  502. border-radius: 10rpx;
  503. width: 320rpx;
  504. height: 320rpx;
  505. margin-bottom: 6rpx;
  506. }
  507. }
  508. .title {
  509. padding: 0 14rpx;
  510. font-size: 28rpx;
  511. ;
  512. overflow: hidden;
  513. text-overflow: ellipsis;
  514. display: -webkit-box;
  515. -webkit-box-orient: vertical;
  516. -webkit-line-clamp: 2;
  517. }
  518. .bean {
  519. padding: 0 14rpx;
  520. display: flex;
  521. align-items: center;
  522. font-size: 32rpx;
  523. line-height: 44rpx;
  524. color: rgba(235, 112, 9, 100);
  525. margin-top: 12rpx;
  526. image {
  527. width: 42rpx;
  528. height: 42rpx;
  529. margin-right: 16rpx;
  530. }
  531. }
  532. }
  533. &-item:last-child {
  534. padding: 0;
  535. height: 0;
  536. }
  537. }
  538. }
  539. .sticky-content-wrap:last-child {
  540. margin-bottom: 20rpx;
  541. }
  542. }
  543. .screen-coin-shopin {
  544. color: #2f2f2f;
  545. font-size: 36rpx;
  546. line-height: 16rpx;
  547. display: inline-block;
  548. padding: 18px 8px 0px 8px;
  549. }
  550. .screen-coin-select-text {
  551. color: #848484;
  552. }
  553. .screen-coin-select-line {
  554. border-right: 3rpx solid #848484;
  555. width: 26rpx;
  556. height: 26rpx;
  557. }
  558. .screen-coin {
  559. width: 100%;
  560. z-index: 10;
  561. background-color: #FFFFFF;
  562. border-top: 1px solid #F8F8F8;
  563. box-shadow: 0 4rpx 10rpx 0 rgba(151, 151, 151, 0.24);
  564. &-select {
  565. height: 86rpx;
  566. line-height: 86rpx;
  567. width: 100%;
  568. justify-content: flex-start;
  569. .title {
  570. padding-left: 20rpx;
  571. margin-right: 10rpx;
  572. }
  573. }
  574. &-list {
  575. width: 100%;
  576. background-color: #FFFFFF;
  577. border-top: 1px solid #F8F8F8;
  578. &-item {
  579. height: 86rpx;
  580. line-height: 86rpx;
  581. background-color: #FFFFFF;
  582. border-bottom: 1px solid #F8F8F8;
  583. }
  584. &-item:last-child {
  585. border: 0;
  586. }
  587. .action {
  588. color: $uni-text-color;
  589. }
  590. }
  591. }
  592. .core {
  593. margin: 20rpx 0;
  594. &-list {
  595. justify-content: space-evenly;
  596. flex-wrap: wrap;
  597. &-item {
  598. box-sizing: border-box;
  599. width: 340rpx;
  600. height: 502rpx;
  601. background-color: #FFFFFF;
  602. border-radius: 10rpx;
  603. margin-bottom: 30rpx;
  604. .iamge-wrap {
  605. image {
  606. border-top-left-radius: 10rpx;
  607. border-top-right-radius: 10rpx;
  608. width: 340rpx;
  609. height: 340rpx;
  610. margin-bottom: 6rpx;
  611. }
  612. }
  613. .title {
  614. padding: 0 14rpx;
  615. font-size: 28rpx;
  616. // line-height: 40rpx;
  617. overflow: hidden;
  618. text-overflow: ellipsis;
  619. display: -webkit-box;
  620. -webkit-box-orient: vertical;
  621. -webkit-line-clamp: 2;
  622. }
  623. .bean {
  624. padding: 0 14rpx;
  625. display: flex;
  626. align-items: center;
  627. font-size: 32rpx;
  628. line-height: 44rpx;
  629. color: rgba(235, 112, 9, 100);
  630. margin-top: 12rpx;
  631. image {
  632. width: 42rpx;
  633. height: 42rpx;
  634. margin-right: 16rpx;
  635. }
  636. }
  637. }
  638. &-item:last-child {
  639. padding: 0;
  640. height: 0;
  641. }
  642. }
  643. .empty {
  644. height: 60vh;
  645. }
  646. }
  647. </style>
  648. <style lang="scss" scoped>
  649. </style>