| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879 |
- import { createRouter, createWebHistory } from 'vue-router'
- import axios from '@/axios'
- import { requestSignature, wxReady } from '@/router/initWxSdk'
- import { ref } from 'vue';
- import { showFailToast } from 'vant';
-
- const router = createRouter({
- history: createWebHistory('/sgsafeh5/'),
- routes: [
- {
- path: '/login',
- name: 'Login',
- component: () => import('@/view/login/index.vue'),
- meta: { requiresAuth: false }
- },
- {
- path: '/login401',
- name: 'login401',
- component: () => import('@/view/login/index401.vue'),
- meta: { requiresAuth: false }
- },
- {
- path: '/Home1',
- component: () => import('@/view/Home1.vue'),
- meta: { requiresAuth: true }
- },
- {
- path: '/',
- redirect: '/Home1'
- },
- {
- path: '/error',
- name: 'error',
- component: () => import('@/view/biz/error/index.vue'),
- meta: { requiresAuth: false }
- },
- {
- path: '/biz/bas/basPartnerH5',
- name: 'basPartnerH5',
- component: () => import('@/view/biz/bas/basPartnerH5.vue'),
- meta: { requiresAuth: false }
- },
- {
- path: '/biz/cot/purContract',
- name: 'purContract',
- component: () => import('@/view/biz/cot/purContract.vue'),
- meta: { requiresAuth: false }
- },
- {
- path: '/biz/cot/salContract',
- name: 'salContract',
- component: () => import('@/view/biz/cot/salContract.vue'),
- meta: { requiresAuth: false }
- },
- {
- path: '/biz/cot/serviceContract',
- name: 'serviceContract',
- component: () => import('@/view/biz/cot/serviceContract.vue'),
- meta: { requiresAuth: false }
- },
- {
- path: '/biz/cot/signRequest',
- name: 'signRequest',
- component: () => import('@/view/biz/cot/signRequest.vue'),
- meta: { requiresAuth: false }
- },
- {
- path: '/biz/pur/purActFinance',
- name: 'purActFinance',
- component: () => import('@/view/biz/pur/purActFinance.vue'),
- meta: { requiresAuth: false }
- },
- {
- path: '/biz/pur/purBillFinance',
- name: 'purBillFinance',
- component: () => import('@/view/biz/pur/purBillFinance.vue'),
- meta: { requiresAuth: false }
- },
- {
- path: '/biz/pur/purPayReqFinance',
- name: 'purPayReqFinance',
- component: () => import('@/view/biz/pur/purPayReqFinance.vue'),
- meta: { requiresAuth: false }
- },
- {
- path: '/biz/pur/purPayRefundFinance',
- name: 'purPayRefundFinance',
- component: () => import('@/view/biz/pur/purPayRefundFinance.vue'),
- meta: { requiresAuth: false }
- },
- {
- path: '/biz/sal/collectionInfoH5',
- name: 'collectionInfoH5',
- component: () => import('@/view/biz/sal/collectionInfoH5.vue'),
- meta: { requiresAuth: false }
- },
- {
- path: '/biz/sal/salPlanH5',
- name: 'salPlanH5',
- component: () => import('@/view/biz/sal/salPlanH5.vue'),
- meta: { requiresAuth: false }
- },
- {
- path: '/biz/sal/salResultH5',
- name: 'salResultH5',
- component: () => import('@/view/biz/sal/salResultH5.vue'),
- meta: { requiresAuth: false }
- },
- {
- path: '/biz/sal/salRetreatH5',
- name: 'salRetreatH5',
- component: () => import('@/view/biz/sal/salRetreatH5.vue'),
- meta: { requiresAuth: false }
- },
- {
- path: '/biz/sal/salUpriceH5',
- name: 'salUpriceH5',
- component: () => import('@/view/biz/sal/salUpriceH5.vue'),
- meta: { requiresAuth: false }
- },
- {
- path: "/yinhuan/home",
- name: "yinhuanHome",
- component: () => import("@/view/yinhuan/home.vue"),
- },
- {
- path: "/projectManage/todo_detail/index",
- name: "projectWorkTodoDetail",
- component: () => import("@/view/projectManage/todo_detail/index.vue"),
- },
- {
- path: "/projectManage/todo_detail/index2",
- name: "projectWorkTodoDetail2",
- component: () => import("@/view/projectManage/todo_detail/index2.vue"),
- },
- {
- path: "/yinhuan/todo_detail/index",
- name: "yinhuanTodoDetail",
- component: () => import("@/view/yinhuan/todo_detail/index.vue"),
- },
- {
- path: "/yinhuan/JuBaotodo_detail/index",
- name: "yinhuanJuBaoTodoDetail",
- component: () => import("@/view/yinhuan/JuBaotodo_detail/index.vue"),
- },
- {
- path: "/yinhuan/registration",
- name: "yinhuanRegistration",
- component: () => import("@/view/yinhuan/registration.vue"),
- },
- {
- path: "/yinhuan/hdRwardReporting",
- name: "yinhuanhdRwardReporting",
- component: () => import("@/view/yinhuan/hdRwardReporting.vue"),
- },
- {
- path: "/yinhuan/registration_edit/index",
- name: "registration_edit",
- component: () => import("@/view/yinhuan/registration_edit/index.vue"),
- },
- {
- path: "/yinhuan/JuBaoregistration_edit/index",
- name: "JuBaoregistration_edit",
- component: () => import("@/view/yinhuan/JuBaoregistration_edit/index.vue"),
- },
- {
- path: "/yinhuan/JuBaoregistration_edit/index",
- name: "JuBaoregistration_edit",
- component: () => import("@/view/yinhuan/JuBaoregistration_edit/index.vue"),
- },
- {
- path: "/yinhuan/hdLedger",
- name: "yinhuanHdLedger",
- component: () => import("@/view/yinhuan/hdLedger.vue"),
- },
- {
- path: "/yinhuan/hdLedgerJuBao",
- name: "yinhuanHdLedgerJuBao",
- component: () => import("@/view/yinhuan/hdLedgerJuBao.vue"),
- },
- {
- path: "/yinhuan/hdLedger_detail",
- name: "yinhuanHdLedgerDtail",
- component: () => import("@/view/yinhuan/heLedger_detail/index.vue"),
- },
- {
- path: "/yinhuan/JuBaohdLedger_detail",
- name: "yinhuanJuBaoHdLedgerDtail",
- component: () => import("@/view/yinhuan/JuBaoheLedger_detail/index.vue"),
- },
- {
- path: "/yinhuan/todo",
- name: "yinhuanTodo",
- component: () => import("@/view/yinhuan/todo.vue"),
- },
- {
- path: "/projectManage/todo",
- name: "projectManagetodo",
- component: () => import("@/view/projectManage/todo.vue"),
- },
- {
- path: "/safeCheck/home",
- name: "checkHome",
- component: () => import("@/view/safeCheck/home.vue"),
- },
- {
- path: "/safeCheck/task",
- name: "safeCheckTask",
- component: () => import("@/view/safeCheck/safeCheckTask.vue"),
- },
- {
- path: "/safeCheck/safeCheckTaskEdit",
- name: "safeCheckTaskEdit",
- component: () => import("@/view/safeCheck/safeCheck_edit/index.vue"),
- },
- {
- path: "/safeCheck/safeCheckTaskItem",
- name: "safeCheckTaskItem",
- component: () => import("@/view/safeCheck/safeCheck_item/index.vue"),
- },
- {
- path: "/projectManage/projectIndex",
- name: "projectIndex",
- component: () => import("@/view/projectManage/projectIndex.vue"),
- },
- {
- path: "/projectManage/projectWorkLedger",
- name: "projectWorkLedger",
- component: () => import("@/view/projectManage/projectWorkLedger.vue"),
- },
- {
- path: "/projectManage/taiZhang",
- name: "taiZhang",
- component: () => import("@/view/projectManage/taiZhangV3.vue"),
- },
- {
- path: "/projectManage/taiZhang_detail",
- name: "taiZhang_detail",
- component: () => import("@/view/projectManage/taiZhang_detail/index.vue"),
- },
- {
- path: "/projectManage/taiZhang_edit",
- name: "taiZhang_indexEdit",
- component: () => import("@/view/projectManage/taiZhang_edit/indexEdit.vue"),
- },
- {
- path: "/projectManage/taiZhang_edit",
- name: "taiZhang_edit",
- component: () => import("@/view/projectManage/taiZhang_edit/index.vue"),
- },
- {
- path: "/projectManage/projectConstructionOperation",
- name: "projectConstructionOperation",
- component: () => import("@/view/projectManage/projectConstructionOperation/index.vue"),
- },
- {
- path: "/projectManage/projectConstructionOperation/projectConstructionOperation_detail",
- name: "projectConstructionOperation_detail",
- component: () => import("@/view/projectManage/projectConstructionOperation/projectConstructionOperation_detail/index.vue"),
- },
- {
- path: "/projectManage/projectConstructionOperation/projectConstructionOperation_detail2",
- name: "projectConstructionOperation_detail2",
- component: () => import("@/view/projectManage/projectConstructionOperation/projectConstructionOperation_detail/indexLook.vue"),
- },
- {
- path: "/projectManage/projectConstructionOperation/projectConstructionOperation_detail3",
- name: "projectConstructionOperation_detail3",
- component: () => import("@/view/projectManage/projectConstructionOperation/projectConstructionOperation_detail/indexLookAll.vue"),
- },
- {
- path: "/lvzhi",
- component: () => import("@/view/lvzhi/dutyList.vue"),
- },
- {
- path: "/lvzhicx",
- component: () => import("@/view/lvzhi/listCx.vue"),
- },
- {
- path: "/lz-rcdcx",
- component: () => import("@/view/lvzhi/dutyRecordListCx.vue"),
- },
- {
- path: "/lz-rcd",
- component: () => import("@/view/lvzhi/dutyRecordList.vue"),
- },
- {
- path: "/lz-rcd-detail",
- component: () => import("@/view/lvzhi/newDutyRecord.vue"),
- },
- {
- path: '/institution/law',
- name: 'Law',
- component: () => import("@/view/institution/law.vue")
- },
- {
- path: '/institution/institutionRegime',
- name: 'InstitutionRegime',
- component: () => import("@/view/institution/institutionRegime.vue")
- },
- {
- path: '/institution/institutionRule',
- name: 'InstitutionRule',
- component: () => import("@/view/institution/institutionRule.vue")
- },
- {
- path: '/institution/riskList',
- name: 'RiskList',
- component: () => import("@/view/institution/riskList.vue")
- },
- {
- path: '/institution/emergencyPlan',
- name: 'EmergencyPlan',
- component: () => import("@/view/institution/emergencyPlan.vue")
- },
- {
- path: '/emergencyResources',
- name: 'EmergencyResources',
- component: () => import("@/view/resources/index.vue")
- },
- {
- path: '/resourcesQuery',
- name: 'ResourcesQuery',
- component: () => import("@/view/resources/resourcesQuery.vue")
- },
- {
- path: '/maintenanceRecords',
- name: 'MaintenanceRecords',
- component: () => import("@/view/resources/maintenanceRecords.vue")
- },
- {
- path: '/recordsQuery',
- name: 'RecordsQuery',
- component: () => import("@/view/resources/recordsQuery.vue")
- },
- {
- path: '/cardManager',
- name: 'CardManager',
- component: () => import("@/view/card/index.vue")
- },
- {
- path: '/cardManager/specialWork',
- name: 'SpecialWork',
- component: () => import("@/view/card/CardSpecialWork.vue")
- },
- {
- path: '/cardManager/equipment',
- name: 'Equipment',
- component: () => import("@/view/card/CardEquipment.vue")
- },
- {
- path: '/cardManager/engineer',
- name: 'Card',
- component: () => import("@/view/card/CardEngineer.vue")
- },
- {
- path: '/cardManager/building',
- name: 'Building',
- component: () => import("@/view/card/CardBuilding.vue")
- },
- {
- path: '/cardManager/manager',
- name: 'Manager',
- component: () => import("@/view/card/CardManager.vue")
- },
- {
- path: '/emergencyDrillPlan',
- name: 'EmergencyDrillPlan',
- component: () => import("@/view/drillPlan/index.vue")
- },
- {
- path: '/emergencyDrillPlanEdit',
- name: 'EmergencyDrillPlanEdit',
- component: () => import("@/view/drillPlan/drillPlanEdit.vue")
- },
- {
- path: '/emergencyDrillActEdit',
- name: 'EmergencyDrillActEdit',
- component: () => import("@/view/drillPlan/drillActEdit.vue")
- },
- {
- path: '/checkTake',
- name: '逢查必考',
- component: () => import("@/view/dati/checkTake/index.vue")
- },
- {
- path: '/examtask',
- name: '考试任务',
- component: () => import("@/view/dati/examCheck/index.vue")
- },
- {
- path: '/checkList',
- name: '考试任务表单',
- component: () => import("@/view/dati/examCheck/checkList.vue")
- },
-
- {
- path: '/addPeo',
- name: '考试人员添加',
- component: () => import("@/view/dati/examCheck/addPeo.vue")
- },
- {
- path: '/dailyproblem',
- name: 'DailyProblem',
- component: () => import("@/view/dati/daily/index.vue")
- },
- {
- path: '/jieguo1',
- name: 'JieGuo1',
- component: () => import("@/view/dati/checkTake/jieguo1.vue")
- },
- {
- path: '/jieguo2',
- name: 'JieGuo2',
- component: () => import("@/view/dati/checkTake/jieguo2.vue")
- },
- {
- path: '/datistart',
- name: 'DatiStart',
- component: () => import("@/view/dati/daily/datistart.vue")
- },
- {
- path: '/jieguo',
- name: 'JieGuo',
- component: () => import("@/view/dati/daily/jieguo.vue")
- },
- {
- path: '/paiming',
- name: 'PaiMing',
- component: () => import("@/view/dati/daily/paiming.vue")
- },
- {
- path: '/home2',
- name: 'Home2',
- component: () => import("@/view/Home2.vue")
- },
- {
- path: '/homeRole',
- name: 'HomeRole',
- component: () => import("@/view/HomeRole.vue")
- },
- {
- path: '/oldHome',
- name: 'OldHome',
- component: () => import("@/view/Home.vue")
- },
- {
- path: '/pendingMatters',
- name: 'PendingMatters',
- component: () => import("@/view/pendingMatters/index.vue")
- },
- {
- path: '/safeClient',
- name: 'SafeClient',
- component: () => import("@/view/onsiteProcessControl/safeClient.vue")
- },
- {
- path: '/jobCondition',
- name: 'JobCondition',
- component: () => import("@/view/onsiteProcessControl/jobCondition.vue")
- },
- {
- path: '/yinhuan/riskChecklist',
- name: 'RiskChecklist',
- component: () => import("@/view/yinhuan/riskChecklist.vue")
- },
- {
- path: '/yinhuan/riskChecklistView',
- name: 'RiskChecklistView',
- component: () => import("@/view/yinhuan/riskChecklistView.vue")
- },
- {
- path: '/yinhuan/riskChecklistRecords',
- name: 'RiskChecklistRecords',
- component: () => import("@/view/yinhuan/riskChecklistRecords.vue")
- },
- {
- path: '/yinhuan/riskChecklistRecordsView',
- name: 'RiskChecklistRecordsView',
- component: () => import("@/view/yinhuan/riskChecklistRecordsView.vue")
- },
- {
- path: '/drillProcess',
- name: 'DrillProcess',
- component: () => import("@/view/drillPlan/drillProcess.vue")
- },
- {
- path: '/specificSteps',
- name: 'SpecificSteps',
- component: () => import("@/view/drillPlan/specificSteps.vue")
- },
- {
- path: '/specificStepsView',
- name: '/SpecificStepsView',
- component: () => import("@/view/drillPlan/specificStepsView.vue")
- },
- {
- path: '/assRec',
- name: '/考核登记首页',
- component: () => import("@/view/performance/assRec.vue")
- },
- {
- path: '/asscheckList',
- name: '/考核登记新增',
- component: () => import("@/view/performance/checkList.vue")
- },
- {
- path: '/assRecN',
- name: '/考核记录',
- component: () => import("@/view/performance/assRecN.vue")
- },
- {
- path: '/learning',
- name: 'Learning',
- component: () => import('@/view/performance/learning.vue')
- },
- {
- path: '/annex',
- name: '文件发布',
- component: () => import('@/view/announ/annex.vue')
- },
- {
- path: '/annexList',
- name: '文件发布新增',
- component: () => import('@/view/announ/annexList.vue')
- },
- {
- path: '/notice',
- name: '通知公告',
- component: () => import('@/view/announ/notice.vue')
- },
- {
- path: '/noticeList',
- name: '通知公告新增',
- component: () => import('@/view/announ/noticeList.vue')
- },
- {
- path: '/keyMatters',
- name: '重点事项',
- component: () => import('@/view/keyMatters/index.vue')
- },
- {
- path: '/keyMatters/view',
- name: '重点事项查看',
- component: () => import('@/view/keyMatters/view.vue')
- },
- {
- path: '/keyMatters/report',
- name: '重点事项汇报',
- component: () => import('@/view/keyMatters/report.vue')
- },
- {
- path: '/planManagement',
- name: '计划管理',
- component: () => import('@/view/planManagement/index.vue')
- },
- {
- path: '/planManagement/manifest',
- name: '任务清单',
- component: () => import('@/view/planManagement/manifest.vue')
- },
- {
- path: '/planManagement/manifestView',
- name: '任务清单查看',
- component: () => import('@/view/planManagement/manifestView.vue')
- },
- {
- path: '/planManagement/manifestReport',
- name: '任务清单汇报',
- component: () => import('@/view/planManagement/manifestReport.vue')
- },
- {
- path: '/performanceReview/units',
- name: '单位绩效评估',
- component: () => import('@/view/performanceReview/units.vue')
- },
- {
- path: '/accidentManager/accidentBaoGaoLedger/index',
- name: 'accidentBaoGaoLedger',
- component: () => import('@/view/accidentManager/accidentBaoGaoLedger/index.vue')
- },
- {
- path: '/accidentManager/accidentJuBao/index',
- name: 'accidentJuBao',
- component: () => import('@/view/accidentManager/accidentJuBao/index.vue')
- },
- {
- path: '/accidentManager/accidentBaoGaoLedger/accidentBaoGaoLedger_edit/index',
- name: 'accidentBaoGaoLedger_edit',
- component: () => import('@/view/accidentManager/accidentBaoGaoLedger/accidentBaoGaoLedger_edit/index.vue')
- },
- {
- path: '/accidentManager/accidentJuBao/accidentJuBao_edit/index',
- name: 'accidentJuBao_edit',
- component: () => import('@/view/accidentManager/accidentJuBao/accidentJuBao_edit/index.vue')
- },
- {
- path: '/accidentManager/accidentJuBaoLedger/index',
- name: 'accidentJuBaoLedger',
- component: () => import('@/view/accidentManager/accidentJuBaoLedger/index.vue')
- },
- {
- path: '/knowledge/accident',
- name: '事故案例',
- component: () => import('@/view/knowledge/accident.vue')
- },
- {
- path: '/accidentList',
- name: '事故案例编辑',
- component: () => import('@/view/knowledge/accidentList.vue')
- },
- {
- path: '/knowledge/manager',
- name: '管理案例',
- component: () => import('@/view/knowledge/manager.vue')
- },
- {
- path: '/managerList',
- name: '管理案例编辑',
- component: () => import('@/view/knowledge/managerList.vue')
- },
- {
- path: '/knowledge/Culture',
- name: '安全文化',
- component: () => import('@/view/knowledge/Culture.vue')
- },
- {
- path: '/CultureList',
- name: '安全文化编辑',
- component: () => import('@/view/knowledge/CultureList.vue')
- },
- {
- path: '/knowledge/project',
- name: '项目案例库',
- component: () => import('@/view/knowledge/project.vue')
- },
- {
- path: '/projectList',
- name: '项目案例库编辑',
- component: () => import('@/view/knowledge/projectList.vue')
- },
- {
- path: '/moneySafe/safeMoneyManagement',
- name: '安环费用管理',
- component: () => import('@/view/moneySafe/safeMoneyManagement.vue')
- },
- {
- path: '/safeMoneyManagementList',
- name: '安环费用管理编辑',
- component: () => import('@/view/moneySafe/safeMoneyManagementList.vue')
- },
- {
- path: '/moneySafe/safeMoneyBudget',
- name: '安全费用预算',
- component: () => import('@/view/moneySafe/safeMoneyBudget.vue')
- },
- {
- path: '/safeMoneyBudgetList',
- name: '安全费用预算编辑',
- component: () => import('@/view/moneySafe/safeMoneyBudgetList.vue')
- },
- {
- path: '/class2',
- name: '学习课程库',
- component: () => import("@/view/dati/classOne/class2.vue")
- },
- {
- path: '/courseManagement',
- name: '课程管理',
- component: () => import('@/view/dati/courseManagement/courseManagement.vue')
- },
- {
- path: '/courseManagementList',
- name: '课程管理编辑',
- component: () => import('@/view/dati/courseManagement/courseManagementList.vue')
- },
- {
- path: '/courseAddPeo',
- name: '课程添加人员',
- component: () => import('@/view/dati/courseManagement/addPeo.vue')
- },
- {
- path: '/section',
- name: '课程添加小节',
- component: () => import('@/view/dati/courseManagement/section.vue')
- },
- {
- path: '/sectionList',
- name: '人员小节',
- component: () => import('@/view/dati/classOne/sectionList.vue')
- },
- {
- path: '/line',
- name: '人员小节答题',
- component: () => import('@/view/dati/classOne/line.vue')
- },
- {
- path: '/learning1',
- name: '人员学习',
- component: () => import('@/view/dati/classOne/learning.vue')
- },
- {
- path: '/fcbkdatistart',
- name: '逢查必考跳转答题',
- component: () => import('@/view/dati/examCheck/fcbkdatistart.vue')
- },
-
-
- ]
- })
-
- // 路由守卫
- router.beforeEach(async (to, from, next) => {
-
- /*
- const requiresWeCom = to.matched.some(record => record.meta.requiresWeCom);
-
- if (requiresWeCom && typeof wx === 'undefined') {
- console.warn('该页面需在企业微信内打开');
- // 可以跳转提示页或者 Toast 提示
- return next(false);
- }
-
- wxReady((requestSignature().data))
- */
- function isTokenValid(token : string) : boolean {
- try {
- // 检查 token 是否为合法 JWT 格式(3段)
- const parts = token.split('.');
- if (parts.length !== 3) {
- return false;
- }
-
- // 解码 payload 部分
- const payloadStr = atob(parts[1]);
- const payload = JSON.parse(payloadStr);
-
- // 检查是否有 exp 字段
- if (!payload.exp) {
- return false;
- }
-
- // 判断是否过期(exp 是秒级时间戳)
- const expTime = payload.exp * 1000;
- return Date.now() <= expTime; // ✅ 没过期就返回 true
- } catch (error) {
- console.error('Token 解析失败:', error);
- return false; // 出错也认为无效
- }
- }
- const getDeptPost = () => {
- var url = 'framework/SysDepartment/queryDeptPostByUserId'
- var param = {
-
- }
- axios.get(url, param).then(response => {
- if (response.data.code == 0) {
- // this.$store.commit('setPost', response.data.data.post)
- // this.$store.commit('setDept', response.data.data.dept)
- localStorage.setItem('post', JSON.stringify(response.data.data.post))
- localStorage.setItem('dept', JSON.stringify(response.data.data.dept))
- localStorage.setItem('role', JSON.stringify(response.data.data.role))
- localStorage.setItem('deptTree', JSON.stringify(response.data.data.deptTree))
- } else {
- localStorage.setItem('post', JSON.stringify([]))
- localStorage.setItem('dept', JSON.stringify([]))
- localStorage.setItem('role', JSON.stringify([]))
- localStorage.setItem('deptTree', JSON.stringify([]))
- }
-
- })
- }
-
- //const tableDataUserId=ref({})
- const getTableDataCode = async (userID : string) : Promise<any> => {
- const url = '/framework/SysUser/queryByCode';
- const param = { userCode: userID };
-
- const response = await axios.get(url, param);
-
- if (response.data.code === '0') {
- return response.data.data; // 这个 return 是给 async 函数的
- }
-
- return null; // 或者抛出错误,根据你的业务需求
- }
- console.log(to);
- if (to.path == '/Home1'||to.path=='/yinhuan/todo_detail/index'|| to.path == '/lz-rcd-detail'||to.path == '/emergencyResources'||to.path == '/cardManager/specialWork'||to.path == '/cardManager/equipment'||to.path == '/cardManager/engineer') {
-
- /*const token = localStorage.getItem('token');
- // 判断是否已经初始化过用户信息
- const hasUserInfo = !!localStorage.getItem('userId');
- if (hasUserInfo) {
- // @ts-ignore
- if (token && isTokenValid(token)) {
- next();
- return;
- }
- }*/
-
- // const userId=ref('3E4C4009430211B28E367D90704E23CA')
-
- const userId=ref(import.meta.env.VITE_USER_ID)
- console.log(userId.value);
- console.log("当前环境:");
- console.log(import.meta.env.MODE);
- if (import.meta.env.MODE == 'production') {
- // console.log('当前版本:', import.meta.env.VITE_APP_VERSION);
- const signRes = await requestSignature();
- const userInfo = await wxReady(signRes.data)
- console.log("获取到的用户信息userInfo为:");
- console.log(userInfo);
- console.log("userInfo的userId为:");
- console.log(userInfo.userID);
- //const userData = await getTableDataCode(userInfo.userID)
- userId.value = userInfo.userID
- console.log("userData的userId为:");
- console.log(userId.value);
- if (!userInfo) {
- if (window.history.length > 1) {
- showFailToast("获取信息失败,请联系管理员")
- window.history.back();
- } else {
- // 如果没有历史记录,跳转到首页或其他页面
- router.push('/login');
- }
- }
- }
- // userId.value='S56077'
-
- //http://localhost:4200/workflow?userId=2&flowId=100&workId=HZ289fc39448dafa0194492f66c80125
- var url = 'framework/SysLogin/queryPublicKeyToken'
- // var url = 'framework/SysLogin/queryPublicKey'
- var param = {
- param: userId.value
- }
-
- await axios.post(url, param).then(response => {
-
- localStorage.setItem('publicKey', response.data.data.publicKey)
- localStorage.setItem('userId', response.data.data.id)
- localStorage.setItem('userCode', response.data.data.userCode)
- localStorage.setItem('userName', response.data.data.userName)
- localStorage.setItem('userDesc', response.data.data.userDesc)
- localStorage.setItem('userType', response.data.data.userType)
- localStorage.setItem('token', response.data.data.token)
- localStorage.setItem('belongId', response.data.data.belongId)
-
- localStorage.setItem('applications', JSON.stringify(response.data.data
- .applications))
- localStorage.setItem('application', JSON.stringify(response.data.data.applications[
- 0]))
- sessionStorage.setItem('workflowQuery', JSON.stringify({
- flowId: to.query.flowId,
- workId: to.query.workId,
- trackId: to.query.trackId,
- date: new Date().getTime()
- }))
- })
- getDeptPost()
- next()
- } else {
- next()
- }
-
-
-
- const token = localStorage.getItem('token')
-
- /* if (to.meta.requiresAuth && !token) {
- next('/login')
- } else if (to.path === '/login' && token) {
- next('/Home')
- } else {
- next()
- }*/
- })
-
- export default router
|