Commit afbbc324 authored by chenqikuai's avatar chenqikuai

fix: 修复交易列表页面,点击其他页数后,再点击首页,页面不会自动查询数据的问题

parent 33c0a4e8
...@@ -3,8 +3,14 @@ import { message } from "ant-design-vue"; ...@@ -3,8 +3,14 @@ import { message } from "ant-design-vue";
import { getRpc } from "ycc-api/dist/cmjs/service/Rpc"; import { getRpc } from "ycc-api/dist/cmjs/service/Rpc";
import { iBlockInBlockMixin, iGetBlocksRetResultItem } from "@/types/block"; import { iBlockInBlockMixin, iGetBlocksRetResultItem } from "@/types/block";
import { yccApi } from "@/service/api"; import { yccApi } from "@/service/api";
import {
clearTimeoutFromTimerObj,
registerTimeoutToTimerObj,
} from "@/utils/common";
const Rpc = getRpc(yccApi); const Rpc = getRpc(yccApi);
const TimerObj = {} as any;
export default Vue.extend({ export default Vue.extend({
data() { data() {
return { return {
...@@ -13,7 +19,6 @@ export default Vue.extend({ ...@@ -13,7 +19,6 @@ export default Vue.extend({
startHeight: 0, startHeight: 0,
endHeight: 0, endHeight: 0,
Loading: false, Loading: false,
Timer: 0,
pages: { pages: {
currentPage: 1, currentPage: 1,
pageSize: 20, pageSize: 20,
...@@ -48,7 +53,7 @@ export default Vue.extend({ ...@@ -48,7 +53,7 @@ export default Vue.extend({
}); });
}, },
pageChange(page: number) { pageChange(page: number) {
clearTimeout(this.Timer); clearTimeoutFromTimerObj(TimerObj);
this.pages.currentPage = page; this.pages.currentPage = page;
const newHeight = const newHeight =
this.maxHeight - (this.pages.currentPage - 1) * this.pages.pageSize; this.maxHeight - (this.pages.currentPage - 1) * this.pages.pageSize;
...@@ -102,14 +107,11 @@ export default Vue.extend({ ...@@ -102,14 +107,11 @@ export default Vue.extend({
watch: { watch: {
Loading(val) { Loading(val) {
if (val === false && this.pages.currentPage === 1) { if (val === false && this.pages.currentPage === 1) {
this.Timer = window.setTimeout(() => { registerTimeoutToTimerObj(TimerObj, this.getLastBlock, 10 * 1e3);
this.getLastBlock();
}, 15000);
} }
}, },
}, },
beforeDestroy() { beforeDestroy() {
//清除定时器 clearTimeoutFromTimerObj(TimerObj);
clearTimeout(this.Timer);
}, },
}); });
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/no-explicit-any */
import { getTxCount, getTxList } from "@/service/api"; import { getTxCount, getTxList } from "@/service/api";
import { filterNum } from "@/utils/utils";
import { icustomized2Tx } from "@/types/trade"; import { icustomized2Tx } from "@/types/trade";
import Vue from "vue"; import Vue from "vue";
export default Vue.extend({ export default Vue.extend({
...@@ -21,6 +22,7 @@ export default Vue.extend({ ...@@ -21,6 +22,7 @@ export default Vue.extend({
this.init(); this.init();
}, },
methods: { methods: {
filterNum,
checkGroup(arr: icustomized2Tx[]) { checkGroup(arr: icustomized2Tx[]) {
arr.map((current, index) => { arr.map((current, index) => {
if (current.group_count > 1) { if (current.group_count > 1) {
...@@ -69,7 +71,7 @@ export default Vue.extend({ ...@@ -69,7 +71,7 @@ export default Vue.extend({
if (this.pages.currentPage === 1) { if (this.pages.currentPage === 1) {
this.Timer = window.setTimeout(() => { this.Timer = window.setTimeout(() => {
this.init(); this.init();
}, 15 * 1e3); }, 10 * 1e3);
} }
} }
}); });
...@@ -79,12 +81,19 @@ export default Vue.extend({ ...@@ -79,12 +81,19 @@ export default Vue.extend({
pageChange(page: number) { pageChange(page: number) {
this.pages.currentPage = page; this.pages.currentPage = page;
this.loading = true; this.loading = true;
window.clearTimeout(this.Timer);
getTxList(this.pages.currentPage, this.pages.pageSize).then((ret) => { getTxList(this.pages.currentPage, this.pages.pageSize).then((ret) => {
if (!ret.error) { if (!ret.error) {
this.txList = this.checkGroup(ret.result); this.txList = this.checkGroup(ret.result);
this.loading = false; this.loading = false;
if (this.pages.currentPage === 1) {
this.Timer = window.setTimeout(() => {
this.init();
}, 10 * 1e3);
}
} }
}); });
}, },
sizeChange(size: number) { sizeChange(size: number) {
this.pages.pageSize = size; this.pages.pageSize = size;
......
export const checkIsMobile = function () { export const checkIsMobile = function() {
const flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i) const flag = navigator.userAgent.match(
/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
);
const width = document.documentElement.clientWidth; const width = document.documentElement.clientWidth;
return !!(flag || width <= 500) return !!(flag || width <= 500);
};
export function filterNum(num: number | string) {
const str = num.toString();
const reg =
str.indexOf(".") > -1 ? /(\d)(?=(\d{3})+\.)/g : /(\d)(?=(?:\d{3})+$)/g;
return str.replace(reg, "$1,");
} }
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
'border-bottom-left-radius': '2px', 'border-bottom-left-radius': '2px',
'border-bottom-right-radius': '2px', 'border-bottom-right-radius': '2px',
}" }"
:title="`${$t('lang.trade.title')}(${total}${$t( :title="`${$t('lang.trade.title')}(${filterNum(total)}${$t(
'lang.trade.count', 'lang.trade.count',
)}) (${$t('lang.trade.tip')})`" )}) (${$t('lang.trade.tip')})`"
></m-title> ></m-title>
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
class="total-block float-left flex items-center" class="total-block float-left flex items-center"
style="height: 32px;" style="height: 32px;"
> >
{{ $t('lang.trade.title') }}{{ total {{ $t('lang.trade.title') }}{{ filterNum(total)
}}{{ $t('lang.trade.count') }} }}{{ $t('lang.trade.count') }}
<span v-if="pages.total >= 100000"> <span v-if="pages.total >= 100000">
( (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment