260720
This commit is contained in:
395
utils/gxmu/config.js
Normal file
395
utils/gxmu/config.js
Normal file
@@ -0,0 +1,395 @@
|
||||
const GENDER_OPTIONS = ['男', '女']
|
||||
const YES_NO_OPTIONS = ['是', '否']
|
||||
|
||||
export const GXMU_MODULES = [
|
||||
{
|
||||
title: '十佳青年岗位能手',
|
||||
code: 'gxmu_sjqn',
|
||||
icon: '青',
|
||||
group: '个人奖项',
|
||||
desc: '面向青年岗位骨干与先进典型的申报入口。'
|
||||
},
|
||||
{
|
||||
title: '十佳团支部书记',
|
||||
code: 'gxmu_sjtbzbsj',
|
||||
icon: '书',
|
||||
group: '个人奖项',
|
||||
desc: '聚焦基层团支部书记的履职表现与带动成效。'
|
||||
},
|
||||
{
|
||||
title: '五四红旗团委',
|
||||
code: 'gxmu_wshqtw',
|
||||
icon: '委',
|
||||
group: '组织奖项',
|
||||
desc: '用于先进团委集体申报与材料汇总展示。'
|
||||
},
|
||||
{
|
||||
title: '五四红旗团支部',
|
||||
code: 'gxmu_wshqtzb',
|
||||
icon: '支',
|
||||
group: '组织奖项',
|
||||
desc: '聚焦先进团支部建设成果与品牌工作展示。'
|
||||
},
|
||||
{
|
||||
title: '优秀共青团干部',
|
||||
code: 'gxmu_yxgqtdgb',
|
||||
icon: '干',
|
||||
group: '个人奖项',
|
||||
desc: '面向团学骨干和团务干部的申报入口。'
|
||||
},
|
||||
{
|
||||
title: '优秀共青团员',
|
||||
code: 'gxmu_yxgqty',
|
||||
icon: '员',
|
||||
group: '个人奖项',
|
||||
desc: '面向优秀团员个人事迹与成长表现申报。'
|
||||
},
|
||||
{
|
||||
title: '挑战杯',
|
||||
code: 'gxmu_tzbcy_form',
|
||||
icon: '挑',
|
||||
group: '竞赛项目',
|
||||
desc: '面向挑战杯项目材料填报与过程归档。'
|
||||
},
|
||||
{
|
||||
title: '青马工程',
|
||||
code: 'gxmu_qmgc_form',
|
||||
icon: '青',
|
||||
group: '培养项目',
|
||||
desc: '用于青马工程学员培养信息和成果申报。'
|
||||
},
|
||||
{
|
||||
title: '未来学术之星',
|
||||
code: 'gxmu_wxxzx_project',
|
||||
icon: '星',
|
||||
group: '创新项目',
|
||||
desc: '用于未来学术之星项目申报和材料整理。'
|
||||
}
|
||||
]
|
||||
|
||||
const createFields = (fields) =>
|
||||
fields.map((field) => ({
|
||||
required: false,
|
||||
placeholder: `请输入${field.label}`,
|
||||
...field
|
||||
}))
|
||||
|
||||
export const GXMU_FORM_MAP = {
|
||||
gxmu_sjqn: {
|
||||
title: '十佳青年岗位能手申报表',
|
||||
subtitle: '参考后台 SJQNForm 字段结构,适用于个人申报信息填写。',
|
||||
sections: [
|
||||
{
|
||||
title: '基础信息',
|
||||
fields: createFields([
|
||||
{ key: 'year', label: '年份', type: 'year', required: true },
|
||||
{ key: 'applyType', label: '申报类别', required: true },
|
||||
{ key: 'name', label: '姓名', required: true },
|
||||
{ key: 'gender', label: '性别', type: 'select', options: GENDER_OPTIONS },
|
||||
{ key: 'birthMonth', label: '出生年月', type: 'month' },
|
||||
{ key: 'nation', label: '民族' },
|
||||
{ key: 'politics', label: '政治面貌' },
|
||||
{ key: 'education', label: '学历' },
|
||||
{ key: 'position', label: '职务' },
|
||||
{ key: 'title', label: '职称' },
|
||||
{ key: 'unit', label: '所在单位' }
|
||||
])
|
||||
},
|
||||
{
|
||||
title: '申报内容',
|
||||
fields: createFields([
|
||||
{ key: 'awards', label: '近三年曾获校级及以上奖励', type: 'textarea' },
|
||||
{ key: 'experience', label: '工作(学习)经历', type: 'textarea' },
|
||||
{ key: 'mainStory', label: '主要事迹', type: 'textarea' }
|
||||
])
|
||||
}
|
||||
]
|
||||
},
|
||||
gxmu_sjtbzbsj: {
|
||||
title: '十佳团支部书记申报表',
|
||||
subtitle: '参考后台 SJTBZBSJForm 字段结构,适用于个人申报信息填写。',
|
||||
sections: [
|
||||
{
|
||||
title: '基础信息',
|
||||
fields: createFields([
|
||||
{ key: 'year', label: '年份', type: 'year', required: true },
|
||||
{ key: 'name', label: '姓名', required: true },
|
||||
{ key: 'gender', label: '性别', type: 'select', options: GENDER_OPTIONS },
|
||||
{ key: 'birthMonth', label: '出生年月', type: 'month' },
|
||||
{ key: 'nation', label: '民族' },
|
||||
{ key: 'politics', label: '政治面貌' },
|
||||
{ key: 'collegeClass', label: '学院班级/单位科室' },
|
||||
{ key: 'branch', label: '所在团支部' },
|
||||
{ key: 'eduEval', label: '上一年度团员教育评议等次' }
|
||||
])
|
||||
},
|
||||
{
|
||||
title: '申报内容',
|
||||
fields: createFields([
|
||||
{ key: 'awards', label: '近三年曾获校级及以上奖励', type: 'textarea' },
|
||||
{ key: 'experience', label: '工作(学习)经历', type: 'textarea' },
|
||||
{ key: 'mainStory', label: '主要事迹', type: 'textarea' }
|
||||
])
|
||||
}
|
||||
]
|
||||
},
|
||||
gxmu_wshqtw: {
|
||||
title: '五四红旗团委申报表',
|
||||
subtitle: '参考后台 WSHQTWForm 字段结构,适用于组织集体申报。',
|
||||
sections: [
|
||||
{
|
||||
title: '组织基本信息',
|
||||
fields: createFields([
|
||||
{ key: 'year', label: '年份', type: 'year', required: true },
|
||||
{ key: 'orgName', label: '二级团组织全称', required: true },
|
||||
{ key: 'leader', label: '负责人' },
|
||||
{ key: 'phone', label: '联系电话', type: 'phone' },
|
||||
{ key: 'memberTotal', label: '现有团员总数', type: 'number' },
|
||||
{ key: 'memberDeveloped2024', label: '上一年度发展团员人数', type: 'number' },
|
||||
{ key: 'smartSystemLogin', label: '是否已登录智慧团建系统', type: 'select', options: YES_NO_OPTIONS },
|
||||
{ key: 'committeeCount', label: '团委委员人数', type: 'number' },
|
||||
{ key: 'fulltimeCadreCount', label: '专职团干部数(其中教师/学生)' },
|
||||
{ key: 'parttimeCadreCount', label: '兼职团干部数(其中教师/学生)' },
|
||||
{ key: 'lastElectionTime', label: '团委最近一次换届时间', type: 'date' },
|
||||
{ key: 'branchCount', label: '团支部数', type: 'number' }
|
||||
])
|
||||
},
|
||||
{
|
||||
title: '年度建设情况',
|
||||
fields: createFields([
|
||||
{ key: 'feeReceivable2024', label: '上一年度应收团费', type: 'number' },
|
||||
{ key: 'feeReceived2024', label: '上一年度实收团费', type: 'number' },
|
||||
{ key: 'feePayable2024', label: '上一年度应上缴团费', type: 'number' },
|
||||
{ key: 'feePaid2024', label: '上一年度实际上缴团费', type: 'number' },
|
||||
{ key: 'standardizedWork2024', label: '是否开展规范化建设工作', type: 'select', options: YES_NO_OPTIONS },
|
||||
{ key: 'recommendActivist2024', label: '推荐入党积极分子人数', type: 'number' },
|
||||
{ key: 'activistConfirmed', label: '确定为入党积极分子数', type: 'number' },
|
||||
{ key: 'recommendDevTarget2024', label: '推荐党的发展对象人数', type: 'number' },
|
||||
{ key: 'devTargetConfirmed', label: '确定为党的发展对象数', type: 'number' }
|
||||
])
|
||||
},
|
||||
{
|
||||
title: '主要成果',
|
||||
fields: createFields([
|
||||
{ key: 'honorsFiveYears', label: '近五年获得校级及以上荣誉情况', type: 'textarea' },
|
||||
{ key: 'workSummaryThreeYears', label: '近三年开展的主要工作及取得的效果', type: 'textarea' }
|
||||
])
|
||||
}
|
||||
]
|
||||
},
|
||||
gxmu_wshqtzb: {
|
||||
title: '五四红旗团支部申报表',
|
||||
subtitle: '参考后台 WSHQTZBForm 字段结构,适用于基层团支部集体申报。',
|
||||
sections: [
|
||||
{
|
||||
title: '组织基本信息',
|
||||
fields: createFields([
|
||||
{ key: 'year', label: '年份', type: 'year', required: true },
|
||||
{ key: 'branchName', label: '团支部全称', required: true },
|
||||
{ key: 'secondOrg', label: '所属二级团组织' },
|
||||
{ key: 'secretary', label: '团支部书记' },
|
||||
{ key: 'politics', label: '政治面貌' },
|
||||
{ key: 'contact', label: '联系方式', type: 'phone' },
|
||||
{ key: 'establishTime', label: '成立时间', type: 'date' },
|
||||
{ key: 'lastElectionTime', label: '最近一次换届时间', type: 'date' },
|
||||
{ key: 'smartSystemLogin', label: '是否已登录智慧团建系统', type: 'select', options: YES_NO_OPTIONS },
|
||||
{ key: 'memberTotal', label: '现有团员总数', type: 'number' },
|
||||
{ key: 'memberDeveloped2024', label: '上一年度发展团员数', type: 'number' }
|
||||
])
|
||||
},
|
||||
{
|
||||
title: '年度建设情况',
|
||||
fields: createFields([
|
||||
{ key: 'feeReceivable2024', label: '上一年度应收团费', type: 'number' },
|
||||
{ key: 'feeReceived2024', label: '上一年度实收团费', type: 'number' },
|
||||
{ key: 'feePayable2024', label: '上一年度应上缴团费', type: 'number' },
|
||||
{ key: 'feePaid2024', label: '上一年度实际上缴团费', type: 'number' },
|
||||
{ key: 'recommendActivist2024', label: '推荐入党积极分子人数', type: 'number' },
|
||||
{ key: 'activistConfirmed', label: '确定为入党积极分子数', type: 'number' },
|
||||
{ key: 'recommendDevTarget2024', label: '推荐党的发展对象人数', type: 'number' },
|
||||
{ key: 'devTargetConfirmed', label: '确定为党的发展对象数', type: 'number' },
|
||||
{ key: 'branchCommitteeMeetingCount', label: '团支部委员会会议召开次数', type: 'number' },
|
||||
{ key: 'branchMemberMeetingCount', label: '团支部团员大会召开次数', type: 'number' },
|
||||
{ key: 'eduEvalDone', label: '是否开展团员教育评议', type: 'select', options: YES_NO_OPTIONS },
|
||||
{ key: 'annualRegDone', label: '是否开展团员年度团籍注册', type: 'select', options: YES_NO_OPTIONS },
|
||||
{ key: 'classCount', label: '开展团课次数', type: 'number' },
|
||||
{ key: 'smartSystem100', label: '是否100%录入智慧团建', type: 'select', options: YES_NO_OPTIONS }
|
||||
])
|
||||
},
|
||||
{
|
||||
title: '主要成果',
|
||||
fields: createFields([
|
||||
{ key: 'honorsFiveYears', label: '近五年获得院级及以上荣誉情况', type: 'textarea' },
|
||||
{ key: 'workSummaryThreeYears', label: '近三年开展的主要工作及取得的效果', type: 'textarea' }
|
||||
])
|
||||
}
|
||||
]
|
||||
},
|
||||
gxmu_yxgqtdgb: {
|
||||
title: '优秀共青团干部申报表',
|
||||
subtitle: '参考后台 YXGQTDGBForm 字段结构,适用于团干部个人申报。',
|
||||
sections: [
|
||||
{
|
||||
title: '基础信息',
|
||||
fields: createFields([
|
||||
{ key: 'year', label: '年份', type: 'year', required: true },
|
||||
{ key: 'name', label: '姓名', required: true },
|
||||
{ key: 'gender', label: '性别', type: 'select', options: GENDER_OPTIONS },
|
||||
{ key: 'nation', label: '民族' },
|
||||
{ key: 'birthMonth', label: '出生年月', type: 'month' },
|
||||
{ key: 'politics', label: '政治面貌' },
|
||||
{ key: 'position', label: '职务' },
|
||||
{ key: 'identity', label: '身份' },
|
||||
{ key: 'organization', label: '所在团组织' },
|
||||
{ key: 'contact', label: '联系方式', type: 'phone' },
|
||||
{ key: 'memberNo', label: '发展团员编号' },
|
||||
{ key: 'currentDutyTime', label: '任现团内职务时间', type: 'month' },
|
||||
{ key: 'cadreYears', label: '担任团干部年限' },
|
||||
{ key: 'assessment2024', label: '上一年度工作考核结果' },
|
||||
{ key: 'volunteerRegTime', label: '成为注册志愿者时间', type: 'month' }
|
||||
])
|
||||
},
|
||||
{
|
||||
title: '申报内容',
|
||||
fields: createFields([
|
||||
{ key: 'cadreExperience', label: '从事团干部经历', type: 'textarea' },
|
||||
{ key: 'honorsFiveYears', label: '近五年获得校级及以上荣誉情况', type: 'textarea' },
|
||||
{ key: 'mainStory', label: '主要事迹', type: 'textarea' }
|
||||
])
|
||||
}
|
||||
]
|
||||
},
|
||||
gxmu_yxgqty: {
|
||||
title: '优秀共青团员申报表',
|
||||
subtitle: '参考后台 YXGQTYForm 字段结构,适用于团员个人申报。',
|
||||
sections: [
|
||||
{
|
||||
title: '基础信息',
|
||||
fields: createFields([
|
||||
{ key: 'year', label: '年份', type: 'year', required: true },
|
||||
{ key: 'name', label: '姓名', required: true },
|
||||
{ key: 'gender', label: '性别', type: 'select', options: GENDER_OPTIONS },
|
||||
{ key: 'nation', label: '民族' },
|
||||
{ key: 'politics', label: '政治面貌' },
|
||||
{ key: 'birthMonth', label: '出生年月', type: 'month' },
|
||||
{ key: 'joinTime', label: '入团时间', type: 'month' },
|
||||
{ key: 'collegeMajorClass', label: '所在学院、专业、班级' },
|
||||
{ key: 'position', label: '职务' },
|
||||
{ key: 'volunteerRegTime', label: '成为注册志愿者时间', type: 'month' },
|
||||
{ key: 'eduEval2024', label: '上一年度团员教育评议等次' },
|
||||
{ key: 'smartSystem', label: '是否已登录智慧团建系统', type: 'select', options: YES_NO_OPTIONS },
|
||||
{ key: 'contact', label: '联系电话', type: 'phone' },
|
||||
{ key: 'totalVolunteerHours', label: '累计志愿服务时长' },
|
||||
{ key: 'volunteerHours2024', label: '上一年度志愿服务时长' },
|
||||
{ key: 'memberNo', label: '发展团员编号' }
|
||||
])
|
||||
},
|
||||
{
|
||||
title: '申报内容',
|
||||
fields: createFields([
|
||||
{ key: 'honorsFiveYears', label: '近五年获得荣誉情况', type: 'textarea' },
|
||||
{ key: 'mainStory', label: '主要事迹', type: 'textarea' }
|
||||
])
|
||||
}
|
||||
]
|
||||
},
|
||||
gxmu_tzbcy_form: {
|
||||
title: '挑战杯申报表',
|
||||
subtitle: '面向挑战杯项目申报、团队信息和成果材料整理。',
|
||||
sections: [
|
||||
{
|
||||
title: '项目信息',
|
||||
fields: createFields([
|
||||
{ key: 'year', label: '年份', type: 'year', required: true },
|
||||
{ key: 'projectName', label: '项目名称', required: true },
|
||||
{ key: 'projectType', label: '项目类型', required: true },
|
||||
{ key: 'projectGroup', label: '项目分组', required: true },
|
||||
{ key: 'leaderName', label: '项目负责人', required: true },
|
||||
{ key: 'leaderCollege', label: '负责人学院' },
|
||||
{ key: 'leaderPhone', label: '负责人电话', type: 'phone' },
|
||||
{ key: 'guidanceTeacher', label: '指导老师' }
|
||||
])
|
||||
},
|
||||
{
|
||||
title: '项目内容',
|
||||
fields: createFields([
|
||||
{ key: 'projectSummary', label: '项目简介', type: 'textarea', required: true },
|
||||
{ key: 'innovationPoint', label: '创新亮点', type: 'textarea' },
|
||||
{ key: 'teamMembers', label: '团队成员', type: 'textarea' },
|
||||
{ key: 'honors', label: '已有成果与奖励', type: 'textarea' }
|
||||
])
|
||||
}
|
||||
]
|
||||
},
|
||||
gxmu_qmgc_form: {
|
||||
title: '青马工程申报表',
|
||||
subtitle: '用于青马工程学员基础信息、培养情况和成果申报。',
|
||||
sections: [
|
||||
{
|
||||
title: '基础信息',
|
||||
fields: createFields([
|
||||
{ key: 'year', label: '年份', type: 'year', required: true },
|
||||
{ key: 'name', label: '姓名', required: true },
|
||||
{ key: 'gender', label: '性别', type: 'select', options: GENDER_OPTIONS },
|
||||
{ key: 'college', label: '学院', required: true },
|
||||
{ key: 'className', label: '班级' },
|
||||
{ key: 'phone', label: '联系电话', type: 'phone' },
|
||||
{ key: 'politics', label: '政治面貌' }
|
||||
])
|
||||
},
|
||||
{
|
||||
title: '培养情况',
|
||||
fields: createFields([
|
||||
{ key: 'trainingExperience', label: '培养经历', type: 'textarea', required: true },
|
||||
{ key: 'practiceExperience', label: '实践经历', type: 'textarea' },
|
||||
{ key: 'mainAchievement', label: '主要成果', type: 'textarea' },
|
||||
{ key: 'selfEvaluation', label: '个人总结', type: 'textarea' }
|
||||
])
|
||||
}
|
||||
]
|
||||
},
|
||||
gxmu_wxxzx_project: {
|
||||
title: '未来学术之星申报表',
|
||||
subtitle: '用于未来学术之星项目申报、课题信息和支撑材料整理。',
|
||||
sections: [
|
||||
{
|
||||
title: '项目基础信息',
|
||||
fields: createFields([
|
||||
{ key: 'year', label: '年份', type: 'year', required: true },
|
||||
{ key: 'projectName', label: '项目名称', required: true },
|
||||
{ key: 'applicantName', label: '申请人', required: true },
|
||||
{ key: 'college', label: '学院', required: true },
|
||||
{ key: 'major', label: '专业' },
|
||||
{ key: 'phone', label: '联系电话', type: 'phone' },
|
||||
{ key: 'guidanceTeacher', label: '指导老师' }
|
||||
])
|
||||
},
|
||||
{
|
||||
title: '申报内容',
|
||||
fields: createFields([
|
||||
{ key: 'researchDirection', label: '研究方向', type: 'textarea' },
|
||||
{ key: 'projectBasis', label: '项目基础', type: 'textarea', required: true },
|
||||
{ key: 'researchPlan', label: '研究计划', type: 'textarea' },
|
||||
{ key: 'expectedResult', label: '预期成果', type: 'textarea' }
|
||||
])
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
export const getModuleMeta = (code) => GXMU_MODULES.find((item) => item.code === code)
|
||||
|
||||
export const getFormConfig = (code) => GXMU_FORM_MAP[code]
|
||||
|
||||
export const createInitialFormData = (code) => {
|
||||
const config = getFormConfig(code)
|
||||
if (!config) {
|
||||
return {}
|
||||
}
|
||||
return config.sections.reduce((result, section) => {
|
||||
section.fields.forEach((field) => {
|
||||
result[field.key] = field.defaultValue || ''
|
||||
})
|
||||
return result
|
||||
}, {})
|
||||
}
|
||||
10
utils/gxmu/declare-service.js
Normal file
10
utils/gxmu/declare-service.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import { API_BASE_URL } from '../../utils/request'
|
||||
import { apiRequest } from '../../pages/assistant/chat-service'
|
||||
|
||||
export function listDeclare(params) {
|
||||
return apiRequest({
|
||||
url: `${API_BASE_URL}/gxmu/declare`,
|
||||
method: 'GET',
|
||||
data: params
|
||||
})
|
||||
}
|
||||
439
utils/gxmu/review-list-service.js
Normal file
439
utils/gxmu/review-list-service.js
Normal file
@@ -0,0 +1,439 @@
|
||||
import { API_BASE_URL } from '../request'
|
||||
import { apiRequest } from '../../pages/assistant/chat-service'
|
||||
|
||||
function request(url, method = 'GET', data) {
|
||||
return apiRequest({
|
||||
url: `${API_BASE_URL}${url}`,
|
||||
method,
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export const REVIEW_AUTHORITY = 'gxmu:reviewList:list'
|
||||
|
||||
export const MODULE_OPTIONS = [
|
||||
{ label: '全部模块', value: '' },
|
||||
{ label: '稿件', value: 'cms_manuscript' },
|
||||
{ label: '十佳青年岗位能手', value: 'gxmu_sjqn' },
|
||||
{ label: '十佳团支部书记', value: 'gxmu_sjtbzbsj' },
|
||||
{ label: '五四红旗团委', value: 'gxmu_wshqtw' },
|
||||
{ label: '五四红旗团支部', value: 'gxmu_wshqtzb' },
|
||||
{ label: '优秀共青团干部', value: 'gxmu_yxgqtdgb' },
|
||||
{ label: '优秀共青团员', value: 'gxmu_yxgqty' },
|
||||
{ label: '挑战杯', value: 'gxmu_tzbcy_form' },
|
||||
{ label: '青马工程', value: 'gxmu_qmgc_form' },
|
||||
{ label: '未来学术之星', value: 'gxmu_wxxzx_project' },
|
||||
{ label: '团员管理', value: 'gxmu_tygl_form' },
|
||||
{ label: '团员管理', value: 'gxmu_tygl' }
|
||||
]
|
||||
|
||||
const COMMON_LABELS = {
|
||||
year: '年份',
|
||||
id: 'ID',
|
||||
title: '标题',
|
||||
content: '内容',
|
||||
cover: '封面',
|
||||
createTime: '创建时间',
|
||||
updateTime: '更新时间',
|
||||
status: '状态',
|
||||
sortNumber: '排序',
|
||||
provinceCity: '省市',
|
||||
schoolName: '学校名称',
|
||||
projectName: '项目名称',
|
||||
projectType: '项目类型',
|
||||
projectGroup: '项目分组',
|
||||
publicProjectType: '公开展示项目类型',
|
||||
publicProjectGroup: '公开展示项目分组',
|
||||
leader: '负责人',
|
||||
phone: '联系电话',
|
||||
teamMembers: '团队成员',
|
||||
advisors: '指导老师',
|
||||
projectBrief: '项目简介',
|
||||
socialValue: '社会价值',
|
||||
practiceProcess: '实践过程',
|
||||
innovationMeaning: '创新意义',
|
||||
developmentProspect: '发展前景',
|
||||
teamCooperation: '团队协作情况',
|
||||
projectMaterials: '项目佐证材料',
|
||||
otherProofs: '其他证明材料',
|
||||
projectSummary: '项目总结',
|
||||
teamIntro: '团队介绍',
|
||||
teamSlogan: '团队口号',
|
||||
practiceLog: '实践日志',
|
||||
name: '姓名',
|
||||
gender: '性别',
|
||||
nation: '民族',
|
||||
photo: '电子版照片',
|
||||
birthMonth: '出生年月',
|
||||
politics: '政治面貌',
|
||||
nativePlace: '籍贯',
|
||||
wechat: '微信号',
|
||||
email: '邮箱',
|
||||
qq: 'QQ',
|
||||
idCardNo: '身份证号',
|
||||
hobby: '兴趣爱好',
|
||||
willingToWorkInGuangxi: '是否愿意留桂工作',
|
||||
schoolInfo: '学校信息',
|
||||
leaguePosition: '团内职务',
|
||||
resume: '个人简历',
|
||||
awards: '获得奖励',
|
||||
academicPerformance: '学习成绩',
|
||||
secondaryLeagueOpinion: '二级团组织意见',
|
||||
secondaryLeagueOpinionDate: '二级团组织意见日期',
|
||||
secondaryPartyOpinion: '二级党组织意见',
|
||||
secondaryPartyOpinionDate: '二级党组织意见日期',
|
||||
schoolLeagueOpinion: '学校团组织意见',
|
||||
schoolLeagueOpinionDate: '学校团组织意见日期',
|
||||
applyType: '申报类别',
|
||||
education: '学历',
|
||||
position: '职务',
|
||||
unit: '工作单位',
|
||||
experience: '主要经历',
|
||||
mainStory: '主要事迹',
|
||||
leagueOpinion: '团组织意见',
|
||||
partyOpinion: '党组织意见',
|
||||
schoolOpinion: '学校意见',
|
||||
collegeClass: '学院班级',
|
||||
branch: '团支部名称',
|
||||
eduEval: '教育评议情况',
|
||||
serialNo: '序号',
|
||||
archiveInCurrentOrg: '团籍是否在本组织',
|
||||
joinMonth: '入团时间',
|
||||
memberRecords: '团员记录',
|
||||
growthArchives: '成长档案',
|
||||
orgName: '组织名称',
|
||||
memberTotal: '团员总数',
|
||||
memberDeveloped2024: '上一年度发展团员数',
|
||||
smartSystemLogin: '智慧团建系统录入情况',
|
||||
committeeCount: '团委委员数',
|
||||
fulltimeCadreCount: '专职团干部数',
|
||||
parttimeCadreCount: '兼职团干部数',
|
||||
lastElectionTime: '最近一次换届时间',
|
||||
feeReceivable2024: '上一年度应收团费',
|
||||
feeReceived2024: '上一年度实收团费',
|
||||
feePayable2024: '上一年度应缴团费',
|
||||
feePaid2024: '上一年度实缴团费',
|
||||
branchCount: '团支部数量',
|
||||
standardizedWork2024: '上一年度标准化建设开展情况',
|
||||
recommendActivist2024: '上一年度推优入党人数',
|
||||
activistConfirmed: '入党积极分子确定情况',
|
||||
recommendDevTarget2024: '上一年度推荐发展对象人数',
|
||||
devTargetConfirmed: '发展对象确定情况',
|
||||
honorsFiveYears: '近五年获奖情况',
|
||||
workSummaryThreeYears: '近三年工作总结',
|
||||
branchName: '团支部名称',
|
||||
secondOrg: '所属二级党组织',
|
||||
secretary: '团支部书记',
|
||||
contact: '联系方式',
|
||||
establishTime: '成立时间',
|
||||
branchCommitteeMeetingCount: '支委会次数',
|
||||
branchMemberMeetingCount: '支部大会次数',
|
||||
eduEvalDone: '教育评议是否完成',
|
||||
annualRegDone: '年度团籍注册是否完成',
|
||||
classCount: '班级数量',
|
||||
smartSystem100: '智慧团建系统覆盖率',
|
||||
topicName: '课题名称',
|
||||
collegeGradeClass: '学院年级班级',
|
||||
advisor: '指导老师',
|
||||
topicType: '课题类别',
|
||||
guidanceTeachers: '指导教师组',
|
||||
applicants: '申请人信息',
|
||||
budgets: '经费预算',
|
||||
rationale: '立项依据',
|
||||
teacherOpinion: '指导教师意见',
|
||||
teacherSign: '指导教师签名',
|
||||
reviewOpinion: '评审意见',
|
||||
reviewScore: '评审成绩',
|
||||
reviewLeaderSign: '评审负责人签名',
|
||||
collegeOpinion: '学院意见',
|
||||
promiseSigner: '承诺签字人',
|
||||
promiseSignature: '承诺书签名',
|
||||
reviewCollege: '评审学院',
|
||||
reviewReporter: '汇报人',
|
||||
reviewDate: '评审日期',
|
||||
reviewMembers: '评审成员',
|
||||
fundingBudgetFile: '经费预算表',
|
||||
fundingAllocationFile: '经费划拨明细表',
|
||||
midtermRemark: '中期检查说明',
|
||||
midtermMaterials: '中期检查材料',
|
||||
finalRemark: '结题说明',
|
||||
finalMaterials: '结题材料',
|
||||
archiveAwards: '获奖情况',
|
||||
archiveProofs: '佐证材料',
|
||||
archiveRecords: '成果归档',
|
||||
grade: '年级',
|
||||
className: '班级',
|
||||
major: '专业',
|
||||
role: '角色',
|
||||
item: '项目',
|
||||
amount: '金额',
|
||||
reason: '原因',
|
||||
dept: '部门',
|
||||
sign: '签名',
|
||||
department: '部门',
|
||||
remark: '备注',
|
||||
type: '类型',
|
||||
recordTime: '时间',
|
||||
archiveTime: '时间',
|
||||
identity: '身份',
|
||||
organization: '所在组织',
|
||||
memberNo: '团员编号',
|
||||
currentDutyTime: '现任职务时间',
|
||||
cadreYears: '从事团学工作年限',
|
||||
assessment2024: '上一年度考核情况',
|
||||
volunteerRegTime: '志愿汇注册时间',
|
||||
cadreExperience: '团学工作经历',
|
||||
joinTime: '入团时间',
|
||||
collegeMajorClass: '学院专业班级',
|
||||
eduEval2024: '上一年度教育评议情况',
|
||||
smartSystem: '智慧团建系统录入情况',
|
||||
totalVolunteerHours: '累计志愿服务时长',
|
||||
volunteerHours2024: '上一年度志愿服务时长',
|
||||
duty: '职务',
|
||||
college: '学院',
|
||||
gradeMajor: '年级专业',
|
||||
birthDate: '出生日期',
|
||||
branchOrganizationName: '所属团支部'
|
||||
}
|
||||
|
||||
export const MODULE_CONFIGS = {
|
||||
cms_manuscript: { title: '稿件', path: '/cms/manuscript', labels: COMMON_LABELS },
|
||||
gxmu_sjqn: { title: '十佳青年岗位能手', path: '/gxmu/sjqn-form', labels: COMMON_LABELS },
|
||||
gxmu_sjtbzbsj: { title: '十佳团支部书记', path: '/gxmu/sjtbzbsj-form', labels: COMMON_LABELS },
|
||||
gxmu_wshqtw: { title: '五四红旗团委', path: '/gxmu/wshqtw-form', labels: COMMON_LABELS },
|
||||
gxmu_wshqtzb: { title: '五四红旗团支部', path: '/gxmu/wshqtzb-form', labels: COMMON_LABELS },
|
||||
gxmu_yxgqtdgb: { title: '优秀共青团干部', path: '/gxmu/yxgqtdgb-form', labels: COMMON_LABELS },
|
||||
gxmu_yxgqty: { title: '优秀共青团员', path: '/gxmu/yxgqty-form', labels: COMMON_LABELS },
|
||||
gxmu_tzbcy_form: { title: '挑战杯', path: '/gxmu/tzbcy-form', labels: COMMON_LABELS },
|
||||
gxmu_qmgc_form: { title: '青马工程', path: '/gxmu/qmgc-form', labels: COMMON_LABELS },
|
||||
gxmu_wxxzx_project: { title: '未来学术之星', path: '/gxmu/wxxzx-form', labels: { ...COMMON_LABELS, title: '职称' } },
|
||||
gxmu_tygl_form: { title: '团员管理', path: '/gxmu/tygl-form', labels: COMMON_LABELS },
|
||||
gxmu_tygl: { title: '团员管理', path: '/gxmu/tygl-form', labels: COMMON_LABELS }
|
||||
}
|
||||
|
||||
export const HIDDEN_FIELDS = new Set([
|
||||
'reviewList',
|
||||
'deleted',
|
||||
'tenantId',
|
||||
'userId',
|
||||
'branchOrganizationId'
|
||||
])
|
||||
|
||||
export const IMAGE_FIELDS = new Set(['photo', 'cover', 'promiseSignature'])
|
||||
export const FILE_FIELDS = new Set([
|
||||
'fundingBudgetFile',
|
||||
'fundingAllocationFile',
|
||||
'midtermMaterials',
|
||||
'finalMaterials',
|
||||
'archiveProofs'
|
||||
])
|
||||
|
||||
export function pageGroupReviewList(params) {
|
||||
return request('/gxmu/review-list/groupPage', 'GET', {
|
||||
...(params || {}),
|
||||
backendAccess: true
|
||||
})
|
||||
}
|
||||
|
||||
export function listReviewList(params) {
|
||||
return request('/gxmu/review-list', 'GET', params)
|
||||
}
|
||||
|
||||
export function updateReviewList(data) {
|
||||
return request('/gxmu/review-list', 'PUT', data)
|
||||
}
|
||||
|
||||
export function getModuleDetail(module, id) {
|
||||
const config = MODULE_CONFIGS[module]
|
||||
if (!config || !id) {
|
||||
return Promise.resolve(null)
|
||||
}
|
||||
return request(`${config.path}/${id}`, 'GET')
|
||||
}
|
||||
|
||||
export function formatDateTime(value) {
|
||||
if (!value) {
|
||||
return '-'
|
||||
}
|
||||
const text = String(value).trim()
|
||||
const normalizedText = text.replace('T', ' ')
|
||||
if (/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(normalizedText)) {
|
||||
return normalizedText.slice(0, 19)
|
||||
}
|
||||
const timestamp = typeof value === 'number' || /^\d+$/.test(text) ? Number(value) : null
|
||||
const date = timestamp
|
||||
? new Date(String(timestamp).length === 10 ? timestamp * 1000 : timestamp)
|
||||
: new Date(text.includes('T') ? text : text.replace(/-/g, '/'))
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return value
|
||||
}
|
||||
const pad = (item) => String(item).padStart(2, '0')
|
||||
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`
|
||||
}
|
||||
|
||||
export function getModuleName(module) {
|
||||
const option = MODULE_OPTIONS.find((item) => item.value === module)
|
||||
return (option && option.label) || (MODULE_CONFIGS[module] && MODULE_CONFIGS[module].title) || module || '-'
|
||||
}
|
||||
|
||||
export function getReviewStatusMeta(status) {
|
||||
if (Number(status) === 1) {
|
||||
return { text: '通过', tone: 'success' }
|
||||
}
|
||||
if (Number(status) === 2) {
|
||||
return { text: '拒绝', tone: 'danger' }
|
||||
}
|
||||
return { text: '待审核', tone: 'warning' }
|
||||
}
|
||||
|
||||
export function getAuthorityValue(item) {
|
||||
if (!item) {
|
||||
return ''
|
||||
}
|
||||
if (typeof item === 'string') {
|
||||
return item
|
||||
}
|
||||
return item.authority || item.permission || item.code || ''
|
||||
}
|
||||
|
||||
export function hasReviewListAuthority(profile) {
|
||||
const authorities = Array.isArray(profile && profile.authorities) ? profile.authorities : []
|
||||
return authorities.some((item) => getAuthorityValue(item) === REVIEW_AUTHORITY)
|
||||
}
|
||||
|
||||
export function isPlainObject(value) {
|
||||
return Object.prototype.toString.call(value) === '[object Object]'
|
||||
}
|
||||
|
||||
export function hasVisibleValue(value) {
|
||||
if (value === null || value === undefined) {
|
||||
return false
|
||||
}
|
||||
if (typeof value === 'string') {
|
||||
return value.trim().length > 0
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
return value.length > 0
|
||||
}
|
||||
if (isPlainObject(value)) {
|
||||
return Object.values(value).some((item) => hasVisibleValue(item))
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
export function getFieldLabel(module, key) {
|
||||
const config = MODULE_CONFIGS[module]
|
||||
const label = config && config.labels && config.labels[key]
|
||||
if (label) {
|
||||
return label
|
||||
}
|
||||
return String(key || '')
|
||||
.replace(/([A-Z])/g, ' $1')
|
||||
.replace(/^./, (text) => text.toUpperCase())
|
||||
.trim()
|
||||
}
|
||||
|
||||
export function normalizeDetailValue(key, value) {
|
||||
if (!FILE_FIELDS.has(key) || typeof value !== 'string') {
|
||||
return value
|
||||
}
|
||||
const text = value.trim()
|
||||
if (!text) {
|
||||
return value
|
||||
}
|
||||
if (key === 'fundingBudgetFile' || key === 'fundingAllocationFile') {
|
||||
return text
|
||||
}
|
||||
try {
|
||||
const parsed = JSON.parse(text)
|
||||
return Array.isArray(parsed) ? parsed : text
|
||||
} catch (error) {
|
||||
return text
|
||||
}
|
||||
}
|
||||
|
||||
export function formatSimpleValue(value) {
|
||||
if (value === null || value === undefined || value === '') {
|
||||
return '-'
|
||||
}
|
||||
return String(value)
|
||||
}
|
||||
|
||||
export function formatDisplayValue(module, key, value) {
|
||||
if (key === 'createTime' || key === 'updateTime') {
|
||||
return formatDateTime(value)
|
||||
}
|
||||
if (key === 'status' && module === 'cms_manuscript') {
|
||||
if (Number(value) === 0) {
|
||||
return '待审核'
|
||||
}
|
||||
if (Number(value) === 1) {
|
||||
return '显示'
|
||||
}
|
||||
}
|
||||
return formatSimpleValue(value)
|
||||
}
|
||||
|
||||
export function getFileName(url) {
|
||||
if (!url) {
|
||||
return '未命名文件'
|
||||
}
|
||||
const cleanUrl = String(url).split('?')[0]
|
||||
return decodeURIComponent(cleanUrl.split('/').pop() || cleanUrl)
|
||||
}
|
||||
|
||||
export function normalizeFileEntries(value) {
|
||||
if (Array.isArray(value)) {
|
||||
return value
|
||||
.map((item) => {
|
||||
if (typeof item === 'string' && item.trim()) {
|
||||
return { name: getFileName(item), url: item }
|
||||
}
|
||||
if (isPlainObject(item) && typeof item.url === 'string' && item.url.trim()) {
|
||||
return {
|
||||
name: (typeof item.name === 'string' && item.name.trim()) || getFileName(item.url),
|
||||
url: item.url
|
||||
}
|
||||
}
|
||||
return null
|
||||
})
|
||||
.filter(Boolean)
|
||||
}
|
||||
if (typeof value === 'string' && value.trim()) {
|
||||
return [{ name: getFileName(value), url: value }]
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
export function formatObjectLines(module, value) {
|
||||
return Object.keys(value || {})
|
||||
.filter((key) => !HIDDEN_FIELDS.has(key) && hasVisibleValue(value[key]))
|
||||
.map((key) => `${getFieldLabel(module, key)}:${formatDisplayValue(module, key, value[key])}`)
|
||||
}
|
||||
|
||||
export function formatArrayEntry(module, entry) {
|
||||
if (isPlainObject(entry)) {
|
||||
const lines = formatObjectLines(module, entry)
|
||||
return lines.length ? lines : ['-']
|
||||
}
|
||||
return [formatSimpleValue(entry)]
|
||||
}
|
||||
|
||||
export function buildDescriptionItems(module, detail) {
|
||||
const source = detail || {}
|
||||
const labels = (MODULE_CONFIGS[module] && MODULE_CONFIGS[module].labels) || {}
|
||||
const orderedKeys = Object.keys(labels).filter((key) => (
|
||||
!HIDDEN_FIELDS.has(key) && hasVisibleValue(source[key])
|
||||
))
|
||||
const extraKeys = Object.keys(source).filter((key) => (
|
||||
!HIDDEN_FIELDS.has(key) &&
|
||||
hasVisibleValue(source[key]) &&
|
||||
!orderedKeys.includes(key)
|
||||
))
|
||||
|
||||
return [...orderedKeys, ...extraKeys].map((key) => ({
|
||||
key,
|
||||
label: getFieldLabel(module, key),
|
||||
value: normalizeDetailValue(key, source[key])
|
||||
}))
|
||||
}
|
||||
125
utils/markdown.js
Normal file
125
utils/markdown.js
Normal file
@@ -0,0 +1,125 @@
|
||||
/**
|
||||
* Lightweight markdown to HTML converter for uni-app rich-text component.
|
||||
* Supports: headings, bold, italic, inline code, code blocks,
|
||||
* unordered lists, ordered lists, blockquotes, horizontal rules, line breaks.
|
||||
*/
|
||||
|
||||
function escapeHtml(str) {
|
||||
return str
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert markdown string to HTML string.
|
||||
* @param {string} text
|
||||
* @returns {string}
|
||||
*/
|
||||
export function renderMarkdown(text) {
|
||||
if (!text) return ''
|
||||
|
||||
// 1. Protect code blocks first (```)
|
||||
const codeBlocks = []
|
||||
let html = text.replace(/```([\w]*)\n?([\s\S]*?)```/g, (_, lang, code) => {
|
||||
const idx = codeBlocks.length
|
||||
const escaped = escapeHtml(code.replace(/^\n/, '').replace(/\n$/, ''))
|
||||
const langAttr = lang ? ` class="language-${lang}"` : ''
|
||||
codeBlocks.push(`<pre><code${langAttr}>${escaped}</code></pre>`)
|
||||
return `\x00CODE${idx}\x00`
|
||||
})
|
||||
|
||||
// 2. Escape remaining HTML to prevent injection
|
||||
html = html.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
||||
|
||||
// 3. Protect inline code (`)
|
||||
const inlineCodes = []
|
||||
html = html.replace(/`([^`\n]+)`/g, (_, code) => {
|
||||
const idx = inlineCodes.length
|
||||
inlineCodes.push(`<code>${escapeHtml(code)}</code>`)
|
||||
return `\x00INLINE${idx}\x00`
|
||||
})
|
||||
|
||||
// 4. Headings (must be at line start)
|
||||
html = html.replace(/^#{4,6} (.+)$/gm, '<h6>$1</h6>')
|
||||
html = html.replace(/^### (.+)$/gm, '<h3>$1</h3>')
|
||||
html = html.replace(/^## (.+)$/gm, '<h2>$1</h2>')
|
||||
html = html.replace(/^# (.+)$/gm, '<h1>$1</h1>')
|
||||
|
||||
// 5. Horizontal rules
|
||||
html = html.replace(/^[ \t]*(?:---+|===+|\*\*\*+)[ \t]*$/gm, '<hr/>')
|
||||
|
||||
// 6. Blockquotes
|
||||
html = html.replace(/^> ?(.*)$/gm, '<blockquote>$1</blockquote>')
|
||||
|
||||
// 7. Bold + Italic
|
||||
html = html.replace(/\*\*\*(.+?)\*\*\*/g, '<strong><em>$1</em></strong>')
|
||||
html = html.replace(/___(.+?)___/g, '<strong><em>$1</em></strong>')
|
||||
|
||||
// 8. Bold
|
||||
html = html.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>')
|
||||
html = html.replace(/__(.+?)__/g, '<strong>$1</strong>')
|
||||
|
||||
// 9. Italic
|
||||
html = html.replace(/\*(.+?)\*/g, '<em>$1</em>')
|
||||
html = html.replace(/_(.+?)_/g, '<em>$1</em>')
|
||||
|
||||
// 10. Lists — collect consecutive list lines into <ul> or <ol>
|
||||
const lines = html.split('\n')
|
||||
const result = []
|
||||
let inUl = false
|
||||
let inOl = false
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i]
|
||||
const ulMatch = line.match(/^[ \t]*[-*+] (.+)$/)
|
||||
const olMatch = line.match(/^[ \t]*\d+\. (.+)$/)
|
||||
|
||||
if (ulMatch) {
|
||||
if (!inUl) {
|
||||
if (inOl) { result.push('</ol>'); inOl = false }
|
||||
result.push('<ul>')
|
||||
inUl = true
|
||||
}
|
||||
result.push(`<li>${ulMatch[1]}</li>`)
|
||||
} else if (olMatch) {
|
||||
if (!inOl) {
|
||||
if (inUl) { result.push('</ul>'); inUl = false }
|
||||
result.push('<ol>')
|
||||
inOl = true
|
||||
}
|
||||
result.push(`<li>${olMatch[1]}</li>`)
|
||||
} else {
|
||||
if (inUl) { result.push('</ul>'); inUl = false }
|
||||
if (inOl) { result.push('</ol>'); inOl = false }
|
||||
result.push(line)
|
||||
}
|
||||
}
|
||||
if (inUl) result.push('</ul>')
|
||||
if (inOl) result.push('</ol>')
|
||||
|
||||
html = result.join('\n')
|
||||
|
||||
// 11. Paragraphs — split by blank lines, wrap plain text blocks in <p>
|
||||
const blocks = html.split(/\n{2,}/)
|
||||
html = blocks.map(block => {
|
||||
block = block.trim()
|
||||
if (!block) return ''
|
||||
// Already wrapped in a block-level tag — leave as-is
|
||||
if (/^<(h[1-6]|ul|ol|li|pre|blockquote|hr)[\s/>]/.test(block)) return block
|
||||
// Has multiple lines → join with <br/>
|
||||
block = block.replace(/\n/g, '<br/>')
|
||||
return `<p>${block}</p>`
|
||||
}).join('\n')
|
||||
|
||||
// 12. Restore inline codes and code blocks
|
||||
inlineCodes.forEach((code, idx) => {
|
||||
html = html.replace(`\x00INLINE${idx}\x00`, code)
|
||||
})
|
||||
codeBlocks.forEach((code, idx) => {
|
||||
html = html.replace(`\x00CODE${idx}\x00`, code)
|
||||
})
|
||||
|
||||
return html
|
||||
}
|
||||
139
utils/request.js
Normal file
139
utils/request.js
Normal file
@@ -0,0 +1,139 @@
|
||||
export const API_BASE_URL = (() => {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
return 'http://localhost:10051/api'
|
||||
}
|
||||
return 'https://tuanwei-api.gxwebsoft.com/api'
|
||||
})()
|
||||
|
||||
export const TOKEN_STORAGE_KEYS = ['access_token', 'Authorization', 'uni_id_token', 'token']
|
||||
export const DEFAULT_TENANT_ID = 10049
|
||||
export const TOKEN_HEADER_NAME = 'Authorization'
|
||||
export const LOGIN_PAGE_URL = '/pages/login/index'
|
||||
|
||||
export function getToken() {
|
||||
for (let index = 0; index < TOKEN_STORAGE_KEYS.length; index += 1) {
|
||||
const value = uni.getStorageSync(TOKEN_STORAGE_KEYS[index])
|
||||
if (value) {
|
||||
return value
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
export function hasToken() {
|
||||
return !!getToken()
|
||||
}
|
||||
|
||||
export function clearAuthStorage() {
|
||||
TOKEN_STORAGE_KEYS.forEach((key) => {
|
||||
try {
|
||||
uni.removeStorageSync(key)
|
||||
} catch (error) {}
|
||||
})
|
||||
try {
|
||||
uni.removeStorageSync('user_info')
|
||||
} catch (error) {}
|
||||
}
|
||||
|
||||
export function setAuthInfo(loginResult) {
|
||||
const result = loginResult || {}
|
||||
const token = result.access_token || result.accessToken || result.token || ''
|
||||
const user = result.user || {}
|
||||
if (token) {
|
||||
uni.setStorageSync('access_token', token)
|
||||
uni.setStorageSync('Authorization', token)
|
||||
uni.setStorageSync('token', token)
|
||||
}
|
||||
uni.setStorageSync('user_info', user)
|
||||
return {
|
||||
token,
|
||||
user
|
||||
}
|
||||
}
|
||||
|
||||
export function getStoredUserInfo() {
|
||||
return uni.getStorageSync('user_info') || {}
|
||||
}
|
||||
|
||||
export function redirectToLogin(redirectUrl) {
|
||||
const query = redirectUrl ? `?redirect=${encodeURIComponent(redirectUrl)}` : ''
|
||||
uni.reLaunch({
|
||||
url: `${LOGIN_PAGE_URL}${query}`
|
||||
})
|
||||
}
|
||||
|
||||
export function ensureLoggedIn(options = {}) {
|
||||
const { redirectUrl } = options
|
||||
if (hasToken()) {
|
||||
return true
|
||||
}
|
||||
redirectToLogin(redirectUrl)
|
||||
return false
|
||||
}
|
||||
|
||||
export function request({ url, method = 'GET', data, header = {}, auth = true }) {
|
||||
const token = getToken()
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url: /^https?:\/\//.test(url) ? url : `${API_BASE_URL}${url}`,
|
||||
method,
|
||||
data,
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
...(auth && token ? { [TOKEN_HEADER_NAME]: token } : {}),
|
||||
...header
|
||||
},
|
||||
success: (response) => {
|
||||
const responseHeader = (response && response.header) || {}
|
||||
const nextToken =
|
||||
responseHeader[TOKEN_HEADER_NAME] ||
|
||||
responseHeader[TOKEN_HEADER_NAME.toLowerCase()]
|
||||
if (nextToken) {
|
||||
uni.setStorageSync('access_token', nextToken)
|
||||
uni.setStorageSync('Authorization', nextToken)
|
||||
uni.setStorageSync('token', nextToken)
|
||||
}
|
||||
const body = (response && response.data) || {}
|
||||
const code = Number(body.code)
|
||||
if (code === 0 || code === 200) {
|
||||
resolve(body.data !== undefined ? body.data : body)
|
||||
return
|
||||
}
|
||||
if (code === 401) {
|
||||
clearAuthStorage()
|
||||
}
|
||||
reject(new Error(body.message || '请求失败'))
|
||||
},
|
||||
fail: (error) => {
|
||||
reject(new Error((error && error.errMsg) || '网络请求失败'))
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function get(url, data, options = {}) {
|
||||
return request({
|
||||
url,
|
||||
method: 'GET',
|
||||
data,
|
||||
...options
|
||||
})
|
||||
}
|
||||
|
||||
export function post(url, data, options = {}) {
|
||||
return request({
|
||||
url,
|
||||
method: 'POST',
|
||||
data,
|
||||
...options
|
||||
})
|
||||
}
|
||||
|
||||
export function put(url, data, options = {}) {
|
||||
return request({
|
||||
url,
|
||||
method: 'PUT',
|
||||
data,
|
||||
...options
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user