|
|
@@ -10,12 +10,12 @@
|
|
|
<van-tab :title="$t('lang216')" disabled></van-tab>
|
|
|
<van-tab :title="$t('lang246')"></van-tab>
|
|
|
</van-tabs>
|
|
|
- <div class="home_page" @scroll="handleScroll">
|
|
|
+ <div class="home_page">
|
|
|
<div class="pd1">
|
|
|
<div class="btn_box">
|
|
|
<van-button v-for="(item, index) in typeList" :key="index" :class="[typeIndex == index ? 'cc_btn cc_active' : 'cc_btn']" @click="changeType(item, index)"> {{ item.title }}</van-button>
|
|
|
</div>
|
|
|
- <van-field v-model="key" :placeholder="$t('lang4')" class="input" right-icon="search" @click-right-icon="search" />
|
|
|
+ <van-field v-model="key" :placeholder="$t('lang496')" class="input" right-icon="search" @click-right-icon="search" />
|
|
|
|
|
|
<div class="sort flex jsb">
|
|
|
<span class="w1">{{ $t('lang244') }}</span>
|
|
|
@@ -52,7 +52,10 @@
|
|
|
<!-- </div> -->
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="goods_box" v-if="list.length > 0">
|
|
|
+ <div class="bare" v-if="total < 1">
|
|
|
+ <span>{{ $t('lang60') }}</span>
|
|
|
+ </div>
|
|
|
+ <van-list class="goods_box" v-model="loading" :finished="finished" :finished-text="$t('lang202')" @load="onLoad" v-else>
|
|
|
<div class="goods_list jsb" v-for="(item, index) in list" :key="index" @click="navigatorToPage('typeDetail', item.product_id)">
|
|
|
<div class="info">
|
|
|
<van-image class="goods_list_img" radius="10" :src="item.img_url" />
|
|
|
@@ -88,10 +91,8 @@
|
|
|
<span class="fw">88</span>
|
|
|
</div> -->
|
|
|
</div>
|
|
|
- </div>
|
|
|
- <div class="bare" v-else>
|
|
|
- <span>{{ $t('lang60') }}</span>
|
|
|
- </div>
|
|
|
+ </van-list>
|
|
|
+
|
|
|
</div>
|
|
|
<BottomNavigation></BottomNavigation>
|
|
|
</div>
|
|
|
@@ -112,26 +113,35 @@ export default {
|
|
|
volume: 0,
|
|
|
type_id: 0,
|
|
|
list: [],
|
|
|
- page: 1,
|
|
|
+ page: 0,
|
|
|
navActive: 0,
|
|
|
typeList: [],
|
|
|
typeIndex: 0,
|
|
|
starValue: 0,
|
|
|
+ total: 1,
|
|
|
+ loading: false,
|
|
|
+ finished: false,
|
|
|
};
|
|
|
},
|
|
|
|
|
|
mounted() {
|
|
|
- this.init();
|
|
|
+ this.getPopularType();
|
|
|
+ this.onLoad();
|
|
|
},
|
|
|
methods: {
|
|
|
+ onLoad() {
|
|
|
+ console.log('onLoad');
|
|
|
+ this.page += 1;
|
|
|
+ if (this.navActive == 0) {
|
|
|
+ this.getTransferList(); // 触发加载更多
|
|
|
+ } else if (this.navActive == 2) {
|
|
|
+ this.getTransferCollectList();
|
|
|
+ }
|
|
|
+ },
|
|
|
//返回上一页
|
|
|
back() {
|
|
|
this.$router.back();
|
|
|
},
|
|
|
- init() {
|
|
|
- this.getPopularType();
|
|
|
- this.getTransferList();
|
|
|
- },
|
|
|
|
|
|
handleScroll(event) {
|
|
|
const container = event.target;
|
|
|
@@ -152,14 +162,11 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
search() {
|
|
|
- this.page = 1;
|
|
|
+ this.total = 1
|
|
|
+ this.page = 0;
|
|
|
this.list = []; // 重置列表数据
|
|
|
// this.getTransferList(); // 触发重新获取列表数据
|
|
|
- if (this.navActive == 0) {
|
|
|
- this.getTransferList();
|
|
|
- } else if (this.navActive == 2) {
|
|
|
- this.getTransferCollectList();
|
|
|
- }
|
|
|
+ this.onLoad();
|
|
|
},
|
|
|
getPopularType() {
|
|
|
homeApi.getPopularType({}).then(res => {
|
|
|
@@ -170,32 +177,82 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
getTransferList() {
|
|
|
+ this.loading = true;
|
|
|
+ this.finished = false;
|
|
|
homeApi.getTransferList({ sort: this.sort, type_id: this.type_id, key_val: this.key, page: this.page }).then(res => {
|
|
|
+ // if (res.code == 200) {
|
|
|
+ // if (this.list.length >= res.data.total) {
|
|
|
+ // this.page = -1; // 重置为 -1,表示没有更多数据
|
|
|
+ // } else {
|
|
|
+ // this.list = [...this.list, ...res.data.data];
|
|
|
+ // if (this.list.length >= res.data.total) {
|
|
|
+ // this.page = -1; // 重置为 -1,表示没有更多数据
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // }
|
|
|
if (res.code == 200) {
|
|
|
- if (this.list.length >= res.data.total) {
|
|
|
- this.page = -1; // 重置为 -1,表示没有更多数据
|
|
|
- } else {
|
|
|
- this.list = [...this.list, ...res.data.data];
|
|
|
- if (this.list.length >= res.data.total) {
|
|
|
- this.page = -1; // 重置为 -1,表示没有更多数据
|
|
|
- }
|
|
|
+ let rows = res.data.data;
|
|
|
+ // 如果返回的数组是空或数组长度是0
|
|
|
+ if (rows == null || rows.length === 0) {
|
|
|
+ this.loading = false; // 关闭加载状态
|
|
|
+ this.finished = true; // 加载结束
|
|
|
+ this.total = 0
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.loading = false; // 关闭加载状态
|
|
|
+ this.total = res.data.total; //数据总条数
|
|
|
+ this.list = this.list.concat(rows); //合并数组
|
|
|
+ console.log(this.list);
|
|
|
+
|
|
|
+ // 如果合并之后的数组长度大于返回的数据总条数
|
|
|
+ if (this.list.length >= this.total) {
|
|
|
+ this.finished = true; // 加载结束
|
|
|
}
|
|
|
} else {
|
|
|
+ this.total = 0;
|
|
|
+ this.loading = false; // 关闭加载状态
|
|
|
+ this.finished = true; // 加载结束
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
getTransferCollectList() {
|
|
|
+ this.loading = true;
|
|
|
+ this.finished = false;
|
|
|
homeApi.getTransferCollectList({ sort: this.sort, type_id: this.type_id, key_val: this.key, page: this.page }).then(res => {
|
|
|
+ // if (res.code == 200) {
|
|
|
+ // if (this.list.length >= res.data.total) {
|
|
|
+ // this.page = -1; // 重置为 -1,表示没有更多数据
|
|
|
+ // } else {
|
|
|
+ // this.list = [...this.list, ...res.data.data];
|
|
|
+ // if (this.list.length >= res.data.total) {
|
|
|
+ // this.page = -1; // 重置为 -1,表示没有更多数据
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // }
|
|
|
if (res.code == 200) {
|
|
|
- if (this.list.length >= res.data.total) {
|
|
|
- this.page = -1; // 重置为 -1,表示没有更多数据
|
|
|
- } else {
|
|
|
- this.list = [...this.list, ...res.data.data];
|
|
|
- if (this.list.length >= res.data.total) {
|
|
|
- this.page = -1; // 重置为 -1,表示没有更多数据
|
|
|
- }
|
|
|
+ let rows = res.data.data;
|
|
|
+ // 如果返回的数组是空或数组长度是0
|
|
|
+ if (rows == null || rows.length === 0) {
|
|
|
+ this.loading = false; // 关闭加载状态
|
|
|
+ this.finished = true; // 加载结束
|
|
|
+ this.total = 0
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.loading = false; // 关闭加载状态
|
|
|
+ this.total = res.data.total; //数据总条数
|
|
|
+ this.list = this.list.concat(rows); //合并数组
|
|
|
+ console.log(this.list);
|
|
|
+
|
|
|
+ // 如果合并之后的数组长度大于返回的数据总条数
|
|
|
+ if (this.list.length >= this.total) {
|
|
|
+ this.finished = true; // 加载结束
|
|
|
}
|
|
|
} else {
|
|
|
+ this.total = 0;
|
|
|
+ this.loading = false; // 关闭加载状态
|
|
|
+ this.finished = true; // 加载结束
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
@@ -251,23 +308,15 @@ export default {
|
|
|
changeType(item, index) {
|
|
|
this.typeIndex = index;
|
|
|
this.type_id = item.id;
|
|
|
- this.page = 1;
|
|
|
+ this.page = 0;
|
|
|
this.list = [];
|
|
|
- if (this.navActive == 0) {
|
|
|
- this.getTransferList();
|
|
|
- } else if (this.navActive == 2) {
|
|
|
- this.getTransferCollectList();
|
|
|
- }
|
|
|
+ this.search();
|
|
|
},
|
|
|
changeTab(item) {
|
|
|
console.log(item);
|
|
|
- this.page = 1;
|
|
|
+ this.page = 0;
|
|
|
this.list = [];
|
|
|
- if (item == 0) {
|
|
|
- this.getTransferList();
|
|
|
- } else if (item == 2) {
|
|
|
- this.getTransferCollectList();
|
|
|
- }
|
|
|
+ this.search();
|
|
|
},
|
|
|
},
|
|
|
computed: {
|