home.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <scroll-view class="home" scroll-y @scrolltolower='onBottom'>
  3. <!-- <van-tabs >
  4. <van-tab title="标签 1">内容 1</van-tab>
  5. <van-tab title="标签 2">内容 2</van-tab>
  6. <van-tab title="标签 3">内容 3</van-tab>
  7. <van-tab title="标签 4">内容 4</van-tab>
  8. </van-tabs> -->
  9. <view class="top-list">
  10. <image class="background-img" style="width: 100vw;" src="https://t1-1305573081.cos.ap-shanghai.myqcloud.com/wxapp/static/imgs/%E9%A1%B6%E9%83%A8%E8%83%8C%E6%99%AF3.png"
  11. mode="widthFix"></image>
  12. <topbar class="topbar-slot">
  13. <view>
  14. <text style="color: #FFFFFF;">极速生活圈</text>
  15. </view>
  16. </topbar>
  17. <loadSke :loading='topLoading' :list='bannerList'>
  18. <swiper class="swiper-box" :current="current" autoplay circular indicator-dots>
  19. <swiper-item v-for="(item,index) in bannerList" :key='index'>
  20. <image @click="clickJumpType(item)" class="image" :src="item.fileUrl" mode="scaleToFill" :draggable="false" />
  21. </swiper-item>
  22. </swiper>
  23. <view class="eat-box">
  24. <view class="eat" v-for="(item,index) in couponList" :key='index' @click="clickJumpType(item)">
  25. <image :src="item.fileUrl" mode="scaleToFill" class="img"></image>
  26. <view class="text-box">
  27. <text class="text-1">{{item.pictureName}}</text>
  28. <text class="text-2">{{item.dataDescribe.split(' ')[0]}}</text>
  29. <text class="text-3">{{item.dataDescribe.split(' ')[1]}}</text>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="menu-box">
  34. <view class="menu" v-for="(item,index) in menuList" :key='index' @click="clickJumpType(item)">
  35. <image :src="item.fileUrl" mode="scaleToFill" class="img"></image>
  36. <text class="text-1">{{item.pictureName}}</text>
  37. <text class="text-2">{{item.dataDescribe || '暂无描述'}}</text>
  38. </view>
  39. </view>
  40. </loadSke>
  41. </view>
  42. <view class="bottom-ad" v-for="(item,index) in bottomAD" :key='index' @click="clickJumpType(item)">
  43. <image style="width: 100%;" :src="item.fileUrl" mode="widthFix"></image>
  44. <text>今日仅剩{{dynamicQuantity(index)}}个</text>
  45. <button>免费领取</button>
  46. </view>
  47. <view class="item-box">
  48. <view class="item-titBox">
  49. <text class="item-tit">限时特价</text>
  50. <!-- <text class="item-tit-right" @tap='go()'>更多视频 ></text> -->
  51. </view>
  52. <loadSke :loading='pddLoading' :list='pddList'>
  53. <view class="flex-box">
  54. <view class="film-box" v-for="(item,index) in pddList" :key='index' @click="goMiniApp(JSON.stringify({appId:item.we_app_info.app_id,path:item.we_app_info.page_path}))">
  55. <image :src="item.goods_image_url" mode="widthFix" class="img" draggable></image>
  56. <view class="bottom-box">
  57. <view class="tit">
  58. <text class="text-1">{{item.goods_name}}</text>
  59. </view>
  60. <view class="des-box">
  61. <view class="des">{{item.unified_tags}}</view>
  62. </view>
  63. <view class="buy-box">
  64. <text class="price">{{'¥'+(item.min_group_price)/100}}</text>
  65. <button type="default" class="buy">活动价 {{'¥'+(item.min_group_price-item.coupon_discount)/100}}</button>
  66. </view>
  67. </view>
  68. </view>
  69. <view v-if="pddDataLoading" class="bottom-loading">
  70. 正在加载中...
  71. </view>
  72. </view>
  73. </loadSke>
  74. </view>
  75. </scroll-view>
  76. </template>
  77. <script>
  78. import {
  79. getHomePageDataList,
  80. getPDD,
  81. getPddWxData
  82. } from '@/api/home.js'
  83. export default {
  84. data: () => ({
  85. bannerList: [],
  86. couponList: [],
  87. menuList: [],
  88. bottomAD: [],
  89. topLoading: true,
  90. pddList: [],
  91. pddLoading: true,
  92. limit: 6,
  93. page: 0,
  94. pddDataLoading: false
  95. }),
  96. mounted() {
  97. this.init()
  98. },
  99. methods: {
  100. onBottom() {
  101. if (this.pddDataLoading) return
  102. this.pddDataLoading = true
  103. this.page++
  104. getPddWxData({
  105. limit: this.limit,
  106. offset: this.page * this.limit
  107. }).then(res => {
  108. this.pddList = this.pddList.concat(res)
  109. this.$nextTick(() => {
  110. this.pddLoading = false
  111. this.pddDataLoading = false
  112. })
  113. })
  114. },
  115. dynamicQuantity(index) {
  116. index++
  117. let x = new Date().getHours() / 3
  118. let num = ((x - 8) ** 2) + index * (8 - x) * 1 + index * 3 + 1
  119. return parseInt(num)
  120. },
  121. init() {
  122. getHomePageDataList().then(res => {
  123. this.bannerList = res.data.carouselChart
  124. this.couponList = res.data.coupon.slice(0, 4)
  125. this.menuList = res.data.menu
  126. this.bottomAD = res.data.bottomAD
  127. this.$nextTick(() => {
  128. this.topLoading = false
  129. })
  130. })
  131. getPddWxData({
  132. limit: this.limit,
  133. offset: this.page * this.limit
  134. }).then(res => {
  135. this.pddList = res
  136. this.$nextTick(() => {
  137. this.pddLoading = false
  138. })
  139. })
  140. }
  141. }
  142. }
  143. </script>
  144. <style scoped lang="scss">
  145. .home{
  146. height: 100%;
  147. }
  148. .top-list {
  149. padding: 30rpx;
  150. padding-top: 0;
  151. box-sizing: border-box;
  152. width: 100%;
  153. background-color: #FFFFFF;
  154. position: relative;
  155. .topbar-slot {
  156. z-index: 1;
  157. align-self: center;
  158. display: flex;
  159. justify-content: center;
  160. }
  161. .background-img {
  162. position: absolute;
  163. top: 0;
  164. left: 0;
  165. }
  166. .swiper-box {
  167. width: 690rpx;
  168. height: 342rpx;
  169. overflow: hidden;
  170. .image {
  171. width: 100%;
  172. height: 100%;
  173. border-radius: 10px;
  174. }
  175. }
  176. .eat-box {
  177. margin-top: 30rpx;
  178. display: flex;
  179. justify-content: space-between;
  180. .eat {
  181. width: 158rpx;
  182. height: 240rpx;
  183. position: relative;
  184. .img {
  185. width: 100%;
  186. height: 100%;
  187. }
  188. .text-box {
  189. display: flex;
  190. flex-direction: column;
  191. justify-content: center;
  192. align-items: center;
  193. position: absolute;
  194. bottom: 10rpx;
  195. left: 50%;
  196. width: 100%;
  197. transform: translateX(-50%);
  198. .text-1 {
  199. font-size: 24rpx;
  200. color: #0F0404;
  201. text-align: center;
  202. }
  203. .text-2 {
  204. margin-top: 5rpx;
  205. font-size: 20rpx;
  206. color: #FE3232;
  207. text-align: center;
  208. }
  209. .text-3 {
  210. font-size: 20rpx;
  211. color: #666666;
  212. text-align: center;
  213. }
  214. }
  215. }
  216. }
  217. .menu-box {
  218. display: flex;
  219. justify-content: flex-start;
  220. flex-wrap: wrap;
  221. margin: 0 -10rpx;
  222. .menu {
  223. width: 20%;
  224. padding: 0 10rpx;
  225. box-sizing: border-box;
  226. // height: 121rpx;
  227. margin-top: 40rpx;
  228. display: flex;
  229. flex-direction: column;
  230. justify-content: space-between;
  231. align-items: center;
  232. .img {
  233. flex-shrink: 0;
  234. width: 83rpx;
  235. height: 83rpx;
  236. border-radius: 50%;
  237. }
  238. .text-1 {
  239. margin-top: 10rpx;
  240. font-size: 24rpx;
  241. color: #0F0404;
  242. text-align: center;
  243. overflow: hidden;
  244. text-overflow: ellipsis;
  245. white-space: nowrap;
  246. }
  247. .text-2 {
  248. font-size: 20rpx;
  249. color: #666666;
  250. text-align: center;
  251. overflow: hidden;
  252. text-overflow: ellipsis;
  253. white-space: nowrap;
  254. }
  255. }
  256. }
  257. }
  258. .bottom-ad {
  259. margin-top: -15rpx;
  260. position: relative;
  261. &:nth-child(2) {
  262. margin-top: 20rpx;
  263. }
  264. text {
  265. position: absolute;
  266. top: 104rpx;
  267. left: 220rpx;
  268. padding: 10rpx 15rpx;
  269. background: #FFE1D9;
  270. font-size: 22rpx;
  271. font-family: PingFang SC;
  272. font-weight: 400;
  273. color: #A40303;
  274. }
  275. button {
  276. position: absolute;
  277. top: 67rpx;
  278. right: 40rpx;
  279. display: inline-block;
  280. margin: 0;
  281. padding: 0rpx 26rpx;
  282. background: linear-gradient(90deg, #E31818, #ED3E24, #ED4F24);
  283. border-radius: 30rpx;
  284. font-size: 26rpx;
  285. font-family: PingFang SC;
  286. font-weight: 400;
  287. color: #FFFFFF;
  288. }
  289. }
  290. .item-box {
  291. background-color: #fff;
  292. // margin-top: 40rpx;
  293. .item-titBox {
  294. display: flex;
  295. justify-content: space-between;
  296. align-items: center;
  297. padding: 20rpx;
  298. border-bottom: 1rpx solid #e8e8e8;
  299. .item-tit {
  300. border-left: 8rpx solid #E31818;
  301. font-size: 30rpx;
  302. padding: 11rpx;
  303. margin-left: 20rpx;
  304. }
  305. .item-tit-right {
  306. font-size: 26rpx;
  307. color: #666666;
  308. line-height: 58rpx;
  309. padding: 11rpx;
  310. }
  311. }
  312. .flex-box {
  313. width: 100%;
  314. display: flex;
  315. justify-content: center;
  316. align-items: flex-start;
  317. // flex-direction: column;
  318. flex-wrap: wrap;
  319. background-color: #F8F8F8;
  320. padding-bottom: 20rpx;
  321. .film-box {
  322. width: 334rpx;
  323. border-radius: 20rpx;
  324. overflow: hidden;
  325. background: #FFFFFF;
  326. margin: 30rpx 11rpx 0;
  327. .img {
  328. width: 100%;
  329. }
  330. .bottom-box {
  331. padding: 30rpx 20rpx;
  332. .tit {
  333. display: flex;
  334. justify-content: space-between;
  335. .text-1 {
  336. width: 100%;
  337. font-size: 26rpx;
  338. overflow: hidden;
  339. text-overflow: ellipsis;
  340. // white-space: nowrap;
  341. }
  342. }
  343. .des-box {
  344. margin-top: 10rpx;
  345. .des {
  346. width: 100%;
  347. font-size: 22rpx;
  348. color: #666666;
  349. overflow: hidden;
  350. text-overflow: ellipsis;
  351. white-space: nowrap;
  352. }
  353. }
  354. .buy-box {
  355. margin-top: 20rpx;
  356. display: flex;
  357. justify-content: flex-start;
  358. align-items: center;
  359. .price {
  360. // color: #E31818;
  361. text-decoration: line-through;
  362. font-size: 34rpx;
  363. }
  364. .buy {
  365. height: 40rpx;
  366. background: linear-gradient(90deg, #E31818, #ED3E24, #ED4F24);
  367. border-radius: 20rpx;
  368. margin-left: 10rpx;
  369. font-size: 20rpx;
  370. color: #FFFFFF;
  371. display: flex;
  372. justify-content: center;
  373. align-items: center;
  374. white-space: nowrap;
  375. }
  376. }
  377. }
  378. }
  379. }
  380. .bottom-loading{
  381. margin-top: 5rpx;
  382. padding: 10rpx;
  383. }
  384. }
  385. .ad-video {
  386. margin-top: 40rpx;
  387. }
  388. </style>