|
@@ -1,38 +1,49 @@
|
|
|
<template>
|
|
|
- <view class="container">
|
|
|
- <view class="jg"></view>
|
|
|
- <view class="good-wrapper flex" v-for="(good ,index) in list" :key="good.id">
|
|
|
- <image :src="good.image" mode="" class="good-img"></image>
|
|
|
- <view class="good-info flex">
|
|
|
- <view class="tit clamp2">
|
|
|
- {{good.store_name }}
|
|
|
- </view>
|
|
|
- <view class="price-wrap">
|
|
|
- <view class="old-price">
|
|
|
- <text class="old">¥{{good.ot_price}}</text>
|
|
|
- <template v-if="good.ot_price - good.price > 0">
|
|
|
- <image src="../../static/icon/down.png" mode=""></image>
|
|
|
- <text class="zj">直降{{good.ot_price - good.use_max_integral}}元</text>
|
|
|
- </template>
|
|
|
- </view>
|
|
|
- <view class="integral-wrap">
|
|
|
- <image src="../../static/icon/jf.png" mode=""></image>
|
|
|
- <text class="price">{{good.price}}</text>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <view class="btn" @click="nav(good.id)">
|
|
|
- 立即购买
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- </view>
|
|
|
- <view class="jg"></view>
|
|
|
+ <view class="container">
|
|
|
+ <empty v-if="loaded === true && list.length === 0"></empty>
|
|
|
+ <template>
|
|
|
+ <view class="jg"></view>
|
|
|
+ <view class="good-wrapper flex" v-for="(good ,index) in list" :key="good.id">
|
|
|
+ <image :src="good.image" mode="" class="good-img"></image>
|
|
|
+ <view class="good-info flex">
|
|
|
+ <view class="tit clamp2">
|
|
|
+ {{good.store_name }}
|
|
|
+ </view>
|
|
|
+ <view class="price-wrap">
|
|
|
+ <view class="old-price">
|
|
|
+ <text class="old">¥{{good.ot_price}}</text>
|
|
|
+ <template v-if="good.ot_price - good.price > 0">
|
|
|
+ <!-- <image src="../../static/icon/down.png" mode=""></image> -->
|
|
|
+ <!-- <text class="zj">直降{{good.ot_price - good.use_max_integral}}元</text> -->
|
|
|
+ </template>
|
|
|
+ </view>
|
|
|
+ <view class="integral-wrap">
|
|
|
+ <image src="../../static/icon/jf.png" mode=""></image>
|
|
|
+ <text class="price">{{good.price}}</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="btn" @click="nav(good.id)">
|
|
|
+ 立即购买
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view class="jg"></view>
|
|
|
+ <uni-load-more :status="loadingType"></uni-load-more>
|
|
|
+ </template>
|
|
|
</view>
|
|
|
-
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { groomList } from '@/api/product.js';
|
|
|
-export default {
|
|
|
+import { groomList, getProducts } from '@/api/product.js';
|
|
|
+
|
|
|
+import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
|
|
|
+import empty from '@/components/empty';
|
|
|
+
|
|
|
+export default {
|
|
|
+ components: {
|
|
|
+ uniLoadMore,
|
|
|
+ empty
|
|
|
+ },
|
|
|
filters: {
|
|
|
toFixed: function(value) {
|
|
|
// 判断是否为整数
|
|
@@ -46,7 +57,10 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
list: [],
|
|
|
- bannerImg: []
|
|
|
+ page: 1,
|
|
|
+ limit: 10,
|
|
|
+ loadingType: 'more',
|
|
|
+ loaded: false,
|
|
|
};
|
|
|
},
|
|
|
onLoad(option) {
|
|
@@ -73,17 +87,32 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
// 请求载入数据
|
|
|
- async loadData() {
|
|
|
- groomList({}, 5)
|
|
|
- .then(({ data }) => {
|
|
|
- // 保存轮播图
|
|
|
- this.bannerImg = data.banner;
|
|
|
+ loadData() {
|
|
|
+ let obj = this
|
|
|
+ if(obj.loadingType == 'noMore' || obj.loadingType == 'loading') {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ obj.loadingType = 'loading'
|
|
|
+ getProducts({
|
|
|
+ page:obj.page,
|
|
|
+ limit: obj.limit,
|
|
|
+ is_consumer: 1,
|
|
|
+ })
|
|
|
+ .then(({ data }) => {
|
|
|
+ console.log(data)
|
|
|
// 保存商品信息
|
|
|
- this.list = data.list.map(e => {
|
|
|
+ obj.list = data.map(e => {
|
|
|
e.price = Number(e.price);
|
|
|
e.ot_price = Number(e.ot_price);
|
|
|
return e;
|
|
|
- });
|
|
|
+ });
|
|
|
+ obj.page++
|
|
|
+ if(obj.limit == data.length) {
|
|
|
+ obj.loadingType = 'more'
|
|
|
+ }else {
|
|
|
+ obj.loadingType = 'noMore'
|
|
|
+ }
|
|
|
+ obj.loaded = true
|
|
|
})
|
|
|
.catch(e => {
|
|
|
console.log(e);
|