+
![]()
-
-
请使用抖音扫码,将公司账号绑定至灵机平台。
+
请使用抖音扫码,将公司账号绑定至灵机平台。
@@ -62,8 +62,10 @@ import icon1 from '@/assets/img/media-account/icon-warn.png';
import icon2 from '@/assets/img/media-account/icon-feedback-success.png';
import icon3 from '@/assets/img/media-account/icon-feedback-fail.png';
+const OVERDUE_TIME = 30000; // 失效时间
+
const visible = ref(false);
-const isOverdue = ref(false);
+const isOverdue = ref(false); // 二维码失效
const isLoading = ref(false);
const isCompleted = ref(false);
const isSuccess = ref(false);
@@ -73,6 +75,7 @@ const id = ref('');
const imgUrl = ref('');
let progressTimer = null;
+let overdueTimer = null;
const notCompleted = computed(() => {
return !isCompleted.value;
@@ -84,7 +87,7 @@ const confirmBtnText = computed(() => {
const open = (accountId) => {
id.value = accountId;
- handleAuthorizedImage();
+ getAuthorizedQrCode();
visible.value = true;
};
const close = () => {
@@ -95,14 +98,21 @@ const close = () => {
failReason.value = '';
progress.value = 0;
id.value = '';
-
+ clearFakeProgressTimer();
+ clearOverdueTimer();
visible.value = false;
};
-const handleAuthorizedImage = async () => {
+const getAuthorizedQrCode = async () => {
const { code, data } = await getAuthorizedImage(id.value);
if (code === 200) {
imgUrl.value = data.url;
+ overdueTimer = null;
+
+ // 约定:后端限制40s内必须扫码,前端定30s后失效
+ overdueTimer = setTimeout(() => {
+ isOverdue.value = true;
+ }, OVERDUE_TIME);
}
};
const startLoading = async () => {
@@ -136,18 +146,27 @@ const clearFakeProgressTimer = () => {
progressTimer = null;
}
};
+const clearOverdueTimer = () => {
+ if (overdueTimer) {
+ clearTimeout(overdueTimer);
+ overdueTimer = null;
+ }
+};
const handleOk = () => {
if (notCompleted.value) {
+ clearOverdueTimer();
+
+ if (isOverdue.value) {
+ AMessage.error('二维码已失效,请重新扫码');
+ return;
+ }
+
startLoading();
return;
}
};
-onUnmounted(() => {
- clearFakeProgressTimer();
-});
-
defineExpose({
open,
});
diff --git a/src/views/property-marketing/media-account/account-manage/components/reauthorize-account-modal/index.vue b/src/views/property-marketing/media-account/account-manage/components/reauthorize-account-modal/index.vue
index ef84c93..bdf86ce 100644
--- a/src/views/property-marketing/media-account/account-manage/components/reauthorize-account-modal/index.vue
+++ b/src/views/property-marketing/media-account/account-manage/components/reauthorize-account-modal/index.vue
@@ -9,11 +9,40 @@
title="重新授权"
modal-class="reauthorize-account-modal"
:mask-closable="false"
- :footer="!isLoading"
+ :footer="taskStep !== TASK_STEP.loading"
@close="close"
>
-
+
+
+
+
![]()
+
检测到该账号最后更新日期为x月x日,已有x天未同步最新数据。
+
+
+ 立即同步遗漏数据 - 获取完整的最新数据 (推荐)
+ 仅授权不更新 - 继续使用当前不完全的数据
+
+
+
+
+
![]()
+
+
+ 请使用抖音扫码,将公司账号绑定至灵机平台。
+
+
+
数据同步和初始化中,请勿关闭窗口。
-
-
-
![]()
-
检测到该账号最后更新日期为x月x日,已有x天未同步最新数据。
-
-
- 立即同步遗漏数据 - 获取完整的最新数据 (推荐)
- 仅授权不更新 - 继续使用当前不完全的数据
-
-
-
-
-
![]()
-
当前绑定的账号与之前的昵称不一致,请确认是否覆盖原账号信息。
-
-
-
-
原账号:全球旅行小助手
-
当前账号:环球旅行官
-
-
-
-
+
+
+
![]()
+
当前绑定的账号与之前的昵称不一致,请确认是否覆盖原账号信息。
+
+
+
+
原账号:全球旅行小助手
+
当前账号:环球旅行官
+
+
+
+
{{ `数据初始化${isSuccess ? '成功' : '失败'}。` }}
失败原因:{{ failReason || '-' }}
-
-
-
![]()
-
未识别到有效二维码。
-
-
-
![]()
-
-
- 请使用抖音扫码,将公司账号绑定至灵机平台。
-
- 取消
{{ confirmBtnText }}
@@ -91,64 +95,81 @@ import icon2 from '@/assets/img/media-account/icon-feedback-success.png';
import icon3 from '@/assets/img/media-account/icon-feedback-fail.png';
import icon4 from '@/assets/img/media-account/icon-warn-1.png';
+const OVERDUE_TIME = 30000; // 失效时间
+const TASK_STEP = {
+ default: 1,
+ loading: 2,
+ end: 3,
+};
+
const visible = ref(false);
-const isOverdue = ref(false);
-const isLoading = ref(false);
-const isCompleted = ref(false);
+const isOverdue = ref(false); // 二维码失效
const isSuccess = ref(false);
const failReason = ref('');
const progress = ref(0);
const id = ref('');
const imgUrl = ref('');
-const loadingStep = ref(0); // 1 | 2
+
+const taskStep = ref(TASK_STEP.default);
+const hasUnsyncData = ref(false); // 含有未同步数据
+const isNicknameChanged = ref(false); // 昵称发生变化
const actionType = ref(1);
let progressTimer = null;
+let overdueTimer = null;
-const notCompleted = computed(() => {
- return !isCompleted.value;
-});
const confirmBtnText = computed(() => {
- if (loadingStep.value === 1) return '确定';
- if (loadingStep.value === 2) return '确定覆盖';
+ if (taskStep.value === TASK_STEP.default) {
+ return hasUnsyncData.value ? '确定' : '完成扫码';
+ }
- if (notCompleted.value) return '完成扫码';
+ if (taskStep.value === TASK_STEP.end) {
+ if (isNicknameChanged.value) return '确定覆盖';
+ return isSuccess.value ? '继续添加' : '重新扫码';
+ }
- return isSuccess.value ? '继续添加' : '重新扫码';
+ return '';
});
const open = (accountId) => {
id.value = accountId;
- handleAuthorizedImage();
+ getAuthorizedQrCode();
visible.value = true;
};
const close = () => {
isOverdue.value = false;
- isLoading.value = false;
- isCompleted.value = false;
isSuccess.value = false;
failReason.value = '';
progress.value = 0;
- loadingStep.value = 0;
+ taskStep.value = TASK_STEP.default;
actionType.value = 1;
+ hasUnsyncData.value = false;
+ isNicknameChanged.value = false;
id.value = '';
-
+ clearFakeProgressTimer();
+ clearOverdueTimer();
visible.value = false;
};
-const handleAuthorizedImage = async () => {
+const getAuthorizedQrCode = async () => {
const { code, data } = await getAuthorizedImage(id.value);
if (code === 200) {
imgUrl.value = data.url;
+ overdueTimer = null;
+
+ // 约定:后端限制40s内必须扫码,前端定30s后失效
+ overdueTimer = setTimeout(() => {
+ isOverdue.value = true;
+ }, OVERDUE_TIME);
}
};
const startLoading = async () => {
- isLoading.value = true;
+ taskStep.value = TASK_STEP.loading;
progress.value = 0;
startFakeProgressPolling();
// const { code } = await startPatchAccount(id.value);
// if (code === 200) {
- // isLoading.value = true;
+ // taskStep.value = TASK_STEP.loading;
// progress.value = 0;
// startFakeProgressPolling();
// }
@@ -162,7 +183,7 @@ const startFakeProgressPolling = () => {
progress.value = Math.min(progress.value + step, 0.99);
progress.value = Number(progress.value.toFixed(2));
} else {
- loadingStep.value = 2;
+ taskStep.value = TASK_STEP.end;
clearFakeProgressTimer();
}
}, 1000);
@@ -174,23 +195,50 @@ const clearFakeProgressTimer = () => {
progressTimer = null;
}
};
+const clearOverdueTimer = () => {
+ if (overdueTimer) {
+ clearTimeout(overdueTimer);
+ overdueTimer = null;
+ }
+};
+
+const getSyncDataStatus = () => {
+ return hasUnsyncData.value;
+};
const handleOk = () => {
- if (loadingStep.value === 1) {
+ if (taskStep.value === TASK_STEP.default) {
+ clearOverdueTimer();
+
+ if (isOverdue.value) {
+ AMessage.error('二维码已失效,请重新扫码');
+ return;
+ }
+
+ const _hasUnsyncData = getSyncDataStatus();
+ if (!_hasUnsyncData) {
+ hasUnsyncData.value = true;
+ return;
+ }
+
startLoading();
return;
}
- if (notCompleted.value) {
- loadingStep.value = 1;
- return;
+ if (taskStep.value === TASK_STEP.end) {
+ if (isNicknameChanged.value) {
+ isNicknameChanged.value = false;
+ console.log('确定覆盖');
+ } else {
+ if (isSuccess.value) {
+ console.log('继续添加');
+ } else {
+ console.log('重新扫码');
+ }
+ }
}
};
-onUnmounted(() => {
- clearFakeProgressTimer();
-});
-
defineExpose({
open,
});