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:
parent
a071be1f41
commit
7c1e0a4e18
@ -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-wrap(main.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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user