perf: 二维码loading态
This commit is contained in:
BIN
src/assets/img/media-account/icon-default-qrcode.png
Normal file
BIN
src/assets/img/media-account/icon-default-qrcode.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
@ -149,8 +149,7 @@ const openDelete = (item) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleReauthorize = (item) => {
|
const handleReauthorize = (item) => {
|
||||||
// const isUnauthorized = isUnauthorizedStatus(item.status);
|
const isUnauthorized = isUnauthorizedStatus(item.status);
|
||||||
const isUnauthorized = false;
|
|
||||||
if (isUnauthorized) {
|
if (isUnauthorized) {
|
||||||
authorizedAccountModalRef.value?.open(item.id);
|
authorizedAccountModalRef.value?.open(item.id);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -32,7 +32,20 @@
|
|||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<div class="img-box">
|
<div class="img-box">
|
||||||
<img :src="imgUrl" width="160" height="160" />
|
<template v-if="qrCodeLoading">
|
||||||
|
<div class="relative w-160px h-160px">
|
||||||
|
<img :src="icon1" width="160" height="160" />
|
||||||
|
<div class="absolute top-0 left-0 z-2 w-full h-full flex flex-col items-center justify-center">
|
||||||
|
<icon-loading size="24" class="color-#6D4CFE mb-13px" />
|
||||||
|
<span class="s2 !color-#6D4CFE">二维码生成中...</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="absolute top-0 left-0 w-full h-full flex items-center justify-center opacity-80 bg-#fff"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<img v-else :src="qrCodeUrl" width="160" height="160" />
|
||||||
|
|
||||||
<div v-if="isOverdue" class="mask cursor-pointer" @click="getAuthorizedQrCode">
|
<div v-if="isOverdue" class="mask cursor-pointer" @click="getAuthorizedQrCode">
|
||||||
<icon-refresh size="24" class="mb-13px" />
|
<icon-refresh size="24" class="mb-13px" />
|
||||||
<p class="s1">二维码失效</p>
|
<p class="s1">二维码失效</p>
|
||||||
@ -54,6 +67,7 @@
|
|||||||
import { defineExpose, ref } from 'vue';
|
import { defineExpose, ref } from 'vue';
|
||||||
import { getAuthorizedImage, getMediaAccountsAuthorizedStatus } from '@/api/all/propertyMarketing';
|
import { getAuthorizedImage, getMediaAccountsAuthorizedStatus } from '@/api/all/propertyMarketing';
|
||||||
|
|
||||||
|
import icon1 from '@/assets/img/media-account/icon-default-qrcode.png';
|
||||||
import icon2 from '@/assets/img/media-account/icon-feedback-success.png';
|
import icon2 from '@/assets/img/media-account/icon-feedback-success.png';
|
||||||
import icon3 from '@/assets/img/media-account/icon-feedback-fail.png';
|
import icon3 from '@/assets/img/media-account/icon-feedback-fail.png';
|
||||||
|
|
||||||
@ -70,7 +84,8 @@ const isSuccess = ref(false);
|
|||||||
const failReason = ref('');
|
const failReason = ref('');
|
||||||
const progress = ref(0);
|
const progress = ref(0);
|
||||||
const id = ref('');
|
const id = ref('');
|
||||||
const imgUrl = ref('');
|
const qrCodeUrl = ref('');
|
||||||
|
const qrCodeLoading = ref(false);
|
||||||
|
|
||||||
let progressTimer = null;
|
let progressTimer = null;
|
||||||
let overdueTimer = null;
|
let overdueTimer = null;
|
||||||
@ -93,7 +108,8 @@ const resetTaskFields = () => {
|
|||||||
isSuccess.value = false;
|
isSuccess.value = false;
|
||||||
failReason.value = '';
|
failReason.value = '';
|
||||||
progress.value = 0;
|
progress.value = 0;
|
||||||
imgUrl.value = '';
|
qrCodeUrl.value = '';
|
||||||
|
qrCodeLoading.value = false;
|
||||||
};
|
};
|
||||||
const close = () => {
|
const close = () => {
|
||||||
resetTaskFields();
|
resetTaskFields();
|
||||||
@ -105,16 +121,21 @@ const close = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getAuthorizedQrCode = async () => {
|
const getAuthorizedQrCode = async () => {
|
||||||
const { code, data } = await getAuthorizedImage(id.value);
|
try {
|
||||||
if (code === 200) {
|
qrCodeLoading.value = true;
|
||||||
imgUrl.value = data.image;
|
const { code, data } = await getAuthorizedImage(id.value);
|
||||||
overdueTimer = null;
|
if (code === 200) {
|
||||||
isOverdue.value = false;
|
qrCodeUrl.value = data.image;
|
||||||
|
overdueTimer = null;
|
||||||
|
isOverdue.value = false;
|
||||||
|
|
||||||
// 约定:后端限制40s内必须扫码,前端定30s后失效
|
// 约定:后端限制40s内必须扫码,前端定30s后失效
|
||||||
overdueTimer = setTimeout(() => {
|
overdueTimer = setTimeout(() => {
|
||||||
isOverdue.value = true;
|
isOverdue.value = true;
|
||||||
}, OVERDUE_TIME);
|
}, OVERDUE_TIME);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
qrCodeLoading.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -191,8 +212,8 @@ const clearOverdueTimer = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleOk = () => {
|
const handleOk = () => {
|
||||||
if (!imgUrl.value) {
|
if (!qrCodeUrl.value) {
|
||||||
AMessage.error('二维码获取中,请稍等');
|
AMessage.error('二维码生成中,请稍等');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,20 @@
|
|||||||
</template> -->
|
</template> -->
|
||||||
<!-- <template v-else> -->
|
<!-- <template v-else> -->
|
||||||
<div class="img-box">
|
<div class="img-box">
|
||||||
<img :src="imgUrl" width="160" height="160" />
|
<template v-if="qrCodeLoading">
|
||||||
|
<div class="relative w-160px h-160px">
|
||||||
|
<img :src="icon1" width="160" height="160" />
|
||||||
|
<div class="absolute top-0 left-0 z-2 w-full h-full flex flex-col items-center justify-center">
|
||||||
|
<icon-loading size="24" class="color-#6D4CFE mb-13px" />
|
||||||
|
<span class="s2 !color-#6D4CFE">二维码生成中...</span>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="absolute top-0 left-0 w-full h-full flex items-center justify-center opacity-80 bg-#fff"
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<img v-else :src="qrCodeUrl" width="160" height="160" />
|
||||||
|
|
||||||
<div v-if="isOverdue" class="mask cursor-pointer" @click="getAuthorizedQrCode">
|
<div v-if="isOverdue" class="mask cursor-pointer" @click="getAuthorizedQrCode">
|
||||||
<icon-refresh size="24" class="mb-13px" />
|
<icon-refresh size="24" class="mb-13px" />
|
||||||
<p class="s1">二维码失效</p>
|
<p class="s1">二维码失效</p>
|
||||||
@ -108,7 +121,8 @@ const isSuccess = ref(false);
|
|||||||
const failReason = ref('');
|
const failReason = ref('');
|
||||||
const progress = ref(0);
|
const progress = ref(0);
|
||||||
const id = ref('');
|
const id = ref('');
|
||||||
const imgUrl = ref('');
|
const qrCodeUrl = ref('');
|
||||||
|
const qrCodeLoading = ref(false);
|
||||||
|
|
||||||
const taskStep = ref(TASK_STEP.default);
|
const taskStep = ref(TASK_STEP.default);
|
||||||
// const hasUnsyncData = ref(false); // 含有未同步数据
|
// const hasUnsyncData = ref(false); // 含有未同步数据
|
||||||
@ -143,7 +157,8 @@ const resetTaskFields = () => {
|
|||||||
isSuccess.value = false;
|
isSuccess.value = false;
|
||||||
failReason.value = '';
|
failReason.value = '';
|
||||||
progress.value = 0;
|
progress.value = 0;
|
||||||
imgUrl.value = '';
|
qrCodeUrl.value = '';
|
||||||
|
qrCodeLoading.value = false;
|
||||||
isNicknameChanged.value = false;
|
isNicknameChanged.value = false;
|
||||||
actionType.value = 1;
|
actionType.value = 1;
|
||||||
taskStep.value = TASK_STEP.default;
|
taskStep.value = TASK_STEP.default;
|
||||||
@ -184,16 +199,21 @@ const startStatusPolling = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getAuthorizedQrCode = async () => {
|
const getAuthorizedQrCode = async () => {
|
||||||
const { code, data } = await getAuthorizedImage(id.value);
|
try {
|
||||||
if (code === 200) {
|
qrCodeLoading.value = true;
|
||||||
imgUrl.value = data.image;
|
const { code, data } = await getAuthorizedImage(id.value);
|
||||||
overdueTimer = null;
|
if (code === 200) {
|
||||||
isOverdue.value = false;
|
qrCodeUrl.value = data.image;
|
||||||
|
overdueTimer = null;
|
||||||
|
isOverdue.value = false;
|
||||||
|
|
||||||
// 约定:后端限制40s内必须扫码,前端定30s后失效
|
// 约定:后端限制40s内必须扫码,前端定30s后失效
|
||||||
overdueTimer = setTimeout(() => {
|
overdueTimer = setTimeout(() => {
|
||||||
isOverdue.value = true;
|
isOverdue.value = true;
|
||||||
}, OVERDUE_TIME);
|
}, OVERDUE_TIME);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
qrCodeLoading.value = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -246,8 +266,8 @@ const handleOk = () => {
|
|||||||
if (taskStep.value === TASK_STEP.default) {
|
if (taskStep.value === TASK_STEP.default) {
|
||||||
clearOverdueTimer();
|
clearOverdueTimer();
|
||||||
|
|
||||||
if (!imgUrl.value) {
|
if (!qrCodeUrl.value) {
|
||||||
AMessage.error('二维码获取中,请稍等');
|
AMessage.error('二维码生成中,请稍等');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isOverdue.value) {
|
if (isOverdue.value) {
|
||||||
|
|||||||
@ -36,6 +36,7 @@ export enum EnumStatus {
|
|||||||
ABNORMAL_LOGIN = 4,
|
ABNORMAL_LOGIN = 4,
|
||||||
ABNORMAL_REQUEST = 5,
|
ABNORMAL_REQUEST = 5,
|
||||||
ABNORMAL_FREEZE = 6,
|
ABNORMAL_FREEZE = 6,
|
||||||
|
ABNORMAL_MISSING = 7,
|
||||||
}
|
}
|
||||||
|
|
||||||
export const STATUS_LIST = [
|
export const STATUS_LIST = [
|
||||||
@ -59,6 +60,11 @@ export const STATUS_LIST = [
|
|||||||
label: '异常',
|
label: '异常',
|
||||||
value: EnumStatus.ABNORMAL,
|
value: EnumStatus.ABNORMAL,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
text: '数据缺失',
|
||||||
|
label: '数据缺失',
|
||||||
|
value: EnumStatus.ABNORMAL_MISSING,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
text: '异常-登录状态失效',
|
text: '异常-登录状态失效',
|
||||||
label: '异常',
|
label: '异常',
|
||||||
|
|||||||
@ -212,12 +212,8 @@ const handleOpenEdit = (item) => {
|
|||||||
const handleSelectionChange = (val) => {
|
const handleSelectionChange = (val) => {
|
||||||
selectedItems.value = val;
|
selectedItems.value = val;
|
||||||
};
|
};
|
||||||
const handleChangeAll = (val) => {
|
const handleChangeAll = (checked) => {
|
||||||
if (val) {
|
selectedItems.value = checked ? cloneDeep(dataSource.value) : [];
|
||||||
selectedItems.value = cloneDeep(dataSource.value);
|
|
||||||
} else {
|
|
||||||
selectedItems.value = [];
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
const handleBatchDelete = () => {
|
const handleBatchDelete = () => {
|
||||||
const ids = selectedItems.value.map((item) => item.id);
|
const ids = selectedItems.value.map((item) => item.id);
|
||||||
|
|||||||
Reference in New Issue
Block a user