feat: gxnlpt 接通后端API,401弹窗引导登录

- 解开 import api 注释
- loadAllSections: API优先,wzxxList失败自动fallback demo
- loadFavorites: API调用,401弹窗提示登录(确认→登录页,取消→停留)
- handleCollect: API调用,401同上
- handleSubmitForm: API调用,401同上

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
liulujian 2026-07-04 23:54:47 +08:00
parent a071be1f41
commit 7c1e0a4e18

View File

@ -319,7 +319,7 @@ import GxnlptCardTags from '@/pages/index/views/gxnlpt/components/GxnlptCardTags
import EmptyState from '@/pages/index/components/EmptyState.vue';
import StatsSummary from '@/pages/index/components/StatsSummary.vue';
import SkeletonCard from '@/pages/index/components/SkeletonCard.vue';
// import api from '@/pages/index/api/gxnl/index.js'; // TODO
import api from '@/pages/index/api/gxnl/index.js';
// 204
// .xlsx
// Sheet1 3 + Sheet2 15 = 18
@ -1179,37 +1179,31 @@ export default {
},
async loadAllSections() {
this.pageLoading = true;
// TODO
// this.useDemoData = false;
// if (FORCE_DEMO_PREVIEW) {
// this.applyDemoFallback();
// this.pageLoading = false;
// return;
// }
// try {
// const res = await api.wzxxList({
// pageNo: 1,
// pageSize: 200,
// });
// const data = res && res.data;
// const records = ((data && data.records) || []).map((r) => this.normalizeRecord(r));
// if (!records.length) {
// this.applyDemoFallback();
// return;
// }
// this.assignCategoryCards(records);
// const hasCards = this.categoryList.some((c) => c.displayList.length);
// if (!hasCards) {
// this.applyDemoFallback();
// }
// } catch (e) {
// console.error('', e);
// this.applyDemoFallback();
// } finally {
// this.pageLoading = false;
// }
this.applyDemoFallback();
this.pageLoading = false;
this.useDemoData = false;
if (FORCE_DEMO_PREVIEW) {
this.applyDemoFallback();
this.pageLoading = false;
return;
}
try {
const res = await api.wzxxList({ pageNo: 1, pageSize: 200 });
const data = res && res.data;
const records = ((data && data.records) || []).map((r) => this.normalizeRecord(r));
if (!records.length) {
this.applyDemoFallback();
return;
}
this.assignCategoryCards(records);
const hasCards = this.categoryList.some((c) => c.displayList.length);
if (!hasCards) {
this.applyDemoFallback();
}
} catch (e) {
console.error('共性能力列表加载失败', e);
this.applyDemoFallback();
} finally {
this.pageLoading = false;
}
},
getScrollRoot() {
// .content-wrapmain.vue
@ -1357,24 +1351,23 @@ export default {
},
async loadFavorites() {
this.favoritesLoading = true;
// TODO
// try {
// const res = await api.myFavoriteList({ pageNo: 1, pageSize: 200 });
// const data = res && res.data;
// const records = ((data && data.records) || []).map((r) => this.normalizeRecord(r));
// this.favoriteList = records.map((card) => {
// card.scbz = 'Y';
// return card;
// });
// } catch (e) {
// if (isUnauthorizedError(e)) {
// showLoginGuide({ actionText: '' });
// return;
// }
// this.$message.warning('');
// } finally {
try {
const res = await api.myFavoriteList({ pageNo: 1, pageSize: 200 });
const data = res && res.data;
const records = ((data && data.records) || []).map((r) => this.normalizeRecord(r));
this.favoriteList = records.map((card) => {
card.scbz = 'Y';
return card;
});
} catch (e) {
if (isUnauthorizedError(e)) {
showLoginGuide({ actionText: '查看我的收藏' });
return;
}
this.$message.warning('我的收藏加载失败');
} finally {
this.favoritesLoading = false;
// }
}
},
resetSubmitForm() {
this.submitForm = SUBMIT_FORM_EMPTY();
@ -1428,32 +1421,25 @@ export default {
if (!this.validateSubmitForm()) {
return;
}
if (this.useDemoData) {
try {
await api.submitSlxx({
bt: this.submitForm.bt1,
wzLj: this.submitForm.lj,
jj: this.submitForm.jj,
gxnlFlDm: flTitleToDm(this.submitForm.fl),
bqjh: this.submitForm.bq,
});
this.$message.success('提交成功,请等待审核');
this.resetSubmitForm();
this.contentView = 'list';
return;
await this.loadAllSections();
} catch (e) {
if (isUnauthorizedError(e)) {
showLoginGuide({ actionText: '提交收录' });
return;
}
this.$message.warning('提交失败,请稍后重试');
}
// TODO
// try {
// await api.submitSlxx({
// bt: this.submitForm.bt1,
// wzLj: this.submitForm.lj,
// jj: this.submitForm.jj,
// gxnlFlDm: flTitleToDm(this.submitForm.fl),
// bqjh: this.submitForm.bq,
// });
// this.$message.success('');
// this.resetSubmitForm();
// this.contentView = 'list';
// await this.loadAllSections();
// } catch (e) {
// if (isUnauthorizedError(e)) {
// showLoginGuide({ actionText: '' });
// return;
// }
// this.$message.warning('');
// }
},
/**
* 平滑滚动到指定分类区块
@ -1918,20 +1904,19 @@ export default {
card.scbz = card.scbz === 'Y' ? 'N' : 'Y';
return;
}
// TODO
// try {
// const type = card.scbz === 'Y' ? 'remove' : 'add';
// await api.toggleGxsc({ wzUuid: card.gxUuid, type });
// const next = card.scbz === 'Y' ? 'N' : 'Y';
// card.scbz = next;
// this.syncFavoriteListAfterToggle(card, next);
// } catch (e) {
// if (isUnauthorizedError(e)) {
// showLoginGuide({ actionText: '' });
// return;
// }
// this.$message.warning('');
// }
try {
const type = card.scbz === 'Y' ? 'remove' : 'add';
await api.toggleGxsc({ wzUuid: card.gxUuid, type });
const next = card.scbz === 'Y' ? 'N' : 'Y';
card.scbz = next;
this.syncFavoriteListAfterToggle(card, next);
} catch (e) {
if (isUnauthorizedError(e)) {
showLoginGuide({ actionText: '收藏' });
return;
}
this.$message.warning('收藏操作失败');
}
},
/** 收藏切换后同步本地 favoriteList避免再次进入「我的收藏」时与服务端不一致 */
syncFavoriteListAfterToggle(card, nextScbz) {