![]()
0) {
diff --git a/src/views/mobile/Market.vue b/src/views/mobile/Market.vue
index b748673..f88dd61 100644
--- a/src/views/mobile/Market.vue
+++ b/src/views/mobile/Market.vue
@@ -39,10 +39,30 @@
@handSortSelect="handSortSelect"
>
@@ -79,7 +99,7 @@ export default {
hero: "",
isType: "market",
nftList: [],
- currencyTypeList:[],
+ currencyTypeList: [],
debounce: null,
priceFilter: "0|999999990000000000000000",
priceMin: 0,
@@ -95,7 +115,9 @@ export default {
durabilityFilter: null,
orderMethod: 0,
starts: 0,
+ isShow:false,
currentPage: 1,
+ loadingInstance: null,
types: [
{ id: 1, name: "HERO" },
{ id: 2, name: "WEAPON" },
@@ -446,6 +468,7 @@ export default {
methods: {
onClickItem(s) {
this.nftType = s.id;
+ this.nftList=[]
this.getMarketNftList();
},
handSortSelect(value) {
@@ -564,38 +587,92 @@ export default {
if (!AppModule.accountId) {
return;
}
+ try {
+ const reqData = {
+ page_size: this.pageSize,
+ start: this.starts,
+ type: this.nftType == 4 ? 5 : this.nftType,
+ job_filters: this.nftType == 2 ? null : this.jobFilters,
+ search_filters: this.searchFilters,
+ quality_filter: this.qualityFilter,
+ durability_filter: this.durabilityFilter,
+ lv_filter: this.lvFilter,
+ order_asc: this.orderAsc,
+ order_method: this.orderMethod,
+ price_filter: this.priceFilter,
+ };
+ this.showLoading();
+ const res = await queryMarketNftList(reqData);
- const reqData = {
- page_size: this.pageSize,
- start: this.starts,
- type: this.nftType == 4 ? 5 : this.nftType,
- job_filters: this.nftType == 2 ? null : this.jobFilters,
- search_filters: this.searchFilters,
- quality_filter: this.qualityFilter,
- durability_filter: this.durabilityFilter,
- lv_filter: this.lvFilter,
- order_asc: this.orderAsc,
- order_method: this.orderMethod,
- price_filter: this.priceFilter,
- };
-
- const res = await queryMarketNftList(reqData);
- if (res.nfts) {
- let list = res.nfts;
- this.nftList = list.filter((item) => {
- return item.details !== null;
- });
- if (res) {
+ if (res.nfts) {
+ this.nftList = res.nfts;
const page = res;
this.totalPage = page.total || 1;
- console.log(this.totalPage, "this.totalPage");
this.pageSize = page.page_size || 10;
- this.starts = page.start;
- this.currentPage = page.start / page.page_size + 1;
+ this.hideLoading();
}
+ } catch (err) {
+ this.hideLoading();
}
},
+ async listenBottomOut() {
+ const scrollTop =
+ document.documentElement.scrollTop || document.body.scrollTop;
+ const clientHeight = document.documentElement.clientHeight;
+ const scrollHeight = document.documentElement.scrollHeight;
+ console.log();
+ if (scrollTop + clientHeight >= scrollHeight) {
+ // 没有数据后,不触发请求
+ if (!this.isShow && this.starts < this.totalPage) {
+ // debugger
+ this.showLoading();
+ this.starts += 10;
+ const reqData = {
+ page_size: this.pageSize,
+ start: this.starts,
+ type: this.nftType == 4 ? 5 : this.nftType,
+ job_filters: this.nftType == 2 ? null : this.jobFilters,
+ search_filters: this.searchFilters,
+ quality_filter: this.qualityFilter,
+ durability_filter: this.durabilityFilter,
+ lv_filter: this.lvFilter,
+ order_asc: this.orderAsc,
+ order_method: this.orderMethod,
+ price_filter: this.priceFilter,
+ };
+ const res = await queryMarketNftList(reqData);
+ if (res.nfts) {
+
+ this.nftList = [...this.nftList,...res.nfts];
+ const page = res;
+ this.totalPage = page.total || 1;
+ this.pageSize = page.page_size || 10;
+ this.hideLoading();
+ // this.isShow = false;
+ }
+
+ console.log("this.getMyNftList();");
+ }
+ return;
+ }
+ },
+ showLoading() {
+ this.loadingInstance = this.$loading({
+ background: "rgba(0, 0, 0, 0.8)",
+ });
+ },
+ hideLoading() {
+ this.loadingInstance?.close();
+ },
},
+ mounted () {
+ // 事件监听
+ window.addEventListener('scroll', this.listenBottomOut)
+ },
+ destroyed () {
+ // 离开页面取消监听
+ window.removeEventListener('scroll', this.listenBottomOut, false)
+ }
};
diff --git a/src/views/mobile/MyNft.vue b/src/views/mobile/MyNft.vue
index 08ca125..b85b2eb 100644
--- a/src/views/mobile/MyNft.vue
+++ b/src/views/mobile/MyNft.vue
@@ -34,38 +34,30 @@
@handSortSelect="handSortSelect"
>
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
@@ -101,6 +93,7 @@ export default {
return {
nftType: 1,
hero: "",
+
isType: "mynft",
nftList: [],
isFiters: false,
@@ -113,8 +106,10 @@ export default {
qualityFilter: 1,
durabilityFilter: null,
orderMethod: 0,
+ isShow: false,
starts: 0,
currentPage: 1,
+ loadingInstance: null,
types: [
{ id: 1, name: "HERO" },
{ id: 2, name: "WEAPON" },
@@ -455,7 +450,7 @@ export default {
isLogin() {
if (this.isLogin) {
this.getMyNftList();
- this.getCurrencyType()
+ this.getCurrencyType();
}
},
},
@@ -467,6 +462,8 @@ export default {
methods: {
onClickItem(s) {
this.nftType = s.id;
+ this.nftList = [];
+ this.starts = 0;
this.getMyNftList();
},
handSortSelect(value) {
@@ -592,35 +589,103 @@ export default {
if (!AppModule.accountId) {
return;
}
- const reqData = {
- page_size: this.pageSize,
- start: this.starts,
- type: this.nftType == 4 ? 5 : this.nftType,
- job_filters: this.jobFilters,
- search_filters: this.searchFilters,
- quality_filter: this.qualityFilter,
- durability_filter: this.durabilityFilter,
- lv_filter: this.lvFilter,
- order_asc: this.orderAsc,
- order_method: this.orderMethod,
- };
+ try {
+ this.showLoading();
+ const reqData = {
+ page_size: this.pageSize,
+ start: this.starts,
+ type: this.nftType == 4 ? 5 : this.nftType,
+ job_filters: this.jobFilters,
+ search_filters: this.searchFilters,
+ quality_filter: this.qualityFilter,
+ durability_filter: this.durabilityFilter,
+ lv_filter: this.lvFilter,
+ order_asc: this.orderAsc,
+ order_method: this.orderMethod,
+ };
- const res = await queryMyNftList(reqData);
- if (res.nfts) {
- let list = res.nfts;
- this.nftList = list.filter((item) => {
- return item.details !== null;
- });
- if (res) {
+ const res = await queryMyNftList(reqData);
+ if (res.nfts) {
+
+ this.nftList = res.nfts;
const page = res;
this.totalPage = page.total || 1;
- // console.log(this.totalPage, "this.totalPage");
this.pageSize = page.page_size || 10;
- this.starts = page.start;
- this.currentPage = page.start / page.page_size + 1;
+ this.hideLoading();
+ // this.isShow = false;
}
+ } catch (err) {
+ this.hideLoading();
+ this.nftList = [];
+ this.totalPage = 0;
}
},
+ // 触底触发函数
+ async listenBottomOut() {
+ const scrollTop =
+ document.documentElement.scrollTop || document.body.scrollTop;
+ const clientHeight = document.documentElement.clientHeight;
+ const scrollHeight = document.documentElement.scrollHeight;
+ console.log();
+ if (scrollTop + clientHeight >= scrollHeight) {
+ // 没有数据后,不触发请求
+ if (!this.isShow && this.starts < this.totalPage) {
+ // debugger
+ this.showLoading();
+ this.starts += 10;
+ const reqData = {
+ page_size: this.pageSize,
+ start: this.starts,
+ type: this.nftType == 4 ? 5 : this.nftType,
+ job_filters: this.jobFilters,
+ search_filters: this.searchFilters,
+ quality_filter: this.qualityFilter,
+ durability_filter: this.durabilityFilter,
+ lv_filter: this.lvFilter,
+ order_asc: this.orderAsc,
+ order_method: this.orderMethod,
+ };
+ const res = await queryMyNftList(reqData);
+ if (res.nfts) {
+
+ this.nftList = [...this.nftList,...res.nfts];
+ const page = res;
+ this.totalPage = page.total || 1;
+ this.pageSize = page.page_size || 10;
+ this.hideLoading();
+ // this.isShow = false;
+ }
+
+ console.log("this.getMyNftList();");
+ }
+ return;
+ }
+ },
+ showLoading() {
+ this.loadingInstance = this.$loading({
+ background: "rgba(0, 0, 0, 0.8)",
+ });
+ },
+ hideLoading() {
+ this.loadingInstance?.close();
+ },
+ },
+
+ mounted() {
+ // 事件监听
+ window.addEventListener("scroll", this.listenBottomOut);
+ let windowHeight =
+ document.documentElement.clientHeight || document.body.clientHeight; //变量windowHeight是 可视区的高度
+ let scrollHeight =
+ document.documentElement.scrollHeight || document.body.scrollHeight; //变量scrollHeight是 滚动条的总高度 /可视化的高度与溢出的距离(总高度)
+
+ if (windowHeight < scrollHeight) {
+ this.isShow = false;
+ }
+ },
+ destroyed() {
+ // 离开页面取消监听
+ window.removeEventListener("scroll", this.listenBottomOut, false);
},
};