|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <view style="background-color: #f7f7f5;overflow: hidden;">
|
|
|
+ <view id="home" style="background-color: #f7f7f5;overflow: hidden;">
|
|
|
<view class="top-bg"></view>
|
|
|
<view class="section carousel-wrapper">
|
|
|
<swiper class="carousel" :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" circular>
|
|
@@ -22,10 +22,10 @@
|
|
|
</view>
|
|
|
<view class="hot-rank">
|
|
|
<scroll-view scroll-x="true" :show-scrollbar="false" :enable-flex="true" style="white-space: nowrap;">
|
|
|
- <product-item type="swiper" image="https://img.alicdn.com/imgextra/i3/2930255252/O1CN0159ouF21ofSiQ3kPq2_!!2930255252.jpg"></product-item>
|
|
|
- <product-item type="swiper" image="https://img.alicdn.com/imgextra/i3/2930255252/O1CN0159ouF21ofSiQ3kPq2_!!2930255252.jpg"></product-item>
|
|
|
- <product-item type="swiper" image="https://img.alicdn.com/imgextra/i3/2930255252/O1CN0159ouF21ofSiQ3kPq2_!!2930255252.jpg"></product-item>
|
|
|
- <product-item type="swiper" image="https://img.alicdn.com/imgextra/i3/2930255252/O1CN0159ouF21ofSiQ3kPq2_!!2930255252.jpg"></product-item>
|
|
|
+ <template v-for="product in rankProducts">
|
|
|
+ <product-item type="swiper" :image="product.images|imagesFilter" :title="product.name" :org-price="product.org_price"
|
|
|
+ :price="product.price"></product-item>
|
|
|
+ </template>
|
|
|
</scroll-view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -36,10 +36,10 @@
|
|
|
</view>
|
|
|
<view class="new-rank">
|
|
|
<scroll-view scroll-x="true" :show-scrollbar="false" :enable-flex="true" style="white-space: nowrap;">
|
|
|
- <product-item type="swiper" image="https://img.alicdn.com/imgextra/i3/2930255252/O1CN0159ouF21ofSiQ3kPq2_!!2930255252.jpg"></product-item>
|
|
|
- <product-item type="swiper" image="https://img.alicdn.com/imgextra/i3/2930255252/O1CN0159ouF21ofSiQ3kPq2_!!2930255252.jpg"></product-item>
|
|
|
- <product-item type="swiper" image="https://img.alicdn.com/imgextra/i3/2930255252/O1CN0159ouF21ofSiQ3kPq2_!!2930255252.jpg"></product-item>
|
|
|
- <product-item type="swiper" image="https://img.alicdn.com/imgextra/i3/2930255252/O1CN0159ouF21ofSiQ3kPq2_!!2930255252.jpg"></product-item>
|
|
|
+ <template v-for="product in newProducts">
|
|
|
+ <product-item type="swiper" :image="product.images|imagesFilter" :title="product.name" :org-price="product.org_price"
|
|
|
+ :price="product.price"></product-item>
|
|
|
+ </template>
|
|
|
</scroll-view>
|
|
|
</view>
|
|
|
|
|
@@ -49,10 +49,10 @@
|
|
|
<image src="../../static/images/like.png" mode="scaleToFill" style="height: 28rpx;width: 363rpx;"></image>
|
|
|
</view>
|
|
|
<view class="like">
|
|
|
- <product-item type="list" image="https://img.alicdn.com/imgextra/i3/2930255252/O1CN0159ouF21ofSiQ3kPq2_!!2930255252.jpg"></product-item>
|
|
|
- <product-item type="list" image="https://img.alicdn.com/imgextra/i3/2930255252/O1CN0159ouF21ofSiQ3kPq2_!!2930255252.jpg"></product-item>
|
|
|
- <product-item type="list" image="https://img.alicdn.com/imgextra/i3/2930255252/O1CN0159ouF21ofSiQ3kPq2_!!2930255252.jpg"></product-item>
|
|
|
- <product-item type="list" image="https://img.alicdn.com/imgextra/i3/2930255252/O1CN0159ouF21ofSiQ3kPq2_!!2930255252.jpg"></product-item>
|
|
|
+ <template v-for="product in likeProducts">
|
|
|
+ <product-item type="list" :image="product.images|imagesFilter" :title="product.name" :org-price="product.org_price"
|
|
|
+ :price="product.price"></product-item>
|
|
|
+ </template>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -62,23 +62,28 @@
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- title: 'Hello',
|
|
|
+ rankProducts: [],
|
|
|
+ newProducts: [],
|
|
|
+ likeProducts: [],
|
|
|
+ page: 1,
|
|
|
+ pageLoading: false
|
|
|
}
|
|
|
},
|
|
|
components: {},
|
|
|
onLoad() {
|
|
|
- console.log(this.$http)
|
|
|
+ this.getRankProductData();
|
|
|
+ this.getNewProductData();
|
|
|
+ this.getLikeProductsData();
|
|
|
},
|
|
|
- onShow() {
|
|
|
- this.$http.get({
|
|
|
- url: "/demo/test",
|
|
|
- data: {
|
|
|
- category: 'test'
|
|
|
- },
|
|
|
- success: (res) => {
|
|
|
-
|
|
|
+ onShow() {},
|
|
|
+ onPageScroll(e) {
|
|
|
+ const query = uni.createSelectorQuery();
|
|
|
+ query.select("#home").boundingClientRect(data => {
|
|
|
+ if (e.scrollTop > data.height - uni.getSystemInfoSync().windowHeight * 2) {
|
|
|
+ this.getLikeProductsData();
|
|
|
}
|
|
|
- })
|
|
|
+ }).exec();
|
|
|
+
|
|
|
},
|
|
|
onNavigationBarButtonTap(e) {
|
|
|
// console.log(e)
|
|
@@ -92,7 +97,48 @@
|
|
|
break;
|
|
|
}
|
|
|
},
|
|
|
- methods: {}
|
|
|
+ methods: {
|
|
|
+ getRankProductData() {
|
|
|
+ this.$http.get({
|
|
|
+ url: "/product/rand",
|
|
|
+ data: {
|
|
|
+ limit: 10
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ this.rankProducts = res.data.data
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getNewProductData() {
|
|
|
+ this.$http.get({
|
|
|
+ url: "/product/rand",
|
|
|
+ data: {
|
|
|
+ limit: 10
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ this.newProducts = res.data.data
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getLikeProductsData() {
|
|
|
+ if (!this.pageLoading) {
|
|
|
+ console.log("加载下一页");
|
|
|
+ this.pageLoading = true;
|
|
|
+ this.$http.get({
|
|
|
+ url: "/product/lists",
|
|
|
+ data: {
|
|
|
+ limit: 10,
|
|
|
+ page: this.page,
|
|
|
+ },
|
|
|
+ success: (res) => {
|
|
|
+ this.likeProducts = [...this.likeProducts, ...res.data.data.rows]
|
|
|
+ this.page++;
|
|
|
+ this.pageLoading = false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|