index.vue 14 KB

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