Commit afbbc324 authored by chenqikuai's avatar chenqikuai

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

parent 33c0a4e8
......@@ -3,8 +3,14 @@ import { message } from "ant-design-vue";
import { getRpc } from "ycc-api/dist/cmjs/service/Rpc";
import { iBlockInBlockMixin, iGetBlocksRetResultItem } from "@/types/block";
import { yccApi } from "@/service/api";
import {
clearTimeoutFromTimerObj,
registerTimeoutToTimerObj,
} from "@/utils/common";
const Rpc = getRpc(yccApi);
const TimerObj = {} as any;
export default Vue.extend({
data() {
return {
......@@ -13,7 +19,6 @@ export default Vue.extend({
startHeight: 0,
endHeight: 0,
Loading: false,
Timer: 0,
pages: {
currentPage: 1,
pageSize: 20,
......@@ -48,7 +53,7 @@ export default Vue.extend({
});
},
pageChange(page: number) {
clearTimeout(this.Timer);
clearTimeoutFromTimerObj(TimerObj);
this.pages.currentPage = page;
const newHeight =
this.maxHeight - (this.pages.currentPage - 1) * this.pages.pageSize;
......@@ -102,14 +107,11 @@ export default Vue.extend({
watch: {
Loading(val) {
if (val === false && this.pages.currentPage === 1) {
this.Timer = window.setTimeout(() => {
this.getLastBlock();
}, 15000);
registerTimeoutToTimerObj(TimerObj, this.getLastBlock, 10 * 1e3);
}
},
},
beforeDestroy() {
//清除定时器
clearTimeout(this.Timer);
clearTimeoutFromTimerObj(TimerObj);
},
});
/* eslint-disable @typescript-eslint/no-explicit-any */
import { getTxCount, getTxList } from "@/service/api";
import { filterNum } from "@/utils/utils";
import { icustomized2Tx } from "@/types/trade";
import Vue from "vue";
export default Vue.extend({
......@@ -21,6 +22,7 @@ export default Vue.extend({
this.init();
},
methods: {
filterNum,
checkGroup(arr: icustomized2Tx[]) {
arr.map((current, index) => {
if (current.group_count > 1) {
......@@ -69,7 +71,7 @@ export default Vue.extend({
if (this.pages.currentPage === 1) {
this.Timer = window.setTimeout(() => {
this.init();
}, 15 * 1e3);
}, 10 * 1e3);
}
}
});
......@@ -79,12 +81,19 @@ export default Vue.extend({
pageChange(page: number) {
this.pages.currentPage = page;
this.loading = true;
window.clearTimeout(this.Timer);
getTxList(this.pages.currentPage, this.pages.pageSize).then((ret) => {
if (!ret.error) {
this.txList = this.checkGroup(ret.result);
this.loading = false;
if (this.pages.currentPage === 1) {
this.Timer = window.setTimeout(() => {
this.init();
}, 10 * 1e3);
}
}
});
},
sizeChange(size: number) {
this.pages.pageSize = size;
......
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)
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 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 @@
'border-bottom-left-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',
)}) (${$t('lang.trade.tip')})`"
></m-title>
......
......@@ -15,7 +15,7 @@
class="total-block float-left flex items-center"
style="height: 32px;"
>
{{ $t('lang.trade.title') }}{{ total
{{ $t('lang.trade.title') }}{{ filterNum(total)
}}{{ $t('lang.trade.count') }}
<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