index.vue 16 KB

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