index.vue 9.7 KB

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