From 6fb9ba54b20f191db512a79a211501c7187dc003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=B2=A9?= Date: Fri, 18 Jul 2025 20:22:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=90=89=E7=A5=A5?= =?UTF-8?q?=E7=89=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- src/api/login.js | 68 ++++++++++++++----------- src/api/mascot.js | 33 ++++++++++-- src/pages/index/dialog.vue | 4 +- src/pages/index/index.vue | 14 ++--- src/pages/login/login.vue | 31 +++++------ src/pages/mascot/mascot_select_list.vue | 8 ++- src/pages/me/index.vue | 63 +++++++++++++++++++++-- src/pages/setting/index.vue | 2 - 9 files changed, 157 insertions(+), 68 deletions(-) diff --git a/.env.development b/.env.development index 42c1ece7..c5628d20 100644 --- a/.env.development +++ b/.env.development @@ -9,7 +9,7 @@ ENV = 'development' # VITE_APP_BASE_API_Url = 'http://25.18.122.78:9786' # DEV -VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' +VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' # app入口 #VITE_APP_BASE_API_Url = 'http://25.16.122.65:7001' diff --git a/src/api/login.js b/src/api/login.js index 52b2b984..bbfa079d 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -24,39 +24,46 @@ export const useAccountLoginApp = (data) => request({ }) => { if (rtnCode === '0000') { setToken(body) - // 获取科技鹿 - queryCurrentValidMascotInfo().then((res) => { - const userInfo = getUserInfo() - setUserInfo({ - ...userInfo, - 'mascotInfo': res - }) - console.log('科技', res); - if (res.imgAddr) { - setTimeout(() => { - const img = new Image(); // 创建Image对象 - // 图片加载成功(缓存完成) - img.onload = () => { - console.log(`图片缓存成功: ${url}`); - resolve(img); // 返回加载完成的Image对象 - }; + // queryCurrentValidMascotInfo().then(({body}) => { + // const userInfo = getUserInfo() + // setUserInfo({ + // ...userInfo, + // 'mascotInfo': body + // }) + // const userInfo2 = getUserInfo() + // console.log('设置科技鹿', userInfo2); + // if (body.imgAddr) { + // setTimeout(() => { + // const img = new Image(); // 创建Image对象 + // // 图片加载成功(缓存完成) + // img.onload = () => { + // console.log(`图片缓存成功: ${url}`); + // resolve(img); // 返回加载完成的Image对象 + // }; - // 图片加载失败 - img.onerror = () => { - console.error(`图片缓存失败: ${url}`); - reject(new Error(`Failed to load image: ${url}`)); - }; + // // 图片加载失败 + // img.onerror = () => { + // console.error(`图片缓存失败: ${url}`); + // reject(new Error(`Failed to load image: ${url}`)); + // }; - // 开始加载图片(设置src触发请求,浏览器会自动缓存) - img.src = url; - }) - } + // // 开始加载图片(设置src触发请求,浏览器会自动缓存) + // img.src = url; + // }) + // } + // }) + // const user_data = await queryCurrentUser() + const res = await Promise.all([queryCurrentUser(), queryCurrentValidMascotInfo()]) + const userInfo = getUserInfo() + const mascotInfo = res[1] + setUserInfo({ + ...userInfo, + 'mascotInfo': mascotInfo }) - const user_data = await queryCurrentUser() - - return user_data - + return { + mascotState:!mascotInfo.mascotId + } } return Promise.reject({ rtnCode, @@ -95,6 +102,7 @@ export const queryCurrentUser = (data) => request({ method: 'post', data }).then(res => { + // deptId: "" // deptName: null // loginName: "ADMIN" // todo id @@ -103,7 +111,9 @@ export const queryCurrentUser = (data) => request({ // userId: "USER001" // userName: "ADMIN" / todo name // userStatus: "01" + setUserInfo(res.body) + console.log('预加载头像'); const base_url = get_base_url() // 预加载头像 diff --git a/src/api/mascot.js b/src/api/mascot.js index e6ffc827..c73933e7 100644 --- a/src/api/mascot.js +++ b/src/api/mascot.js @@ -1,6 +1,9 @@ import request from '@/api/request' +import { + get_base_url +} from '@/api/request.js' -const base_url = '/traapp' +const app_url = '/traapp' /** @@ -17,7 +20,7 @@ const base_url = '/traapp' */ export const queryValidTraMascotInfo = (data) => { return request({ - url: base_url + '/traMascotInfo/queryValidTraMascotInfo', + url: app_url + '/traMascotInfo/queryValidTraMascotInfo', method: 'post', toastErrors: true, data @@ -31,7 +34,7 @@ export const queryValidTraMascotInfo = (data) => { */ export const setTraMascotInfo = (data) => { return request({ - url: base_url + '/traMascotInfo/setTraMascotInfo', + url: app_url + '/traMascotInfo/setTraMascotInfo', method: 'post', toastErrors: true, data @@ -53,9 +56,29 @@ export const setTraMascotInfo = (data) => { */ export const queryCurrentValidMascotInfo = (data) => { return request({ - url: base_url + '/traMascotInfo/queryCurrentValidMascotInfo', + url: app_url + '/traMascotInfo/queryCurrentValidMascotInfo', method: 'post', toastErrors: true, data - }); + }).then(({ + body + }) => { + if (body.imgAddr) { + // setTimeout(() => { + // const base_url = get_base_url() + // const url = base_url + body.imgAddr + // const img = new Image(); // 创建Image对象 + // img.onload = () => { + // console.log(`图片缓存成功: ${url}`); + // }; + // // 图片加载失败 + // img.onerror = () => { + // console.error(`图片缓存失败: ${url}`); + // }; + // img.src = url; // 开始加载图片(设置src触发请求,浏览器会自动缓存) + // }) + } + + return body + }) }; \ No newline at end of file diff --git a/src/pages/index/dialog.vue b/src/pages/index/dialog.vue index 89bc4911..3b78d287 100644 --- a/src/pages/index/dialog.vue +++ b/src/pages/index/dialog.vue @@ -15,7 +15,7 @@ - + Hi,我是{{ userInfo.mascotInfo?.mascotName || ''}} 工作学习,我都能帮你! @@ -121,7 +121,7 @@ const socketStore = useSocketStore() const { SocketObj } = storeToRefs(socketStore) const userInfo = computed(() => getUserInfo()) - + console.log('userInfoxxx', getUserInfo()); const questionList = ref([ '对公小程序开户流程?', '厅堂服务经理2025年管理办法?', diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index d80504da..e992fbae 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -129,7 +129,7 @@ - + {{item.crsName}} @@ -161,8 +161,8 @@ - - + + {{item.crsName}} @@ -194,7 +194,7 @@ - + {{item.crsName}} @@ -311,17 +311,17 @@ const stdtTmLen = res.body.stdtTmLen const accmPracticeCnt = res.body.accmPracticeCnt const accmExamCnt = res.body.accmExamCnt - if (stdtTmLen != this.stdtTmLen) { // 不相等就执行 + if (stdtTmLen != this.stdtTmLen) { this.startStdtTmLen = this.stdtTmLen this.stdtTmLen = stdtTmLen stdtTmLenRef.value.start() } - if (accmPracticeCnt != this.accmPracticeCnt) { // 不相等就执行 + if (accmPracticeCnt != this.accmPracticeCnt) { this.startAccmPracticeCnt = this.accmPracticeCnt this.accmPracticeCnt = accmPracticeCnt accmPracticeCntRef.value.start() } - if (accmExamCnt != this.accmExamCnt) { // 不相等就执行 + if (accmExamCnt != this.accmExamCnt) { this.startAccmExamCnt = this.accmExamCnt this.accmExamCnt = accmExamCnt accmExamCntRef.value.start() diff --git a/src/pages/login/login.vue b/src/pages/login/login.vue index 6c0ded28..289d1ac6 100644 --- a/src/pages/login/login.vue +++ b/src/pages/login/login.vue @@ -98,30 +98,27 @@ const login_fun = (): void => { const secretKey = 'EtBzqj+ln5tSTof1SDhpTg=='; const cipherText = encryptByAES(password.value, secretKey); useAccountLoginApp({ loginName: account.value, password: cipherText }) - .then(async () => { + .then(async (res) => { common.hideLoading(); - common.msg('登录成功'); // 登陆成功,缓存账号密码 common.setValue('loginAccountData', { account: account.value, password: password.value }); - // setTimeout(() => { - // this.$common.reLaunch('/pages/homepage/index'); - // }, this.GLOBAL_TIMER_SUBMIT_DELAY_TIME); - - // 不再在登录时创建ws链接 - // socketStore.creatSocket(); - - const pages = getCurrentPages(); - - if (pages.length >= 2) { - // 页面栈只有一页,没有返回页,那就返回首页 - console.log('返回登录的上一页'); - back_state.value = false; - common.navigateBack(); // 返回登录的上一页 + console.log('resresres', res); + if (res['mascotState']) { // 判断是否跳转到选科技鹿页面 + common.redirectTo('/pages/mascot/mascot_select_list'); } else { - common.switchTab('/pages/index/index'); + common.msg('登录成功'); + const pages = getCurrentPages(); + if (pages.length >= 2) { + // 页面栈只有一页,没有返回页,那就返回首页 + console.log('返回登录的上一页'); + back_state.value = false; + common.navigateBack(); // 返回登录的上一页 + } else { + common.switchTab('/pages/index/index'); + } } }) .catch((res) => { diff --git a/src/pages/mascot/mascot_select_list.vue b/src/pages/mascot/mascot_select_list.vue index ab3a9a2d..54038adb 100644 --- a/src/pages/mascot/mascot_select_list.vue +++ b/src/pages/mascot/mascot_select_list.vue @@ -118,7 +118,13 @@ common.hideLoading() common.msg('设置成功') setTimeout(() => { - common.navigateBack() + const pages = getCurrentPages(); + if (pages.length >= 2) { + // 页面栈只有一页,没有返回页,那就返回首页 + common.navigateBack(); // 返回登录的上一页 + } else { + common.switchTab('/pages/index/index'); + } }, 400) }).catch(() => { common.hideLoading() diff --git a/src/pages/me/index.vue b/src/pages/me/index.vue index 9269b5c7..b1a5feb4 100644 --- a/src/pages/me/index.vue +++ b/src/pages/me/index.vue @@ -1,13 +1,12 @@ @@ -104,7 +105,8 @@ import { ref, computed, - reactive + reactive, + nextTick } from 'vue'; import { onShow @@ -125,8 +127,14 @@ import { useSocketStore } from "@/store/socket.js" + import { + updateDfSysUserExtandInfoImageAddr + } from "@/api/user.js" + import { + uploadFile + } from '@/api/common' + import { queryCurrentUser} from '@/api/login.js'; const socketStore = useSocketStore() - const accmTaskCntRef = ref(null); const accmPointRef = ref(null); const stdtTmLenRef = ref(null); @@ -231,6 +239,53 @@ console.log('下拉刷新'); uni.stopPullDownRefresh(); }); + + // 头像 + const avatarCropperStatus = ref(true) + const avatarCropperUrl = ref(''); + // 点击修改头像 + const click_update_avatar = (value) => { + uni.chooseImage({ + count: 1, + sizeType: ["compressed"], + success: (res) => { + avatarCropperUrl.value = res.tempFilePaths[0]; + avatarCropperStatus.value = true + }, + }); + }; + // 选择头像取消 + const onCancel = (value) => { + avatarCropperStatus.value = false + } + // 选择头像确定 + const onConfirm = (file) => { + avatarCropperStatus.value = false + nextTick(async() => { + common.loading('更新头像中') + try{ + const data = { + bizScen: 'S3007', + thumbnailFlag: true, + thumbImgSize:100 + } + // 上传图片 + const res = await uploadFile(file.tempFilePath, data) + // 更新个人信息 + await updateDfSysUserExtandInfoImageAddr({imageAddr : res.thumbFileId}) + // 更新个人信息 + const userData = await queryCurrentUser() + console.log('userData', ); + common.msg('修改成功') + + user_info.imageAddr = getUserInfo('imageAddr') + user_info.imagePath = getUserInfo('imagePath') + } catch { + common.msg('修改失败') + } + common.hideLoading() + }) + }