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