index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  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">
  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"></u-overlay>
  125. <u-overlay :show="ascShow" @click="ascShow = false" zIndex="1"></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: 4500,
  143. duration: 2000,
  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. border-radius: 5px;
  440. overflow: hidden;
  441. }
  442. }
  443. .uni-padding-wrap img {
  444. width: 100%;
  445. height: 100%;
  446. }
  447. .classificationBox {
  448. background-color: #FFFFFF;
  449. display: grid;
  450. grid-template-columns: 1fr 1fr 1fr 1fr;
  451. font-size: 12px;
  452. .ificationBox-mar {
  453. margin: 0 auto;
  454. text-align: center;
  455. margin-top: 10px;
  456. margin-bottom: 10px;
  457. }
  458. }
  459. .ificationBox-mar img {
  460. width: 44px;
  461. height: 44px;
  462. border-radius: 29px;
  463. }
  464. .sticky-bac {
  465. margin-top: 10px;
  466. background-color: #FFFFFF;
  467. padding: 0 3px;
  468. .sticky-bac-text1 {
  469. color: #2f2f2f;
  470. font-size: 18px;
  471. line-height: 25px;
  472. display: inline-block;
  473. padding: 8px;
  474. }
  475. ;
  476. .sticky-bac-text2 {
  477. width: 128px;
  478. height: 40px;
  479. text-align: right;
  480. line-height: 40px;
  481. color: #9c9c9c;
  482. float: right;
  483. display: grid;
  484. grid-template-columns: 1fr 1fr;
  485. }
  486. }
  487. .Seckill-bom {
  488. padding: 0 0.3rem;
  489. // margin-bottom: 10px;
  490. background-color: #FFFFFF;
  491. .Seckill-bom-grid {
  492. min-height: 550rpx;
  493. display: flex;
  494. flex-wrap: wrap;
  495. justify-content: space-between;
  496. padding: 20rpx 15rpx 0px 15px;
  497. margin-bottom: 10px;
  498. }
  499. }
  500. .screen-coin-shopin {
  501. color: #2f2f2f;
  502. font-size: 36rpx;
  503. line-height: 16rpx;
  504. display: inline-block;
  505. padding: 18px 8px 0px 8px;
  506. }
  507. .screen-coin-select-text {
  508. color: #848484;
  509. }
  510. .screen-coin-select-line {
  511. border-right: 3rpx solid #bbbbbb;
  512. width: 26rpx;
  513. height: 26rpx;
  514. }
  515. //================
  516. .screen-coin {
  517. // position: fixed;
  518. width: 100%;
  519. z-index: 10;
  520. background-color: #FFFFFF;
  521. border-top: 1px solid #F8F8F8;
  522. box-shadow: 0 4rpx 10rpx 0 rgba(151, 151, 151, 0.24);
  523. &-select {
  524. height: 86rpx;
  525. line-height: 86rpx;
  526. width: 100%;
  527. justify-content: flex-start;
  528. .title {
  529. padding-left: 20rpx;
  530. margin-right: 10rpx;
  531. }
  532. }
  533. &-list {
  534. width: 100%;
  535. background-color: #FFFFFF;
  536. border-top: 1px solid #F8F8F8;
  537. &-item {
  538. height: 86rpx;
  539. line-height: 86rpx;
  540. background-color: #FFFFFF;
  541. border-bottom: 1px solid #F8F8F8;
  542. }
  543. &-item:last-child {
  544. border: 0;
  545. }
  546. .action {
  547. color: $uni-text-color;
  548. }
  549. }
  550. }
  551. .core {
  552. margin: 20rpx 0;
  553. &-list {
  554. justify-content: space-evenly;
  555. flex-wrap: wrap;
  556. // padding-top: 96rpx;
  557. &-item {
  558. box-sizing: border-box;
  559. width: 340rpx;
  560. height: 502rpx;
  561. background-color: #FFFFFF;
  562. border-radius: 10rpx;
  563. margin-bottom: 30rpx;
  564. .iamge-wrap {
  565. image {
  566. border-top-left-radius: 10rpx;
  567. border-top-right-radius: 10rpx;
  568. width: 340rpx;
  569. height: 340rpx;
  570. margin-bottom: 6rpx;
  571. }
  572. }
  573. .title {
  574. padding: 0 14rpx;
  575. font-size: 28rpx;
  576. // line-height: 40rpx;
  577. overflow: hidden;
  578. text-overflow: ellipsis;
  579. display: -webkit-box;
  580. -webkit-box-orient: vertical;
  581. -webkit-line-clamp: 2;
  582. }
  583. .bean {
  584. padding: 0 14rpx;
  585. display: flex;
  586. align-items: center;
  587. font-size: 32rpx;
  588. line-height: 44rpx;
  589. color: rgba(235, 112, 9, 100);
  590. margin-top: 12rpx;
  591. image {
  592. width: 42rpx;
  593. height: 42rpx;
  594. margin-right: 16rpx;
  595. }
  596. }
  597. }
  598. &-item:last-child {
  599. padding: 0;
  600. height: 0;
  601. }
  602. }
  603. .empty {
  604. height: 60vh;
  605. }
  606. }
  607. </style>
  608. <style lang="scss" scoped>
  609. </style>