index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <view class="center">
  3. <view class="top">
  4. <view class="status_bar"><!-- 这里是状态栏 --></view>
  5. <view class="top-bg"><image src="../../static/img/index-bg.png" mode=""></image></view>
  6. </view>
  7. <view class="carousel">
  8. <swiper autoplay="true" duration="400" interval="5000" @change="swiperChange" class="bor">
  9. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"><image :src="item.pic" /></swiper-item>
  10. </swiper>
  11. </view>
  12. <view class="swiper-dot">
  13. <template v-for="item in swiperLength">
  14. <view class="swiper-dots-item" :key="item" :class="{ action: swiperCurrent + 1 === item }"></view>
  15. </template>
  16. </view>
  17. <view class="main">
  18. <view class="main-item" v-for="(item,index) in main" :key="index">
  19. <view class="pic">
  20. <image :src="item.pic" mode=""></image>
  21. </view>
  22. <view class="main-name">
  23. {{item.name}}
  24. </view>
  25. </view>
  26. </view>
  27. <!-- 商品栏 -->
  28. <view class="commodity">
  29. <view class="commodity-item" v-for="(item,index) in commodityList">
  30. <view class="commodity-prc">
  31. <image src="" mode=""></image>
  32. <view class="fanli" v-if="item.type == 1">
  33. <image src="../../static/img/index-fanl.png" mode=""></image>
  34. </view>
  35. </view>
  36. <view class="commodity-info">
  37. <view class="commodity-name clamp">
  38. {{item.name}}
  39. </view>
  40. <view class="commodity-systom clamp">
  41. {{item.systom}}
  42. </view>
  43. <view class="commodity-price">
  44. ¥{{item.price}}<text>¥{{item.price}}</text>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import { lala, lalaDetial, buylala } from '@/api/product.js';
  53. import { getTime } from '@/utils/rocessor.js';
  54. import { loadIndexs } from '@/api/user.js';
  55. export default {
  56. data() {
  57. return {
  58. carouselList:[],
  59. main:[{
  60. name:'自动拼团',
  61. pic:'../../static/icon/index1.png',
  62. type:1
  63. },
  64. {
  65. name:'11人团专区',
  66. pic:'../../static/icon/index2.png'
  67. },
  68. {
  69. name:'拼团合伙人',
  70. pic:'../../static/icon/index3.png'
  71. },
  72. {
  73. name:'素材分享',
  74. pic:'../../static/icon/index4.png'
  75. },
  76. {
  77. name:'邀请有礼',
  78. pic:'../../static/icon/index5.png'
  79. },
  80. {
  81. name:'拼购福利',
  82. pic:'../../static/icon/index6.png'
  83. },
  84. {
  85. name:'互助专区',
  86. pic:'../../static/icon/index7.png'
  87. },
  88. {
  89. name:'签到领钱',
  90. pic:'../../static/icon/index8.png'
  91. },
  92. {
  93. name:'服务器兑换',
  94. pic:'../../static/icon/index9.png'
  95. },
  96. {
  97. name:'话费充值',
  98. pic:'../../static/icon/index10.png'
  99. },
  100. ],
  101. swiperLength: 0,
  102. swiperCurrent: 0,
  103. commodityList:[{
  104. name:'古驰马衔扣单肩包',
  105. systom:'1955系列单肩包女包',
  106. price:'2690.32',
  107. type:1
  108. },
  109. {
  110. name:'古驰马衔扣单肩包',
  111. systom:'1955系列单肩包女包',
  112. price:'2690',
  113. type:0
  114. },
  115. {
  116. name:'古驰马衔扣单肩包',
  117. systom:'1955系列单肩包女包',
  118. price:'2690',
  119. type:0
  120. },
  121. {
  122. name:'古驰马衔扣单肩包',
  123. systom:'1955系列单肩包女包',
  124. price:'2690',
  125. type:1
  126. },
  127. ],
  128. };
  129. },
  130. //页面加载即刻发生
  131. onShow() {
  132. this.loadDate();
  133. },
  134. methods: {
  135. async loadDate() {
  136. const obj = this
  137. loadIndexs({}).then(({ data }) => {
  138. console.log(data);
  139. obj.carouselList = data.banner;
  140. obj.swiperLength = data.banner.length;
  141. })
  142. },
  143. //轮播图切换修改背景色
  144. swiperChange(e) {
  145. const index = e.detail.current;
  146. this.swiperCurrent = index;
  147. },
  148. }
  149. };
  150. </script>
  151. <style lang="scss">
  152. .center {
  153. height: auto;
  154. min-height: 100%;
  155. background-color: #ffffff;
  156. }
  157. .status_bar {
  158. height: var(--status-bar-height);
  159. width: 100%;
  160. }
  161. .top {
  162. width: 100%;
  163. height: 338rpx;
  164. position: relative;
  165. .top-bg {
  166. position: absolute;
  167. top: 0;
  168. left: 0;
  169. width: 100%;
  170. height: 338rpx;
  171. image {
  172. width: 100%;
  173. height: 100%;
  174. }
  175. }
  176. }
  177. .carousel {
  178. width: 700rpx;
  179. height: 300rpx;
  180. border-radius: 14rpx;
  181. margin: -200rpx auto 0;
  182. .bor {
  183. border-radius: 14rpx;
  184. .carousel-item {
  185. image {
  186. width: 100%;
  187. height: 100%;
  188. border-radius: 14rpx;
  189. }
  190. }
  191. }
  192. }
  193. .swiper-dot {
  194. position: relative;
  195. z-index: 10;
  196. margin-top: -40rpx;
  197. display: flex;
  198. justify-content: center;
  199. .swiper-dots-item {
  200. width: 14rpx;
  201. height: 14rpx;
  202. background: #aaaaaa;
  203. border-radius: 50%;
  204. margin: 0 16rpx;
  205. // z-index: 999;
  206. }
  207. .action {
  208. background-color: #ffffff;
  209. }
  210. }
  211. .main {
  212. margin-top: 80rpx;
  213. display: flex;
  214. width: 100%;
  215. align-items: center;
  216. flex-wrap: wrap;
  217. .main-item {
  218. margin: 20rpx 0;
  219. width: 20%;
  220. display: flex;
  221. flex-direction: column;
  222. align-items: center;
  223. .pic {
  224. width: 64rpx;
  225. height: 64rpx;
  226. image{
  227. width: 100%;
  228. height: 100%;
  229. }
  230. }
  231. .main-name {
  232. font-size: 24rpx;
  233. font-family: PingFang SC;
  234. font-weight: 500;
  235. color: #333333;
  236. margin-top: 10rpx;
  237. }
  238. }
  239. }
  240. .commodity {
  241. padding: 36rpx 14rpx;
  242. margin-top: 20rpx;
  243. display: flex;
  244. flex-wrap: wrap;
  245. .commodity-item {
  246. width: 348rpx;
  247. background: #FFFFFF;
  248. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  249. margin:10rpx 6rpx 0;
  250. border-radius: 10rpx;
  251. .commodity-prc {
  252. width: 345rpx;
  253. height: 345rpx;
  254. border-radius: 10rpx;
  255. }
  256. .commodity-info {
  257. padding: 28rpx 20rpx 35rpx 24rpx;
  258. .commodity-name {
  259. width: 100%;
  260. font-size: 30rpx;
  261. font-family: PingFang SC;
  262. font-weight: bold;
  263. color: #333333;
  264. }
  265. .commodity-systom {
  266. margin-top: 16rpx;
  267. font-size: 26rpx;
  268. font-family: PingFang SC;
  269. font-weight: 500;
  270. color: #666666;
  271. }
  272. .commodity-price {
  273. margin-top: 34rpx;
  274. font-size: 36rpx;
  275. font-family: PingFang SC;
  276. font-weight: bold;
  277. color: #E83F30;
  278. text {
  279. display: inline-block;
  280. padding-left: 6rpx;
  281. font-size: 26rpx;
  282. font-family: PingFang SC;
  283. font-weight: bold;
  284. text-decoration: line-through;
  285. color: #999999;
  286. }
  287. }
  288. }
  289. }
  290. }
  291. </style>