index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  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">
  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 offset-top="60" class="">
  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">
  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 @click="openSelect" class="flex">
  78. <view class="title">
  79. <text v-if="actionInfo.min">{{ actionInfo.min }}</text>
  80. <text v-if="actionInfo.max">-{{ actionInfo.max }}</text>
  81. <text>{{ actionInfo.desc }}</text>
  82. </view>
  83. <u-icon name="arrow-up" color="#333" size="18" v-if="coinShow"></u-icon>
  84. <u-icon name="arrow-down" color="#333" size="18" v-else></u-icon>
  85. </view>
  86. </view>
  87. <view class="screen-coin-list" v-if="ascShow">
  88. <view class="flex screen-coin-list-item" v-for="(item, index) in ascList" :key="index"
  89. @click="selectCoinTwo(item, index)">
  90. <text :class="{ 'action': ascListIndex == index }">{{ item.text }}</text>
  91. </view>
  92. </view>
  93. <view class="screen-coin-list" v-if="coinShow">
  94. <view class="flex screen-coin-list-item" v-for="(item, index) in coinList" :key="index"
  95. @click="selectCoin(item, index)">
  96. <text v-if="item.min" :class="{ 'action': actionIndex == index }">{{ item.min }}</text>
  97. <text v-if="item.max" :class="{ 'action': actionIndex == index }">-{{ item.max }}</text>
  98. <text :class="{ 'action': actionIndex == index }">{{ item.desc }}</text>
  99. </view>
  100. </view>
  101. </view>
  102. </u-sticky>
  103. <view class="core">
  104. <view class="flex core-list">
  105. <navigator :url="`/pages/goods/detail?id=${ item.goodsId }`" class="core-list-item"
  106. hover-class="navigator-hover" v-for="(item, index) in list" :key="index">
  107. <view class="flex iamge-wrap">
  108. <image :src="item.picUrl" mode=""></image>
  109. </view>
  110. <view class="title">{{ item.title }}</view>
  111. <view class="bean">
  112. <image src="../../static/icon/bean.png" mode="aspectFill"></image>
  113. <view>× {{ item.exchangePrice }}</view>
  114. </view>
  115. </navigator>
  116. <view class="core-list-item"></view>
  117. </view>
  118. <view class="flex empty" v-if="!list.length">
  119. <u-empty text="数据为空" mode="order" />
  120. </view>
  121. </view>
  122. <custom-tab-bar :activeValue="'core'" />
  123. <u-overlay :show="coinShow" @click="coinShow = false" zIndex="1"></u-overlay>
  124. <u-overlay :show="ascShow" @click="ascShow = false" zIndex="1"></u-overlay>
  125. <!-- 精选商品结束 -->
  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: 4500,
  142. duration: 2000,
  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. },
  233. onShow() {
  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. },
  243. methods: {
  244. changeIndicatorDots(e) {
  245. this.indicatorDots = true
  246. },
  247. changeAutoplay(e) {
  248. this.autoplay = true
  249. },
  250. intervalChange(e) {
  251. this.interval = e.target.value
  252. },
  253. durationChange(e) {
  254. this.duration = e.target.value
  255. },
  256. // 跳转点击事件
  257. toCoreRange(type, data, name) {
  258. if (type == "link") {
  259. // web-view
  260. } else {
  261. uni.navigateTo({
  262. url: `/pages/coreRange/coreRange?type=${ type }&data=${ data }&name=${ name }`,
  263. })
  264. }
  265. },
  266. //轮播图
  267. getSwiper() {
  268. $http.post(`/api/v1/mp/user/exchange/banner/list`, {
  269. noToken: true,
  270. location: "top"
  271. }).then(res => {
  272. res.data.forEach(item => {
  273. let picUrlArr = item.picUrl.split(',')
  274. item.picUrl = env.filePublic + picUrlArr[0]
  275. })
  276. this.imgTop = this.imgTop.concat(res.data)
  277. })
  278. },
  279. // 分类列表
  280. getListIficationBox() {
  281. $http.post(`/api/v1/mp/user/exchange/category/list`, {
  282. noToken: true
  283. }).then(res => {
  284. res.data.forEach(item => {
  285. let picUrlArr = item.picUrl.split(',')
  286. item.picUrl = env.filePublic + picUrlArr[0]
  287. })
  288. this.goods = this.goods.concat(res.data)
  289. })
  290. },
  291. // 秒杀
  292. async getExclusive() {
  293. let resData = await $http.post(`/api/v1/mp/user/exchange/activity/list`, {
  294. noToken: true
  295. })
  296. let goodsList = []
  297. for (let item of resData.data) {
  298. let resDatas = await $http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=1&pageSize=4`, {
  299. noToken: true,
  300. tagIds: item.tagId
  301. })
  302. goodsList.push({
  303. data: resDatas.rows,
  304. name: item.name,
  305. tagId: item.tagId
  306. })
  307. }
  308. goodsList.forEach(item => {
  309. item.data.forEach(items => {
  310. items.picUrl = env.filePublic + items.picUrl.split(',')[0]
  311. })
  312. })
  313. this.exclusiveSingle = goodsList
  314. },
  315. //精选商品部分
  316. getList() {
  317. uni.showLoading({
  318. title: '加载中'
  319. });
  320. let data = {
  321. categoryId: this.categoryId,
  322. tagIds: this.tagIds,
  323. ...this.coinNum,
  324. noToken: true
  325. }
  326. $http.post(
  327. `/api/v1/mp/user/exchange/goods/list?pageNum=${this.pageNum}&pageSize=20&orderByColumn=${this.orderByColumn}&isAsc=${this.isAsc}`,
  328. data).then(
  329. res => {
  330. uni.hideLoading();
  331. if (res.code == 0) {
  332. res.rows.forEach(item => {
  333. let picUrlArr = item.picUrl.split(',')
  334. item.picUrl = env.filePublic + picUrlArr[0]
  335. })
  336. this.total = res.total
  337. this.list = this.list.concat(res.rows)
  338. }
  339. }).catch(() => {
  340. uni.hideLoading();
  341. })
  342. },
  343. pageList() {
  344. this.pageNum = 1
  345. this.total = 0
  346. this.list = []
  347. this.getList()
  348. },
  349. pageListTwo() {
  350. this.pageNum = 1
  351. this.total = 0
  352. this.list = []
  353. this.getList()
  354. },
  355. openSelect() {
  356. if (this.coinShow == false) {
  357. this.coinShow = true
  358. this.ascShow = false
  359. } else {
  360. this.coinShow = false
  361. }
  362. },
  363. //排序切换
  364. ascSelect() {
  365. if (this.ascShow == false) {
  366. this.ascShow = true
  367. this.coinShow = false
  368. } else {
  369. this.ascShow = false
  370. }
  371. },
  372. selectCoin(item, index) {
  373. this.actionIndex = index
  374. this.actionInfo = this.coinList[this.actionIndex]
  375. this.coinShow = false
  376. this.coinNum.startPrice = item.min
  377. this.coinNum.endPrice = item.max
  378. this.pageList()
  379. },
  380. selectCoinTwo(item, index) {
  381. this.ascListIndex = index
  382. this.ascListsingle = this.ascList[this.ascListIndex]
  383. this.ascShow = false
  384. if (item.data == '') {
  385. this.orderByColumn = ''
  386. this.isAsc = ''
  387. } else {
  388. this.isAsc = item.data
  389. this.orderByColumn = 'exchangePrice'
  390. }
  391. this.pageListTwo()
  392. },
  393. },
  394. //精选商品
  395. onReachBottom() {
  396. // 判断是否有数据
  397. if (this.total > this.pageNum * 20) {
  398. setTimeout(() => {
  399. ++this.pageNum
  400. this.getList()
  401. }, 500)
  402. } else {
  403. uni.$u.toast('没有更多数据了')
  404. }
  405. },
  406. }
  407. </script>
  408. <style lang="scss" scoped>
  409. .swiper-ban {
  410. background-color: #FFFFFF;
  411. padding: 0 3px;
  412. .uni-padding-wrap {
  413. border-radius: 5px;
  414. overflow: hidden;
  415. }
  416. }
  417. .uni-padding-wrap img {
  418. width: 100%;
  419. height: 100%;
  420. }
  421. .classificationBox {
  422. background-color: #FFFFFF;
  423. display: grid;
  424. grid-template-columns: 1fr 1fr 1fr 1fr;
  425. font-size: 12px;
  426. .ificationBox-mar {
  427. margin: 0 auto;
  428. text-align: center;
  429. margin-top: 10px;
  430. margin-bottom: 10px;
  431. }
  432. }
  433. .ificationBox-mar img {
  434. width: 44px;
  435. height: 44px;
  436. border-radius: 29px;
  437. }
  438. .sticky-bac {
  439. margin-top: 10px;
  440. background-color: #FFFFFF;
  441. padding: 0 3px;
  442. .sticky-bac-text1 {
  443. color: #2f2f2f;
  444. font-size: 18px;
  445. line-height: 25px;
  446. display: inline-block;
  447. padding: 8px;
  448. }
  449. ;
  450. .sticky-bac-text2 {
  451. width: 128px;
  452. height: 40px;
  453. text-align: right;
  454. line-height: 40px;
  455. color: #9c9c9c;
  456. float: right;
  457. display: grid;
  458. grid-template-columns: 1fr 1fr;
  459. }
  460. }
  461. .Seckill-bom {
  462. padding: 0 0.3rem;
  463. // margin-bottom: 10px;
  464. background-color: #FFFFFF;
  465. .Seckill-bom-grid {
  466. min-height: 550rpx;
  467. display: flex;
  468. flex-wrap: wrap;
  469. justify-content: space-between;
  470. padding: 20rpx 15rpx;
  471. margin-bottom: 10px;
  472. }
  473. }
  474. .screen-coin-shopin {
  475. color: #2f2f2f;
  476. font-size: 18px;
  477. line-height: 25px;
  478. display: inline-block;
  479. padding: 8px;
  480. }
  481. //================
  482. .screen-coin {
  483. // position: fixed;
  484. width: 100%;
  485. z-index: 10;
  486. background-color: #FFFFFF;
  487. border-top: 1px solid #F8F8F8;
  488. box-shadow: 0 4rpx 10rpx 0 rgba(151, 151, 151, 0.24);
  489. &-select {
  490. height: 86rpx;
  491. line-height: 86rpx;
  492. width: 100%;
  493. justify-content: flex-start;
  494. .title {
  495. padding-left: 40rpx;
  496. margin-right: 10rpx;
  497. }
  498. }
  499. &-list {
  500. width: 100%;
  501. background-color: #FFFFFF;
  502. border-top: 1px solid #F8F8F8;
  503. &-item {
  504. height: 86rpx;
  505. line-height: 86rpx;
  506. background-color: #FFFFFF;
  507. border-bottom: 1px solid #F8F8F8;
  508. }
  509. &-item:last-child {
  510. border: 0;
  511. }
  512. .action {
  513. color: $uni-text-color;
  514. }
  515. }
  516. }
  517. .core {
  518. margin: 20rpx 0;
  519. &-list {
  520. justify-content: space-evenly;
  521. flex-wrap: wrap;
  522. // padding-top: 96rpx;
  523. &-item {
  524. box-sizing: border-box;
  525. width: 340rpx;
  526. height: 502rpx;
  527. background-color: #FFFFFF;
  528. border-radius: 10rpx;
  529. margin-bottom: 30rpx;
  530. .iamge-wrap {
  531. image {
  532. border-top-left-radius: 10rpx;
  533. border-top-right-radius: 10rpx;
  534. width: 340rpx;
  535. height: 340rpx;
  536. margin-bottom: 6rpx;
  537. }
  538. }
  539. .title {
  540. padding: 0 14rpx;
  541. font-size: 28rpx;
  542. line-height: 40rpx;
  543. overflow: hidden;
  544. text-overflow: ellipsis;
  545. display: -webkit-box;
  546. -webkit-box-orient: vertical;
  547. -webkit-line-clamp: 2;
  548. }
  549. .bean {
  550. padding: 0 14rpx;
  551. display: flex;
  552. align-items: center;
  553. font-size: 32rpx;
  554. line-height: 44rpx;
  555. color: rgba(235, 112, 9, 100);
  556. margin-top: 12rpx;
  557. image {
  558. width: 42rpx;
  559. height: 42rpx;
  560. margin-right: 16rpx;
  561. }
  562. }
  563. }
  564. &-item:last-child {
  565. padding: 0;
  566. height: 0;
  567. }
  568. }
  569. .empty {
  570. height: 60vh;
  571. }
  572. }
  573. </style>
  574. <style lang="scss" scoped>
  575. </style>