//国家接口
const getNation = (() => {
getCountry(store.state.diag_token || store.state.diag_h5token)
.then((res: any) => {
console.log('----------------------201', res)
const len = res.length;
//使用filter过滤接口返回的国家列表res,对res进行过滤
//返回id不等于146,119,63的国家数据列表
const filterCountry = res.filter((item:any) => ![146,119,63].includes(item.id) )
console.log('--------------------------206',filterCountry)
if (len % 10 !== 0) {
diagnoseInfo.page = Math.floor(len / 10 + 1);
} else {
diagnoseInfo.page = len / 10;
}
if (res && diagnoseInfo.showFirst) {
for (let j = 0; j <= 19; j++) {
diagnoseInfo.countryList.push(res[diagnoseInfo.counter]);
diagnoseInfo.counter++;
}
setTimeout(() => {
diagnoseInfo.showFirst = false;
}, 500)
}
if (loadingN.value && !diagnoseInfo.showFirst) {
setTimeout(() => {
// for (let i = 0; i < diagnoseInfo.page; i++) {
if (len >= diagnoseInfo.counter + 20) {
for (let j = 0; j <= 19; j++) {
diagnoseInfo.countryList.push(res[diagnoseInfo.counter]);
if (diagnoseInfo.counter >= len - 1) {
// 数据全部加载完成
loadingN.value = false;
finished.value = true;
return
}
diagnoseInfo.counter++;
}
} else {
const aa = len - diagnoseInfo.counter;
if (aa > 0) {
for (let i = 1; i <= aa; i++) {
if (diagnoseInfo.counter >= len) {
finished.value = true;
// 加载状态结束
loading.value = false;
return
}
diagnoseInfo.countryList.push(res[diagnoseInfo.counter]);
diagnoseInfo.counter++;
}
} else {
finished.value = true;
// 加载状态结束
loadingN.value = false;
return
}
}
// 加载状态结束
loadingN.value = false;
}, 1000);
}
})
.finally(() => {
loadingN.value = false;
})
})