Home.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <div class="home">
  3. <swiper
  4. :effect="'coverflow'"
  5. :grabCursor="true"
  6. :centeredSlides="true"
  7. :slidesPerView="'auto'"
  8. :coverflowEffect="{
  9. rotate: 30,
  10. stretch: 0,
  11. depth: 0,
  12. modifier: 1,
  13. slideShadows: true
  14. }"
  15. class="mySwiper"
  16. v-if="banners.length > 0"
  17. >
  18. <template v-for="item in banners" :key="item.id">
  19. <swiper-slide>
  20. <van-image :radius="6" width="100%" height="calc(45vw - 29px)" :src="item.pic" fit="cover" />
  21. </swiper-slide>
  22. </template>
  23. </swiper>
  24. <div class="box" v-if="box.length > 0">
  25. <page-title title="数字盲盒" :to="{ path: '/productList', query: { type: 'BLIND_BOX' } }"></page-title>
  26. <div class="box-list">
  27. <product-info v-for="(item, index) in box" :key="item.id" v-model:info="box[index]"></product-info>
  28. </div>
  29. </div>
  30. <div class="box">
  31. <page-title title="最HOT收藏品" :to="{ path: '/productList', query: { type: 'DEFAULT' } }"></page-title>
  32. <div class="box-list">
  33. <template v-for="(item, index) in products" :key="item.id">
  34. <product-info v-model:info="products[index]"></product-info
  35. ></template>
  36. </div>
  37. </div>
  38. <!-- <page-title title="最HOT收藏品"></page-title>
  39. <div class="hot">
  40. <product-info></product-info>
  41. <div class="hot-right">
  42. <product-small></product-small>
  43. <product-small></product-small>
  44. </div>
  45. </div> -->
  46. <div class="casting">
  47. <page-title title="最受欢迎铸造者" :to="{ path: '/creatorList' }"></page-title>
  48. <template v-for="(item, index) in miners" :key="index">
  49. <creator-info
  50. :rank="index < 3 ? index + 1 : 0"
  51. v-model:info="miners[index]"
  52. size="large"
  53. ></creator-info>
  54. </template>
  55. </div>
  56. <div class="tabbar-placeholder"></div>
  57. </div>
  58. </template>
  59. <script>
  60. // @ is an alias to /src
  61. import { Swiper, SwiperSlide } from 'swiper/vue';
  62. // Import Swiper styles
  63. import 'swiper/swiper.min.css';
  64. import 'swiper/swiper-bundle.min.css';
  65. import SwiperCore, { EffectCoverflow } from 'swiper';
  66. import ProductInfo from '../components/product/productInfo.vue';
  67. // import ProductSmall from "../components/product/productSmall.vue";
  68. import CreatorInfo from '../components/creator/CreatorInfo.vue';
  69. // install Swiper modules
  70. SwiperCore.use([EffectCoverflow]);
  71. export default {
  72. name: 'Home',
  73. inject: ['bs'],
  74. components: {
  75. Swiper,
  76. SwiperSlide,
  77. ProductInfo,
  78. CreatorInfo
  79. },
  80. data() {
  81. return {
  82. banners: [],
  83. box: [],
  84. products: [],
  85. miners: []
  86. };
  87. },
  88. mounted() {
  89. this.$toast.loading({
  90. message: '加载中...',
  91. forbidClick: true
  92. });
  93. Promise.all([
  94. this.$http
  95. .post(
  96. '/banner/all',
  97. {
  98. query: {
  99. type: 'HOME'
  100. },
  101. sort: 'createdAt,desc'
  102. },
  103. { body: 'json' }
  104. )
  105. .then(res => {
  106. this.banners = res.content;
  107. }),
  108. this.getProduct('BLIND_BOX').then(res => {
  109. this.box = res;
  110. }),
  111. this.getProduct().then(res => {
  112. this.products = res;
  113. }),
  114. this.getMiner()
  115. ]).then(() => {
  116. this.$toast.clear();
  117. });
  118. },
  119. methods: {
  120. getProduct(type = 'DEFAULT') {
  121. return this.$http
  122. .post(
  123. '/collection/all',
  124. {
  125. page: 0,
  126. size: 4,
  127. query: {
  128. type: type,
  129. onShelf: true,
  130. del: false
  131. },
  132. sort: 'createdAt,desc'
  133. },
  134. { body: 'json' }
  135. )
  136. .then(res => {
  137. return Promise.resolve(res.content);
  138. });
  139. },
  140. getMiner() {
  141. this.$http
  142. .post(
  143. '/user/all',
  144. {
  145. page: 0,
  146. query: { hasRole: 'ROLE_MINTER' },
  147. size: 5,
  148. sort: 'sales,desc'
  149. },
  150. { body: 'json' }
  151. )
  152. .then(res => {
  153. this.miners = res.content;
  154. });
  155. }
  156. }
  157. };
  158. </script>
  159. <style lang="less" scoped>
  160. .swiper {
  161. width: 100%;
  162. padding-top: 50px;
  163. padding-bottom: 50px;
  164. }
  165. .swiper-slide {
  166. background-position: center;
  167. background-size: cover;
  168. width: calc(100vw - 66px);
  169. height: calc(45vw - 29px);
  170. img {
  171. width: calc(100vw - 66px);
  172. height: calc(45vw - 29px);
  173. display: block;
  174. }
  175. .van-image {
  176. border-radius: 6px;
  177. }
  178. }
  179. .swiper-slide img {
  180. display: block;
  181. width: 100%;
  182. }
  183. .home {
  184. padding: 10px 0 100px 0;
  185. }
  186. .hot {
  187. display: flex;
  188. padding: 0 8px;
  189. .hot-right {
  190. display: flex;
  191. flex-direction: column;
  192. justify-content: space-between;
  193. }
  194. }
  195. .box-list {
  196. padding: 0 8px;
  197. display: flex;
  198. flex-wrap: wrap;
  199. .product {
  200. margin-bottom: 16px;
  201. }
  202. }
  203. </style>