|
@@ -1,5 +1,5 @@
|
|
<template>
|
|
<template>
|
|
- <view style="background-color: #f7f7f5;overflow: hidden;">
|
|
|
|
|
|
+ <view id="home" style="background-color: #f7f7f5;overflow: hidden;">
|
|
<view class="top-bg"></view>
|
|
<view class="top-bg"></view>
|
|
<view class="section carousel-wrapper">
|
|
<view class="section carousel-wrapper">
|
|
<swiper class="carousel" :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" circular>
|
|
<swiper class="carousel" :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" circular>
|
|
@@ -22,10 +22,10 @@
|
|
</view>
|
|
</view>
|
|
<view class="hot-rank">
|
|
<view class="hot-rank">
|
|
<scroll-view scroll-x="true" :show-scrollbar="false" :enable-flex="true" style="white-space: nowrap;">
|
|
<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>
|
|
</scroll-view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
@@ -36,10 +36,10 @@
|
|
</view>
|
|
</view>
|
|
<view class="new-rank">
|
|
<view class="new-rank">
|
|
<scroll-view scroll-x="true" :show-scrollbar="false" :enable-flex="true" style="white-space: nowrap;">
|
|
<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>
|
|
</scroll-view>
|
|
</view>
|
|
</view>
|
|
|
|
|
|
@@ -49,10 +49,10 @@
|
|
<image src="../../static/images/like.png" mode="scaleToFill" style="height: 28rpx;width: 363rpx;"></image>
|
|
<image src="../../static/images/like.png" mode="scaleToFill" style="height: 28rpx;width: 363rpx;"></image>
|
|
</view>
|
|
</view>
|
|
<view class="like">
|
|
<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>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
@@ -62,23 +62,28 @@
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- title: 'Hello',
|
|
|
|
|
|
+ rankProducts: [],
|
|
|
|
+ newProducts: [],
|
|
|
|
+ likeProducts: [],
|
|
|
|
+ page: 1,
|
|
|
|
+ pageLoading: false
|
|
}
|
|
}
|
|
},
|
|
},
|
|
components: {},
|
|
components: {},
|
|
onLoad() {
|
|
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) {
|
|
onNavigationBarButtonTap(e) {
|
|
// console.log(e)
|
|
// console.log(e)
|
|
@@ -92,7 +97,48 @@
|
|
break;
|
|
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>
|
|
</script>
|
|
|
|
|