index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <template>
  2. <view class="container">
  3. <view class="top">
  4. <!-- <image class="top-bg" src="../../static/img/top-bg.png" mode=""></image> -->
  5. <view class="top-main flex">
  6. <view class="search-box flex" @click="clickSearch()">
  7. <image class="search" src="../../static/img/search-h.png" mode=""></image>
  8. <view class="search-font">输入关键词搜索</view>
  9. </view>
  10. </view>
  11. <swiper class="carousel" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  12. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
  13. @click="bannerNavToUrl(item)">
  14. <image class="img" :src="item.pic" mode="scaleToFill" />
  15. </swiper-item>
  16. </swiper>
  17. </view>
  18. <view class="box">
  19. <view class="box-title">
  20. <view class="left flex">
  21. <view class="item" @click="changeList(0)" :class="{action:checked==0}">
  22. 艺绘发售
  23. </view>
  24. <view class="item margin-l-30" @click="changeList(1)" :class="{action:checked==1}">
  25. 盲盒发售
  26. </view>
  27. </view>
  28. </view>
  29. <view v-show="checked==0" class="box-content" v-for="(item,index) in dataList[0].list" @click="buy(item)">
  30. <view class="img">
  31. <image :src="item.image" mode=""></image>
  32. </view>
  33. <view class="content-title">
  34. <view class="title">
  35. {{item.store_name}}
  36. </view>
  37. <view>
  38. <view class="text">
  39. 艺绘官方 发行
  40. </view>
  41. <view class="text flex">
  42. <view class="flex">
  43. <view class="textStock border-radius-10 flex">
  44. <view class="tip">
  45. 限量
  46. </view>
  47. <view class="num">
  48. {{item.stock}}
  49. </view>
  50. </view>
  51. <view class="tip border-radius-10 margin-l-10">
  52. 限购{{item.buy_limit}}份
  53. </view>
  54. </view>
  55. <view class="money">
  56. ¥{{item.price}}
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <u-loadmore v-show="checked==0" :status="dataList[0].list.loadType" />
  63. <view v-show="checked==1" class="box-content" v-for="(item,index) in dataList[1].list" @click="buyMh(item)">
  64. <view class="img">
  65. <image :src="item.pic" mode=""></image>
  66. </view>
  67. <view class="content-title">
  68. <view class="title">
  69. {{item.name}}
  70. </view>
  71. <view class="text">
  72. 艺绘官方 发行
  73. </view>
  74. <view class="text">
  75. ¥{{item.price}}
  76. </view>
  77. </view>
  78. </view>
  79. <u-loadmore v-show="checked==1" :status="dataList[1].list.loadType" />
  80. </view>
  81. </view>
  82. </template>
  83. <script>
  84. import {
  85. getProducts,
  86. mysteryList
  87. } from '@/api/product.js';
  88. import {
  89. loadIndexs
  90. } from '@/api/index.js'
  91. import {
  92. mapState,
  93. mapMutations
  94. } from 'vuex';
  95. export default {
  96. data() {
  97. return {
  98. checked: 0, //当前选中的出售对象
  99. isSc: 2,
  100. carouselList: [], //轮播列表
  101. dataList: [{
  102. list: [], //艺发售
  103. page: 1,
  104. limit: 1,
  105. loadType: 'loadmore',
  106. }, {
  107. list: [], //盲盒发售
  108. page: 1,
  109. limit: 1,
  110. loadType: 'loadmore',
  111. }]
  112. };
  113. },
  114. computed: {
  115. ...mapState(['loginInterceptor', 'baseURL']),
  116. ...mapState('user', ['hasLogin', 'userInfo'])
  117. },
  118. onLoad: function(option) {
  119. this.loadIndex()
  120. },
  121. onShow: function() {
  122. this.getProduct()
  123. },
  124. onReachBottom() {
  125. this.getProduct()
  126. },
  127. methods: {
  128. ...mapMutations(['setLat', 'setLon']),
  129. loadIndex() {
  130. let obj = this
  131. loadIndexs().then(res => {
  132. obj.carouselList = res.data.banner
  133. })
  134. },
  135. // 切换选中的需要显示的列表数据
  136. changeList(ind) {
  137. // 判断是否重复点击
  138. if (this.checked == ind) {
  139. return
  140. }
  141. this.checked = ind;
  142. this.getProduct()
  143. },
  144. // 更新数据
  145. getProduct() {
  146. let obj = this;
  147. let item = obj.dataList[obj.checked];
  148. if (item.loadType === 'loading') {
  149. //防止重复加载
  150. return;
  151. }
  152. if (item.loadType === 'nomore') {
  153. //防止重复加载
  154. return;
  155. }
  156. // 修改当前对象状态为加载中
  157. item.loadType = 'loading';
  158. // 判断是否为艺绘商品
  159. if (obj.checked == 0) {
  160. this.getBaseYh(item)
  161. }
  162. // 判断是否盲盒
  163. if (obj.checked == 1) {
  164. this.mysteryList(item)
  165. }
  166. },
  167. // 盲盒列表
  168. mysteryList(item) {
  169. mysteryList({
  170. page: item.page,
  171. limit: item.limit
  172. }).then(res => {
  173. let arr = res.data.list.map((e) => {
  174. return e
  175. })
  176. item.list = item.list.concat(arr);
  177. item.page++;
  178. if (item.limit == arr.length) {
  179. //判断是否还有数据, 有改为 more, 没有改为noMore
  180. item.loadType = 'loadmore';
  181. return;
  182. } else {
  183. //判断是否还有数据, 有改为 more, 没有改为noMore
  184. item.loadType = 'nomore';
  185. }
  186. })
  187. },
  188. // 获取艺商品
  189. getBaseYh(item) {
  190. getProducts({
  191. page: item.page,
  192. limit: item.limit
  193. }).then(res => {
  194. let arr = res.data.map((e) => {
  195. let time = new Date(e.sell_time * 1000);
  196. e.cmy_pay_time = time.getFullYear() + '年' + (time.getMonth() + 1) + '月' + time
  197. .getDate() + '日' + time.getHours() + '时' + time.getMinutes() + '分' + time
  198. .getSeconds() + '秒'
  199. return e
  200. })
  201. item.list = item.list.concat(arr);
  202. item.page++;
  203. if (item.limit == arr.length) {
  204. //判断是否还有数据, 有改为 more, 没有改为noMore
  205. item.loadType = 'loadmore';
  206. return;
  207. } else {
  208. //判断是否还有数据, 有改为 more, 没有改为noMore
  209. item.loadType = 'nomore';
  210. }
  211. })
  212. },
  213. // 普通商品
  214. buy(item) {
  215. console.log(item, 'res');
  216. uni.navigateTo({
  217. url: '/pages/product/product?id=' + item.id + '&isSc=' + this.isSc
  218. })
  219. },
  220. // 盲盒
  221. buyMh(item) {
  222. uni.navigateTo({
  223. url: '/pages/product/productMh?id=' + item.id
  224. })
  225. },
  226. navTo(url) {
  227. uni.switchTab({
  228. url
  229. })
  230. },
  231. // 點擊搜索框
  232. clickSearch() {
  233. uni.navigateTo({
  234. url: '/pages/product/search'
  235. });
  236. },
  237. swiperChange() {}
  238. }
  239. };
  240. </script>
  241. <style lang="scss">
  242. page {
  243. width: 750rpx;
  244. min-height: 100%;
  245. // background: #111111;
  246. }
  247. .carousel {
  248. width: 750rpx;
  249. height: 375rpx;
  250. .carousel-item {
  251. height: 100%;
  252. width: 100%;
  253. .img {
  254. height: 100%;
  255. width: 100%;
  256. }
  257. }
  258. }
  259. .top {
  260. position: relative;
  261. width: 100%;
  262. .top-bg {
  263. position: absolute;
  264. top: 0;
  265. left: 0;
  266. right: 0;
  267. width: 100%;
  268. height: 100%;
  269. }
  270. .top-main {
  271. position: relative;
  272. z-index: 2;
  273. padding: 30rpx;
  274. .search-box {
  275. justify-content: flex-start;
  276. width: 698rpx;
  277. height: 60rpx;
  278. background: #1d1c21;
  279. border-radius: 10rpx;
  280. padding-left: 20rpx;
  281. .search {
  282. width: 34rpx;
  283. height: 34rpx;
  284. }
  285. .search-font {
  286. margin-left: 14rpx;
  287. font-size: 28rpx;
  288. font-family: PingFang SC;
  289. font-weight: 500;
  290. color: #a4a4a4;
  291. }
  292. }
  293. }
  294. }
  295. .box {
  296. padding: 30rpx;
  297. .box-title {
  298. margin-top: 20rpx;
  299. display: flex;
  300. justify-content: space-between;
  301. margin-bottom: 50rpx;
  302. .left {
  303. font-size: 34rpx;
  304. font-family: PingFang SC;
  305. font-weight: 500;
  306. color: #FFFFFF;
  307. .action {
  308. color: #FDD58A;
  309. }
  310. }
  311. .right {
  312. font-size: 24rpx;
  313. font-family: PingFang SC;
  314. font-weight: 500;
  315. color: #FFFFFF;
  316. line-height: 120rpx;
  317. }
  318. }
  319. .box-content {
  320. margin-bottom: 50rpx;
  321. background-color: rgb(15, 15, 15);
  322. border-radius: 20rpx;
  323. overflow: hidden;
  324. .img {
  325. width: 690rpx;
  326. height: 690rpx;
  327. image {
  328. width: 100%;
  329. height: 100%;
  330. }
  331. }
  332. .content-title {
  333. padding: 30rpx 20rpx;
  334. border-bottom-left-radius: 10rpx;
  335. border-bottom-right-radius: 10rpx;
  336. background-color: rgb(29, 28, 33);
  337. .title {
  338. font-size: 39rpx;
  339. font-weight: bold;
  340. color: #FFFFFF;
  341. margin-bottom: 20rpx;
  342. }
  343. .text {
  344. margin: 10rpx 0;
  345. color: #FFFFFF;
  346. font-size: 28rpx;
  347. flex-grow: 1;
  348. .textStock {
  349. overflow: hidden;
  350. }
  351. .num {
  352. font-size: 18rpx;
  353. padding: 10rpx;
  354. color: #9F570E;
  355. background-color: #4D3414;
  356. }
  357. .money{
  358. font-size: 40rpx;
  359. }
  360. .tip {
  361. font-size: 20rpx;
  362. color: #9F570E;
  363. padding: 10rpx;
  364. line-height: 1;
  365. background: $bgBaseBg;
  366. }
  367. }
  368. }
  369. }
  370. }
  371. .popup-box {
  372. width: 522rpx;
  373. height: 605rpx;
  374. background-color: #ffffff;
  375. border-radius: 20rpx;
  376. position: relative;
  377. .img {
  378. position: relative;
  379. top: -56rpx;
  380. left: 0;
  381. width: 522rpx;
  382. height: 132rpx;
  383. display: flex;
  384. justify-content: center;
  385. image {
  386. border-radius: 20rpx 20rpx 0 0;
  387. width: 450rpx;
  388. height: 132rpx;
  389. }
  390. }
  391. .mian {
  392. margin-top: -44rpx;
  393. display: flex;
  394. flex-direction: column;
  395. align-items: center;
  396. // padding: 32rpx 32rpx;
  397. background-color: #ffffff;
  398. border-radius: 0 0 20rpx 20rpx;
  399. text-align: center;
  400. .delivery {
  401. font-size: 40rpx;
  402. color: #333333;
  403. display: flex;
  404. align-items: center;
  405. flex-direction: column;
  406. .title {}
  407. image {
  408. margin-top: 48rpx;
  409. width: 172rpx;
  410. height: 160rpx;
  411. }
  412. }
  413. .nocancel {
  414. font-size: 32rpx;
  415. color: #333333;
  416. margin-top: 14rpx;
  417. }
  418. .comfirm-box {
  419. margin-top: 52rpx;
  420. display: flex;
  421. // margin-bottom: 32rpx;
  422. // justify-content: space-around;
  423. .cancel {
  424. display: flex;
  425. align-items: center;
  426. justify-content: center;
  427. width: 197rpx;
  428. height: 74rpx;
  429. border: 1px solid #dcc786;
  430. border-radius: 38rpx;
  431. font-size: 32rpx;
  432. color: #605128;
  433. }
  434. .comfirm {
  435. margin-left: 32rpx;
  436. display: flex;
  437. align-items: center;
  438. justify-content: center;
  439. width: 197rpx;
  440. height: 74rpx;
  441. background: linear-gradient(-90deg, #d1ba77 0%, #f7e8ad 100%);
  442. border-radius: 38px;
  443. font-size: 32rpx;
  444. color: #605128;
  445. }
  446. }
  447. }
  448. }
  449. .tongz {
  450. width: 690rpx;
  451. height: 70rpx;
  452. margin: 32rpx auto 0;
  453. padding: 18rpx 30rpx 18rpx 24rpx;
  454. align-items: center;
  455. position: relative;
  456. .tongz-bg {
  457. position: absolute;
  458. top: 0;
  459. right: 0;
  460. left: 0;
  461. width: 690rpx;
  462. height: 70rpx;
  463. image {
  464. width: 100%;
  465. height: 100%;
  466. }
  467. }
  468. .tongz-left {
  469. width: 640rpx;
  470. .image-left {
  471. width: 28rpx;
  472. height: 34rpx;
  473. }
  474. .tongz-font {
  475. margin-left: 22rpx;
  476. font-size: 28rpx;
  477. font-family: Source Han Sans CN;
  478. font-weight: 400;
  479. color: #0f253a;
  480. }
  481. }
  482. .tongz-right {
  483. position: relative;
  484. z-index: 11;
  485. width: 12rpx;
  486. height: 26rpx;
  487. image {
  488. width: 100%;
  489. height: 100%;
  490. }
  491. }
  492. }
  493. </style>