index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  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" @click="toCoreRange(item.type,item.type=='link'?item.linkUrl:item.goodsTags)">
  16. <img :src="item.picUrl" alt="">
  17. </swiper-item>
  18. </swiper>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <!-- swiper结束 -->
  24. <!-- 分类部分开始 -->
  25. <view class="classificationBox">
  26. <view v-for="(item,index) in goods" :key="index" @click="toCoreRange('tag',item.categoryId)" class="ificationBox-mar">
  27. <img :src="item.picUrl" alt="">
  28. <view v-text="item.name" style=" "></view>
  29. </view>
  30. </view>
  31. <!-- 分类部分结束 -->
  32. <!-- 限时秒杀部分开始 -->
  33. <view v-for="(item,index) in exclusive" :key="index">
  34. <view class=" sticky-bac">
  35. <text class="sticky-bac-text1" v-text="item.name"></text>
  36. <view @click="toCoreRange('tag',item.tagId)" class="sticky-bac-text2">
  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="Seckill-bom">
  45. <view class="Seckill-bom-grid" >
  46. <navigator :url="`/pages/goods/detail?id=${ itemExc.goodsId }`" class="core-list-item"
  47. hover-class="navigator-hover" v-for="(itemExc, indexNum) in exclusiveSingle[index]" :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>
  58. </view>
  59. </view>
  60. <!-- 限时秒杀部分结束 -->
  61. <!-- 精选商品部份开始 -->
  62. <u-sticky offset-top="60" class="">
  63. <view class="screen-coin uSticky-toTop">
  64. <view class="flex screen-coin-select" @click="openSelect">
  65. <view class="title">
  66. <text v-if="actionInfo.min">{{ actionInfo.min }}</text>
  67. <text v-if="actionInfo.max">-{{ actionInfo.max }}</text>
  68. <text>{{ actionInfo.desc }}</text>
  69. </view>
  70. <u-icon name="arrow-up" color="#333" size="18" v-if="coinShow"></u-icon>
  71. <u-icon name="arrow-down" color="#333" size="18" v-else></u-icon>
  72. </view>
  73. <view class="screen-coin-list" v-if="coinShow">
  74. <view class="flex screen-coin-list-item" v-for="(item, index) in coinList" :key="index"
  75. @click="selectCoin(item, index)">
  76. <text v-if="item.min" :class="{ 'action': actionIndex == index }">{{ item.min }}</text>
  77. <text v-if="item.max" :class="{ 'action': actionIndex == index }">-{{ item.max }}</text>
  78. <text :class="{ 'action': actionIndex == index }">{{ item.desc }}</text>
  79. </view>
  80. </view>
  81. </view>
  82. </u-sticky>
  83. <view class="core">
  84. <view class="flex core-list">
  85. <navigator :url="`/pages/goods/detail?id=${ item.goodsId }`" class="core-list-item"
  86. hover-class="navigator-hover" v-for="(item, index) in list" :key="index">
  87. <view class="flex iamge-wrap">
  88. <image :src="item.picUrl" mode=""></image>
  89. </view>
  90. <view class="title">{{ item.title }}</view>
  91. <view class="bean">
  92. <image src="../../static/icon/bean.png" mode="aspectFill"></image>
  93. <view>× {{ item.exchangePrice }}</view>
  94. </view>
  95. </navigator>
  96. <view class="core-list-item"></view>
  97. </view>
  98. <view class="flex empty" v-if="!list.length">
  99. <u-empty text="数据为空" mode="order" />
  100. </view>
  101. </view>
  102. <custom-tab-bar :activeValue="'core'" />
  103. <u-overlay :show="coinShow" @click="coinShow = false" zIndex="1"></u-overlay>
  104. <!-- 精选商品结束 -->
  105. <custom-tab-bar :activeValue="'core'" />
  106. </view>
  107. </template>
  108. <script>
  109. import env from '../../config/env.js'
  110. import CustomTabBar from '../../components/custom-tab-bar/custom-tab-bar.vue'
  111. import $http from '@/utils/request.js'
  112. export default {
  113. components: {
  114. CustomTabBar,
  115. },
  116. data() {
  117. return {
  118. indicatorDots: true,
  119. autoplay: true,
  120. interval: 4500,
  121. duration: 2000,
  122. imgTop: [],
  123. goods: [],
  124. exclusive:[],
  125. exclusiveSingle:[],
  126. pageNum: 1,
  127. total: 0,
  128. list: [],
  129. coinShow: false,
  130. coinList: [{
  131. min: null,
  132. max: null,
  133. desc: '全部价格'
  134. },
  135. {
  136. min: 1,
  137. max: 20,
  138. desc: '盲豆'
  139. },
  140. {
  141. min: 21,
  142. max: 40,
  143. desc: '盲豆'
  144. },
  145. {
  146. min: 41,
  147. max: 60,
  148. desc: '盲豆'
  149. },
  150. {
  151. min: 61,
  152. max: 80,
  153. desc: '盲豆'
  154. },
  155. {
  156. min: 81,
  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. };
  193. },
  194. onShow() {
  195. },
  196. onLoad() {
  197. this.pageList()
  198. this.actionInfo = this.coinList[this.actionIndex]
  199. this.getSwiper()
  200. this.getListIficationBox()
  201. this.getExclusive()
  202. },
  203. methods: {
  204. changeIndicatorDots(e) {
  205. this.indicatorDots = true
  206. },
  207. changeAutoplay(e) {
  208. this.autoplay = true
  209. },
  210. intervalChange(e) {
  211. this.interval = e.target.value
  212. },
  213. durationChange(e) {
  214. this.duration = e.target.value
  215. },
  216. // 跳转点击事件
  217. toCoreRange(type,data) {
  218. // 跳转指令
  219. uni.navigateTo({
  220. url: `/pages/coreRange/coreRange?type=${type}&data=${data}`,
  221. })
  222. console.log(`标签是${type},数据是${data}`)
  223. },
  224. //轮播图
  225. getSwiper() {
  226. $http.post(`/api/v1/mp/user/exchange/banner/list`, {
  227. noToken: true,
  228. location: "top"
  229. }).then(res => {
  230. res.data.forEach(item => {
  231. let picUrlArr = item.picUrl.split(',')
  232. item.picUrl = env.filePublic + picUrlArr[0]
  233. })
  234. this.imgTop = this.imgTop.concat(res.data)
  235. })
  236. },
  237. // 分类列表
  238. getListIficationBox(){
  239. $http.post(`/api/v1/mp/user/exchange/category/list`, {noToken: true}).then(res => {
  240. res.data.forEach(item => {
  241. let picUrlArr = item.picUrl.split(',')
  242. item.picUrl = env.filePublic + picUrlArr[0]
  243. })
  244. this.goods = this.goods.concat(res.data)
  245. })
  246. },
  247. // 秒杀
  248. getExclusive(){
  249. $http.post(`/api/v1/mp/user/exchange/activity/list`, {noToken: true}).then(res => {
  250. this.exclusive = res.data
  251. let arr = []
  252. res.data.forEach(item=>{
  253. $http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=1&pageSize=4&orderByColumn=exchangePrice&isAsc=asc`, {
  254. noToken: true,
  255. tagIds: item.tagId, // 分类ID,可空
  256. }).then(r => {
  257. r.rows.forEach(ite => {
  258. let picUrlArr = ite.picUrl.split(',')
  259. ite.picUrl = env.filePublic + picUrlArr[0]
  260. })
  261. arr.push(r.rows)
  262. })
  263. })
  264. this.exclusiveSingle = arr
  265. })
  266. },
  267. //精选商品部分
  268. getList() {
  269. uni.showLoading({
  270. title: '加载中'
  271. });
  272. let data = {
  273. categoryId: '',
  274. ...this.coinNum,
  275. noToken: true
  276. }
  277. $http.post(`/api/v1/mp/user/exchange/goods/list?pageNum=${this.pageNum}&pageSize=20`, data).then(
  278. res => {
  279. uni.hideLoading();
  280. if (res.code == 0) {
  281. res.rows.forEach(item => {
  282. let picUrlArr = item.picUrl.split(',')
  283. item.picUrl = env.filePublic + picUrlArr[0]
  284. })
  285. this.total = res.total
  286. this.list = this.list.concat(res.rows)
  287. }
  288. }).catch(() => {
  289. uni.hideLoading();
  290. })
  291. },
  292. pageList() {
  293. this.pageNum = 1
  294. this.total = 0
  295. this.list = []
  296. this.getList()
  297. },
  298. openSelect() {
  299. uni.createSelectorQuery().select(".uSticky-toTop").boundingClientRect((data) => {
  300. uni.createSelectorQuery().select(".core-cla").boundingClientRect((res) => {
  301. uni.pageScrollTo({
  302. duration: 100, //过渡时间必须为0,uniapp bug,否则运行到手机会报错
  303. scrollTop: data.top - res.top,
  304. })
  305. }).exec()
  306. }).exec()
  307. this.coinShow = !this.coinShow
  308. },
  309. selectCoin(item, index) {
  310. this.actionIndex = index
  311. this.actionInfo = this.coinList[this.actionIndex]
  312. this.coinShow = false
  313. this.coinNum.startPrice = item.min
  314. this.coinNum.endPrice = item.max
  315. this.pageList()
  316. },
  317. },
  318. //精选商品
  319. onReachBottom() {
  320. // 判断是否有数据
  321. if (this.total > this.pageNum * 20) {
  322. setTimeout(() => {
  323. ++this.pageNum
  324. this.getList()
  325. }, 500)
  326. } else {
  327. uni.$u.toast('没有更多数据了')
  328. }
  329. },
  330. }
  331. </script>
  332. <style lang="scss" scoped>
  333. .swiper-ban {
  334. background-color: #FFFFFF;
  335. padding: 0 3px;
  336. .uni-padding-wrap {
  337. border-radius: 5px;
  338. overflow: hidden;
  339. }
  340. }
  341. .uni-padding-wrap img{
  342. width: 100%;
  343. height: 100%;
  344. }
  345. .classificationBox {
  346. background-color: #FFFFFF;
  347. display: grid;
  348. grid-template-columns: 1fr 1fr 1fr 1fr;
  349. font-size: 12px;
  350. .ificationBox-mar {
  351. margin: 0 auto;
  352. text-align: center;
  353. margin-top: 10px;
  354. margin-bottom: 10px;
  355. }
  356. }
  357. .ificationBox-mar img {
  358. width: 44px;
  359. height: 44px;
  360. border-radius: 29px;
  361. }
  362. .sticky-bac {
  363. margin-top: 10px;
  364. background-color: #FFFFFF;
  365. padding: 0 3px;
  366. .sticky-bac-text1 {
  367. color: #2f2f2f;
  368. font-size: 18px;
  369. line-height: 25px;
  370. display: inline-block;
  371. padding: 8px;
  372. };
  373. .sticky-bac-text2 {
  374. width: 128px;
  375. height: 40px;
  376. text-align: right;
  377. line-height: 40px;
  378. color: #9c9c9c;
  379. float: right;
  380. display: grid;
  381. grid-template-columns: 1fr 1fr;
  382. }
  383. }
  384. .Seckill-bom {
  385. padding: 0 0.3rem;
  386. // margin-bottom: 10px;
  387. background-color: #FFFFFF;
  388. .Seckill-bom-grid {
  389. min-height:550rpx ;
  390. display: flex;
  391. flex-wrap: wrap;
  392. justify-content: space-between;
  393. padding: 20rpx 15rpx;
  394. margin-bottom: 10px;
  395. }
  396. }
  397. //================
  398. .screen-coin {
  399. // position: fixed;
  400. width: 100%;
  401. z-index: 10;
  402. background-color: #FFFFFF;
  403. border-top: 1px solid #F8F8F8;
  404. box-shadow: 0 4rpx 10rpx 0 rgba(151, 151, 151, 0.24);
  405. &-select {
  406. height: 86rpx;
  407. line-height: 86rpx;
  408. width: 100%;
  409. justify-content: flex-start;
  410. .title {
  411. padding-left: 40rpx;
  412. margin-right: 10rpx;
  413. }
  414. }
  415. &-list {
  416. width: 100%;
  417. background-color: #FFFFFF;
  418. border-top: 1px solid #F8F8F8;
  419. &-item {
  420. height: 86rpx;
  421. line-height: 86rpx;
  422. background-color: #FFFFFF;
  423. border-bottom: 1px solid #F8F8F8;
  424. }
  425. &-item:last-child {
  426. border: 0;
  427. }
  428. .action {
  429. color: $uni-text-color;
  430. }
  431. }
  432. }
  433. .core {
  434. margin: 20rpx 0;
  435. &-list {
  436. justify-content: space-evenly;
  437. flex-wrap: wrap;
  438. // padding-top: 96rpx;
  439. &-item {
  440. box-sizing: border-box;
  441. width: 340rpx;
  442. height: 502rpx;
  443. background-color: #FFFFFF;
  444. border-radius: 10rpx;
  445. margin-bottom: 30rpx;
  446. .iamge-wrap {
  447. image {
  448. border-top-left-radius: 10rpx;
  449. border-top-right-radius: 10rpx;
  450. width: 340rpx;
  451. height: 340rpx;
  452. margin-bottom: 6rpx;
  453. }
  454. }
  455. .title {
  456. padding: 0 14rpx;
  457. font-size: 28rpx;
  458. line-height: 40rpx;
  459. overflow: hidden;
  460. text-overflow: ellipsis;
  461. display: -webkit-box;
  462. -webkit-box-orient: vertical;
  463. -webkit-line-clamp: 2;
  464. }
  465. .bean {
  466. padding: 0 14rpx;
  467. display: flex;
  468. align-items: center;
  469. font-size: 32rpx;
  470. line-height: 44rpx;
  471. color: rgba(235, 112, 9, 100);
  472. margin-top: 12rpx;
  473. image {
  474. width: 42rpx;
  475. height: 42rpx;
  476. margin-right: 16rpx;
  477. }
  478. }
  479. }
  480. &-item:last-child {
  481. padding: 0;
  482. height: 0;
  483. }
  484. }
  485. .empty {
  486. height: 60vh;
  487. }
  488. }
  489. </style>
  490. <style lang="scss" scoped>
  491. </style>