From ae4aede94d29bb23ba67f4525898de89c7dc47f7 Mon Sep 17 00:00:00 2001 From: 18154758993 <605281283@qq.com> Date: Fri, 13 Mar 2026 14:32:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4-3-13?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 136 +++++-- api/inspection/abnormal.js | 44 +++ api/login.js | 39 ++ config.js | 33 +- manifest.json | 3 +- pages.json | 75 +++- pages/cas/callback.vue | 42 ++ pages/index.vue | 2 +- pages/login.vue | 319 ++++++++-------- pages/mine/about/index.vue | 6 +- pages/mine/help/index.vue | 16 +- pages/mine/index.vue | 20 +- pages/work/index.vue | 21 +- .../work/inspection/abnormalDetail/index.vue | 101 +++++ pages/work/inspection/abnormalList/index.vue | 188 +++++++++ pages/work/inspection/checkInDetail/index.vue | 96 +++++ pages/work/inspection/checkInRecord/index.vue | 359 +++++++++++++----- .../work/inspection/checkInUserList/index.vue | 171 +++++++++ pages/work/inspection/inspectionEx/index.vue | 7 +- pages/work/inspection/recordList/index.vue | 295 ++++++++++++++ pages/work/inspection/scanSign/index.vue | 74 ++-- pages/work/sidebar/filingDetail/index.vue | 319 ++++++++++++++++ pages/work/sidebar/filingLog/index.vue | 359 +++++++++++------- pages/work/sidebar/safetyDeclaratio/index.vue | 16 +- permission.js | 2 +- store/modules/user.js | 53 ++- utils/request.js | 6 +- 27 files changed, 2285 insertions(+), 517 deletions(-) create mode 100644 api/inspection/abnormal.js create mode 100644 pages/cas/callback.vue create mode 100644 pages/work/inspection/abnormalDetail/index.vue create mode 100644 pages/work/inspection/abnormalList/index.vue create mode 100644 pages/work/inspection/checkInDetail/index.vue create mode 100644 pages/work/inspection/checkInUserList/index.vue create mode 100644 pages/work/inspection/recordList/index.vue create mode 100644 pages/work/sidebar/filingDetail/index.vue diff --git a/App.vue b/App.vue index f6a2124..c5c4aac 100644 --- a/App.vue +++ b/App.vue @@ -1,39 +1,119 @@ diff --git a/api/inspection/abnormal.js b/api/inspection/abnormal.js new file mode 100644 index 0000000..d738229 --- /dev/null +++ b/api/inspection/abnormal.js @@ -0,0 +1,44 @@ +import request from '@/utils/request' + +// 查询巡检异常列表 +export function listAbnormal(query) { + return request({ + url: '/inspection/abnormal/list', + method: 'get', + params: query + }) +} + +// 查询巡检异常详细 +export function getAbnormal(id) { + return request({ + url: '/inspection/abnormal/' + id, + method: 'get' + }) +} + +// 新增巡检异常 +export function addAbnormal(data) { + return request({ + url: '/inspection/abnormal', + method: 'post', + data: data + }) +} + +// 修改巡检异常 +export function updateAbnormal(data) { + return request({ + url: '/inspection/abnormal', + method: 'put', + data: data + }) +} + +// 删除巡检异常 +export function delAbnormal(id) { + return request({ + url: '/inspection/abnormal/' + id, + method: 'delete' + }) +} \ No newline at end of file diff --git a/api/login.js b/api/login.js index 035da07..2b8efdb 100644 --- a/api/login.js +++ b/api/login.js @@ -65,4 +65,43 @@ export const getRouters = () => { url: '/getRouters', method: 'get' }) +} + +// CAS 登录方法(通过请求参数传递 ticket 与 service) +export function casLogin(ticket, service) { + return request({ + url: '/cas/login', + headers: { + isToken: false + }, + method: 'post', + // 后端使用 @RequestParam 接收参数 + params: { ticket, service } + }) +} + +// 移动端CAS登录方法 +export function casAppLogin(ticket) { + return request({ + url: '/cas/app/login', + headers: { + isToken: false + }, + method: 'post', + // 后端使用 @RequestParam 接收参数 + params: { ticket } + }) +} + +// 统一CAS登录方法 +export function casUnifiedLogin(ticket) { + return request({ + url: '/cas/unified/login', + headers: { + isToken: false + }, + method: 'post', + // 后端使用 @RequestParam 接收参数 + params: { ticket } + }) } \ No newline at end of file diff --git a/config.js b/config.js index 2da84e3..43fb2e8 100644 --- a/config.js +++ b/config.js @@ -1,9 +1,22 @@ // 应用全局配置 module.exports = { // baseUrl: 'http://172.16.129.101:8080/dev-api/', - baseUrl: 'https://pasd.gxsdxy.cn/prod-api/', + // baseUrl: 'https://pasd.gxsdxy.cn/prod-api/', // baseUrl: 'http://172.16.129.101:8080',//172.16.129.101 - // baseUrl: 'https://192.168.211.59:8080/', + // baseUrl: 'http://localhost:8080', + // 生产环境:通过 Nginx /prod-api 代理到后端 + baseUrl: 'https://pasd.gxsdxy.cn/prod-api', + // 是否启用 CAS 登录(与系统账号登录并存,H5 自动跳转) + // 发布 CAS 端:开启 + casEnable: true, + // CAS 服务端登录地址(示例为统一认证平台登录地址) + casServer: 'https://rsso.gxsdxy.cn/login', + // PC 端 + casService: 'https://pasd.gxsdxy.cn/cas', + + // 移动端(关键) - 现在统一使用相同的回调地址,由后端处理设备检测 + casServiceMobile: 'https://pasd.gxsdxy.cn/cas', + // 应用信息 appInfo: { // 应用名称 @@ -16,13 +29,13 @@ module.exports = { site_url: "http://pasd.gxsdxy.cn", // 政策协议 agreements: [{ - title: "隐私政策", - url: "http://pasd.gxsdxy.cn/protocol.html" - }, - { - title: "用户服务协议", - url: "http://pasd.gxsdxy.cn/protocol.html" - } + title: "隐私政策", + url: "http://pasd.gxsdxy.cn/protocol.html" + }, + { + title: "用户服务协议", + url: "http://pasd.gxsdxy.cn/protocol.html" + } ] } -} \ No newline at end of file +} diff --git a/manifest.json b/manifest.json index d175ed9..d324b7a 100644 --- a/manifest.json +++ b/manifest.json @@ -88,6 +88,7 @@ "router" : { "mode" : "hash", "base" : "./" - } + }, + "publicPath": "./" } } diff --git a/pages.json b/pages.json index 243877c..0233980 100644 --- a/pages.json +++ b/pages.json @@ -4,6 +4,12 @@ "style": { "navigationBarTitleText": "登录" } + }, { + "path": "pages/cas/callback", + "style": { + "navigationBarTitleText": "CAS回调", + "navigationStyle": "custom" + } }, { "path": "pages/register", "style": { @@ -79,7 +85,7 @@ "style": { "navigationBarTitleText": "申报记录", "navigationBarTextStyle": "white", - "navigationBarBackgroundColor": "#bbbbbb", + "navigationBarBackgroundColor": "#1677ff", "enablePullDownRefresh": true, //配置后,可以下拉刷新,上拉加载` "onReachBottomDistance": 100 } @@ -88,8 +94,16 @@ "path": "pages/work/sidebar/safetyDeclaratio/index", "style": { "navigationBarTextStyle": "white", - "navigationBarBackgroundColor": "#bbbbbb", - "navigationBarTitleText": "隐患申报" + "navigationBarBackgroundColor": "#1677ff", + "navigationBarTitleText": "异常隐患巡检" + } + }, + { + "path": "pages/work/sidebar/filingDetail/index", + "style": { + "navigationBarTextStyle": "white", + "navigationBarBackgroundColor": "#1677ff", + "navigationBarTitleText": "申报详情" } }, { @@ -113,7 +127,7 @@ }, "style": { "navigationBarTextStyle": "white", - "navigationBarBackgroundColor": "#bbbbbb", + "navigationBarBackgroundColor": "#1677ff", "navigationBarTitleText": "扫码签到" } }, @@ -124,7 +138,7 @@ "path": "pages/work/inspection/inspectionEx/index", "style": { "navigationBarTextStyle": "white", - "navigationBarBackgroundColor": "#bbbbbb", + "navigationBarBackgroundColor": "#1677ff", "navigationBarTitleText": "异常巡检" } }, @@ -132,13 +146,60 @@ "app-plus": { "titleNView": false }, + "path": "pages/work/inspection/checkInUserList/index", + "style": { + "navigationBarTitleText": "用户打卡列表", + "navigationBarTextStyle": "white", + "navigationBarBackgroundColor": "#1677ff" + } + }, + { + "app-plus": { "titleNView": false }, "path": "pages/work/inspection/checkInRecord/index", "style": { "navigationBarTextStyle": "white", - "navigationBarBackgroundColor": "#bbbbbb", + "navigationBarBackgroundColor": "#1677ff", "navigationBarTitleText": "打卡记录" + } + }, + { + "app-plus": { + "titleNView": false }, - "usingComponents": true + "path": "pages/work/inspection/abnormalList/index", + "style": { + "navigationBarTextStyle": "white", + "navigationBarTitleText": "巡检异常列表", + "navigationBarBackgroundColor": "#1677ff" + } + }, + { + "app-plus": { + "titleNView": false + }, + "path": "pages/work/inspection/abnormalDetail/index", + "style": { + "navigationBarTextStyle": "white", + "navigationBarTitleText": "异常详情", + "navigationBarBackgroundColor": "#1677ff" + } + }, + { + "path": "pages/work/inspection/checkInDetail/index", + "style": { + "navigationBarTitleText": "打卡详情", + "navigationBarTextStyle": "white", + "navigationBarBackgroundColor": "#1677ff" + } + }, + { + "app-plus": { "titleNView": false }, + "path": "pages/work/inspection/recordList/index", + "style": { + "navigationBarTextStyle": "white", + "navigationBarBackgroundColor": "#1677ff", + "navigationBarTitleText": "巡检记录" + } } ], "tabBar": { diff --git a/pages/cas/callback.vue b/pages/cas/callback.vue new file mode 100644 index 0000000..29be469 --- /dev/null +++ b/pages/cas/callback.vue @@ -0,0 +1,42 @@ + + + + + \ No newline at end of file diff --git a/pages/index.vue b/pages/index.vue index 2048a4c..5e68dbd 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -2,7 +2,7 @@ - Hello RuoYi + 平安水电 diff --git a/pages/login.vue b/pages/login.vue index d3d5523..ef8e4fc 100644 --- a/pages/login.vue +++ b/pages/login.vue @@ -17,7 +17,7 @@ - + @@ -25,179 +25,198 @@ - 没有账号? + 没有账号? 立即注册 登录即代表同意 - 《用户协议》 - 《隐私协议》 + + <用户协议> + + + <隐私协议> + - + diff --git a/pages/mine/about/index.vue b/pages/mine/about/index.vue index d3f6255..1ee85e5 100644 --- a/pages/mine/about/index.vue +++ b/pages/mine/about/index.vue @@ -17,13 +17,13 @@ 官方邮箱 - ruoyi@xx.com + 服务热线 - 400-999-9999 + @@ -38,7 +38,7 @@ - Copyright © 2022 ruoyi.vip All Rights Reserved. + Copyright © 2022 平安水电 All Rights Reserved. diff --git a/pages/mine/help/index.vue b/pages/mine/help/index.vue index d2e4374..4636bc3 100644 --- a/pages/mine/help/index.vue +++ b/pages/mine/help/index.vue @@ -20,21 +20,7 @@ data() { return { list: [{ - icon: 'iconfont icon-github', - title: '若依问题', - childList: [{ - title: '若依开源吗?', - content: '开源' - }, { - title: '若依可以商用吗?', - content: '可以' - }, { - title: '若依官网地址多少?', - content: 'http://ruoyi.vip' - }, { - title: '若依文档地址多少?', - content: 'http://doc.ruoyi.vip' - }] + }, { icon: 'iconfont icon-help', diff --git a/pages/mine/index.vue b/pages/mine/index.vue index b79ed52..9725df8 100644 --- a/pages/mine/index.vue +++ b/pages/mine/index.vue @@ -27,22 +27,6 @@ - - - 交流群 - - - - 在线客服 - - - - 反馈社区 - - - - 点赞我们 - @@ -52,7 +36,7 @@ 编辑资料 - + diff --git a/pages/work/index.vue b/pages/work/index.vue index 82c3953..3d22f9d 100644 --- a/pages/work/index.vue +++ b/pages/work/index.vue @@ -52,7 +52,7 @@ uniGridList: [{ text: '打卡记录', type: "calendar-filled", - ifData: "checkRole(['admin'])" + ifData: false }, { text: '异常巡检', @@ -64,6 +64,11 @@ type: "navigate-filled", ifData: "checkRole(['admin',common])" }, + { + text: '巡检记录', + type: "list", + ifData: "checkRole(['admin'])" + }, // { // text: '申报记录', // type: "list", @@ -105,12 +110,14 @@ if (index == 1) { this.$tab.navigateTo("/pages/work/inspection/checkInRecord/index"); } else if (index == 2) { - this.$tab.navigateTo("/pages/work/inspection/inspectionEx/index"); - } else if (index == 3) { - this.$tab.navigateTo("/pages/work/sidebar/safetyDeclaratio/index"); - } else if (index == 4) { - this.$tab.navigateTo("/pages/work/sidebar/filingLog/index"); - } + this.$tab.navigateTo("/pages/work/inspection/abnormalList/index"); + } else if (index == 3) { + this.$tab.navigateTo("/pages/work/sidebar/filingLog/index"); + } else if (index == 4) { + this.$tab.navigateTo("/pages/work/inspection/recordList/index"); + } else if (index == 5) { + this.$tab.navigateTo("/pages/work/sidebar/filingLog/index"); + } } } diff --git a/pages/work/inspection/abnormalDetail/index.vue b/pages/work/inspection/abnormalDetail/index.vue new file mode 100644 index 0000000..45f23b6 --- /dev/null +++ b/pages/work/inspection/abnormalDetail/index.vue @@ -0,0 +1,101 @@ + + + + + \ No newline at end of file diff --git a/pages/work/inspection/abnormalList/index.vue b/pages/work/inspection/abnormalList/index.vue new file mode 100644 index 0000000..f0e6a9a --- /dev/null +++ b/pages/work/inspection/abnormalList/index.vue @@ -0,0 +1,188 @@ + + + + + \ No newline at end of file diff --git a/pages/work/inspection/checkInDetail/index.vue b/pages/work/inspection/checkInDetail/index.vue new file mode 100644 index 0000000..2a61253 --- /dev/null +++ b/pages/work/inspection/checkInDetail/index.vue @@ -0,0 +1,96 @@ + + + + + \ No newline at end of file diff --git a/pages/work/inspection/checkInRecord/index.vue b/pages/work/inspection/checkInRecord/index.vue index 9599bf5..ad6cae2 100644 --- a/pages/work/inspection/checkInRecord/index.vue +++ b/pages/work/inspection/checkInRecord/index.vue @@ -7,24 +7,84 @@ + + + + 总打卡{{ stats.total }} + 活跃天{{ stats.activeDays }} + 平均/天{{ stats.avgPerDay }} + 最长连打{{ stats.maxStreak }} + + + + + + + + + + + + + + + + + + + + 打卡状态:{{ summary.clockState || '-' }} + + + 最近时间:{{ formatDate(latestRecord.inspectionTime) }} + + + 巡检点:{{ latestRecord.inspectionPoint || '-' }} + + + 巡检人:{{ latestRecord.inspectorUser || '-' }} + + + + + + + + + + + + + + - + + - + + - - 打卡时间:{{item.inspectionTime}} - + 打卡时间:{{ formatDate(item.inspectionTime) }} + + + 巡检人:{{ item.inspectorUser || '-' }} + + + 备注:{{ item.remark }} - + + + + + @@ -38,9 +98,8 @@ @@ -304,6 +456,19 @@ /* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */ .charts-box { width: 100%; - height: 300px; + height: auto; } + + .thumbs { display:flex; gap:6px; justify-content:flex-end; } + .thumb { width: 60px; height: 60px; border-radius: 4px; background:#f5f5f5; } + .tag-view { margin-top: 8px; display:flex; justify-content:flex-end; } + + /* 新增:统计与图表布局样式 */ + .stats { margin: 10px 0; } + .stat { background:#fff; border-radius:8px; padding:10px; display:flex; flex-direction:column; align-items:center } + .stat-label { color:#666; font-size:12px } + .stat-value { color:#1677ff; font-weight:bold; font-size:18px } + .charts { display: grid; grid-template-columns: 1fr; gap: 12px; } + @media (min-width: 380px) { .charts { grid-template-columns: 1fr 1fr; } } + .chart-box { background: #fff; border-radius: 8px; padding: 6px; } \ No newline at end of file diff --git a/pages/work/inspection/checkInUserList/index.vue b/pages/work/inspection/checkInUserList/index.vue new file mode 100644 index 0000000..252673f --- /dev/null +++ b/pages/work/inspection/checkInUserList/index.vue @@ -0,0 +1,171 @@ + + + + + \ No newline at end of file diff --git a/pages/work/inspection/inspectionEx/index.vue b/pages/work/inspection/inspectionEx/index.vue index 30800d8..6d8cc61 100644 --- a/pages/work/inspection/inspectionEx/index.vue +++ b/pages/work/inspection/inspectionEx/index.vue @@ -34,8 +34,8 @@ listData } from '@/api/system/dict/data.js' import { - addRecord - } from "@/api/inspection/record.js" + addAbnormal + } from "@/api/inspection/abnormal.js" import { addWatermarkToImage } from "@/utils/watermark.js" export default { // vue @@ -109,8 +109,9 @@ submit() { this.$refs.dynamicForm.validate().then(res => { this.form.inspectionImg = this.joinList() + this.form.inspectionTime = new Date() // 添加当前时间 console.log("this.form",this.form); - addRecord(this.form).then(res => { + addAbnormal(this.form).then(res => { console.log(res); if (res.code==200) { uni.showToast({ diff --git a/pages/work/inspection/recordList/index.vue b/pages/work/inspection/recordList/index.vue new file mode 100644 index 0000000..18b61cb --- /dev/null +++ b/pages/work/inspection/recordList/index.vue @@ -0,0 +1,295 @@ + + + + + \ No newline at end of file diff --git a/pages/work/inspection/scanSign/index.vue b/pages/work/inspection/scanSign/index.vue index 257486a..0c0c780 100644 --- a/pages/work/inspection/scanSign/index.vue +++ b/pages/work/inspection/scanSign/index.vue @@ -41,6 +41,7 @@ import { addRecord } from "@/api/inspection/record.js" import { addWatermarkToImage } from "@/utils/watermark.js" import appConfig from "@/config" + import { getToken } from "@/utils/auth" // ------- URL 安全拼接,避免出现 /undefined/common/upload ------- function joinURL(base, path) { @@ -110,25 +111,26 @@ }, // 选择文件(支持多张) - async upload(e) { - if (!e?.tempFiles?.length) return - if (this.isUploading) { - this.showMessage("warning", "图片正在上传中,请稍等") - return - } - - this.isUploading = true - try { - for (const tf of e.tempFiles) { - await this.handleImageUpload(tf) - } - } catch (err) { - console.error(err) - this.showMessage("error", `图片上传失败:${err.message || err}`) - } finally { - this.isUploading = false - } - }, + async upload(e) { + if (!e?.tempFiles?.length) return + if (this.isUploading) { + this.showMessage("warning", "图片正在上传中,请稍等") + return + } + + this.isUploading = true + try { + for (const tf of e.tempFiles) { + await this.handleImageUpload(tf) + } + } catch (err) { + console.error(err) + const msg = err?.errMsg || err?.message || (typeof err === "string" ? err : JSON.stringify(err)) + this.showMessage("error", `图片上传失败:${msg}`) + } finally { + this.isUploading = false + } + }, // 单张:加水印 -> 压缩(H5) -> 预览 -> 上传 async handleImageUpload(tempFile) { @@ -260,19 +262,45 @@ url: UPLOAD_URL, name: "file", file, // H5 传 File;不要传 filePath + header: { Authorization: "Bearer " + getToken() }, success: (res) => { try { + if (res.statusCode && res.statusCode !== 200) { + throw new Error(`HTTP ${res.statusCode}`) + } const data = typeof res.data === "string" ? JSON.parse(res.data) : res.data - if (data.code === 200) { + if (data && data.code === 200) { resolve(data.fileName || data.url) } else { - reject(new Error(data.msg || "上传失败")) + reject(new Error((data && data.msg) || "上传失败")) } } catch (e) { reject(new Error("上传响应解析失败")) } }, - fail: (err) => reject(err) + fail: async (err) => { + const msg = err?.errMsg || "uploadFile fail" + if (msg.includes("file error") || msg.includes("fail")) { + try { + const form = new FormData() + form.append("file", file) + const resp = await fetch(UPLOAD_URL, { + method: "POST", + headers: { Authorization: "Bearer " + getToken() }, + body: form + }) + if (!resp.ok) return reject(new Error(`HTTP ${resp.status}`)) + const data = await resp.json() + if (data && data.code === 200) { + return resolve(data.fileName || data.url) + } + return reject(new Error((data && data.msg) || "上传失败")) + } catch (e) { + return reject(new Error(e?.message || msg)) + } + } + reject(new Error(msg)) + } }) }) }, @@ -298,7 +326,7 @@ dialogConfirm() { if (this.msgType === "success") { - uni.reLaunch({ url: "/pages/work/index" }) + uni.reLaunch({ url: "/pages/work/inspection/recordList/index" }) } }, diff --git a/pages/work/sidebar/filingDetail/index.vue b/pages/work/sidebar/filingDetail/index.vue new file mode 100644 index 0000000..6ac6ffd --- /dev/null +++ b/pages/work/sidebar/filingDetail/index.vue @@ -0,0 +1,319 @@ + + + + + \ No newline at end of file diff --git a/pages/work/sidebar/filingLog/index.vue b/pages/work/sidebar/filingLog/index.vue index 71c8498..b5b4bb3 100644 --- a/pages/work/sidebar/filingLog/index.vue +++ b/pages/work/sidebar/filingLog/index.vue @@ -1,150 +1,239 @@ \ No newline at end of file diff --git a/pages/work/sidebar/safetyDeclaratio/index.vue b/pages/work/sidebar/safetyDeclaratio/index.vue index cf95462..aedf4e0 100644 --- a/pages/work/sidebar/safetyDeclaratio/index.vue +++ b/pages/work/sidebar/safetyDeclaratio/index.vue @@ -133,13 +133,15 @@ // console.log(); } }, - submit(ref) { - this.$refs[ref].validate().then(res => { - this.SafetyDeclarationTable.declarationImg = this.joinList() - console.log("提交成功"); - console.log("this.SafetyDeclarationTable", this.SafetyDeclarationTable); - addSafetyDeclaration(this.SafetyDeclarationTable).then(res => { - uni.showToast({ + submit(ref) { + this.$refs[ref].validate().then(res => { + // 绑定当前用户为申报人 + this.SafetyDeclarationTable.applyUser = this.$store.getters.name + this.SafetyDeclarationTable.declarationImg = this.joinList() + console.log("提交成功"); + console.log("this.SafetyDeclarationTable", this.SafetyDeclarationTable); + addSafetyDeclaration(this.SafetyDeclarationTable).then(res => { + uni.showToast({ title: '提交成功', icon: 'success', // 成功图标 duration: 1000 // 持续时间为2000ms diff --git a/permission.js b/permission.js index cbaec53..b74571c 100644 --- a/permission.js +++ b/permission.js @@ -5,7 +5,7 @@ const loginPage = "/pages/login" // 页面白名单 const whiteList = [ - '/pages/login', '/pages/register', '/pages/common/webview/index' + '/pages/login', '/pages/register', '/pages/common/webview/index', '/pages/cas/callback' ] // 检查地址白名单 diff --git a/store/modules/user.js b/store/modules/user.js index c1fc1e6..6c5cbc6 100644 --- a/store/modules/user.js +++ b/store/modules/user.js @@ -1,7 +1,7 @@ import config from '@/config' import storage from '@/utils/storage' import constant from '@/utils/constant' -import { login, logout, getInfo } from '@/api/login' +import { login, logout, getInfo, casLogin, casAppLogin, casUnifiedLogin } from '@/api/login' import { getToken, setToken, removeToken } from '@/utils/auth' const baseUrl = config.baseUrl @@ -12,7 +12,7 @@ const user = { name: storage.get(constant.name), avatar: storage.get(constant.avatar), roles: storage.get(constant.roles), - nickName:storage.get(constant.nickName), + nickName: storage.get(constant.nickName), permissions: storage.get(constant.permissions) }, @@ -36,10 +36,10 @@ const user = { state.permissions = permissions storage.set(constant.permissions, permissions) }, - SET_NICKNAME:(state,nickName)=>{ - state.nickName = nickName - storage.set(constant.nickName, nickName) - } + SET_NICKNAME: (state, nickName) => { + state.nickName = nickName + storage.set(constant.nickName, nickName) + } }, actions: { @@ -59,6 +59,43 @@ const user = { }) }) }, + // CAS 票据登录 + CasLogin({ commit }, payload) { + const { ticket, service } = payload || {} + return new Promise((resolve, reject) => { + casLogin(ticket, service).then(res => { + const token = res.token || res.data?.token + if (token) { + setToken(token) + commit('SET_TOKEN', token) + resolve(res) + } else { + reject('CAS 登录未返回令牌') + } + }).catch(error => { + reject(error) + }) + }) + }, + + // 移动端CAS票据登录 + CasAppLogin({ commit }, ticket) { + return new Promise((resolve, reject) => { + // 使用统一CAS登录接口 + casUnifiedLogin(ticket).then(res => { + const token = res.token || res.data?.token + if (token) { + setToken(token) + commit('SET_TOKEN', token) + resolve(res) + } else { + reject('移动端CAS登录未返回令牌') + } + }).catch(error => { + reject(error) + }) + }) + }, // 获取用户信息 GetInfo({ commit, state }) { @@ -67,7 +104,7 @@ const user = { const user = res.user const avatar = (user == null || user.avatar == "" || user.avatar == null) ? require("@/static/images/profile.jpg") : baseUrl + user.avatar const username = (user == null || user.userName == "" || user.userName == null) ? "" : user.userName - const nickName = (user == null || user.nickName == "" || user.nickName == null) ? "" : user.nickName + const nickName = (user == null || user.nickName == "" || user.nickName == null) ? "" : user.nickName if (res.roles && res.roles.length > 0) { commit('SET_ROLES', res.roles) commit('SET_PERMISSIONS', res.permissions) @@ -76,7 +113,7 @@ const user = { } commit('SET_NAME', username) commit('SET_AVATAR', avatar) - commit('SET_NICKNAME',nickName) + commit('SET_NICKNAME', nickName) resolve(res) }).catch(error => { reject(error) diff --git a/utils/request.js b/utils/request.js index bf06016..d6a3d0a 100644 --- a/utils/request.js +++ b/utils/request.js @@ -10,8 +10,8 @@ import { tansParams } from '@/utils/common' -let timeout = 10000 -const baseUrl = 'http://172.20.10.2:8081' +let timeout = 30000 +const baseUrl = appConfig.baseUrl const request = config => { // 是否需要设置 token @@ -30,7 +30,7 @@ const request = config => { uni.request({ method: config.method || 'get', timeout: config.timeout || timeout, - url: appConfig.baseUrl + config.url || baseUrl + config.url, + url: baseUrl + config.url, data: config.data, header: config.header, dataType: 'json'