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..6d3981c5 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() // 预加载头像 @@ -124,29 +134,29 @@ export const queryCurrentUser = (data) => request({ const localFilePath = '_downloads/' + filename // 先检查是否存在 - uni.getFileInfo({ - filePath: localFilePath, - success: () => { - console.log('头像已存在,无需下载'); - updateUserAvatar(localFilePath) - }, - fail: () => { - console.log('开始下载头像:', url); - const dtask = plus.downloader.createDownload( - url, { - method: 'GET', - filename: '_downloads/' + filename - }, - (download, status) => { - if (status === 200) { - console.log('头像下载成功:', download.filename); - updateUserAvatar(download.filename) - } - } - ) - dtask.start(); - } - }) + // uni.getFileInfo({ + // filePath: localFilePath, + // success: () => { + // console.log('头像已存在,无需下载'); + // updateUserAvatar(localFilePath) + // }, + // fail: () => { + // console.log('开始下载头像:', url); + // const dtask = plus.downloader.createDownload( + // url, { + // method: 'GET', + // filename: '_downloads/' + filename + // }, + // (download, status) => { + // if (status === 200) { + // console.log('头像下载成功:', download.filename); + // updateUserAvatar(download.filename) + // } + // } + // ) + // dtask.start(); + // } + // }) } catch (error) { 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/api/request.js b/src/api/request.js index b0c4ae38..97a9fb43 100644 --- a/src/api/request.js +++ b/src/api/request.js @@ -8,7 +8,7 @@ const ENV = import.meta.env export const get_base_url = url => { if (ENV.MODE === 'development') { // 开发环境 - return ENV.VITE_APP_BASE_API_Url + return ENV.VITE_APP_BASE_API_Url // H5必须用非https,手机端必须用https // #ifdef H5 const baseUrl = ENV.VITE_APP_BASE_API_Url diff --git a/src/pages/course/index.vue b/src/pages/course/index.vue index 92b24b85..1fbf94f6 100644 --- a/src/pages/course/index.vue +++ b/src/pages/course/index.vue @@ -126,7 +126,8 @@ import { queryCrsInfoByPopularApi, queryCrsInfoByRecmdApi } from "@/api/course.js" -import { onMounted, ref, computed } from 'vue' +import { onMounted, onActivated, ref, computed } from 'vue' +import { onShow } from "@dcloudio/uni-app" const customStyle = { backgroundColor: "#ffffff", paddingLeft: "40rpx", @@ -288,6 +289,9 @@ import { onMounted, ref, computed } from 'vue' }) changeTab({name:'全部'}) }) + onActivated(() => { + changeTab({name:activeTab.value || '全部'}) + }); 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..4c31c094 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(); // 返回登录的上一页 + // res['mascotState'] + if (false) { // 判断是否跳转到选科技鹿页面 + 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..09e0bdc3 100644 --- a/src/pages/mascot/mascot_select_list.vue +++ b/src/pages/mascot/mascot_select_list.vue @@ -13,12 +13,13 @@ - + - + @@ -41,15 +42,17 @@ --> - + - - + + @@ -60,7 +63,8 @@ onMounted, onUnmounted, ref, - reactive + reactive, + computed } from 'vue'; import { queryValidTraMascotInfo, @@ -74,28 +78,68 @@ import { onLoad } from '@dcloudio/uni-app'; + const mascotList = reactive([]) - onLoad(() => { - common.loading() - queryValidTraMascotInfo().then(({ - body - }) => { - Object.assign(mascotList, { - ...body - }) - console.log(mascotList); - common.hideLoading() - }) - }) - const swiperCount = 4; // 总共有4个轮播项 + const windowsInfo = uni.getWindowInfo() + const nowWidth = ref(0); + const swiperCount = 4; // 总轮播项数量 + const TRANSITION_RATIO = 0.3; + // 计算过渡起点(像素值,取整):屏幕宽度的20%位置 + const TRANSITION_SUM = computed(() => Math.floor(windowsInfo.screenWidth * TRANSITION_RATIO)); + const TRANSITION_START = computed(() => Math.floor(windowsInfo.screenWidth * (1 - TRANSITION_RATIO))); + // 计算过渡终点(像素值,取整):屏幕宽度的80%位置 + const TRANSITION_END = computed(() => Math.floor(windowsInfo.screenWidth * TRANSITION_RATIO)); + // 第一张图透明度(0、2索引显示) + const btn1Opacity = computed(() => { + + if (initialIndex % 2 === 1) { // 淡入 + console.log('111我淡入淡入'); + if (nowWidth.value <= TRANSITION_START.value) { + return 0; + } else { + return Math.min(1, (nowWidth.value - TRANSITION_START.value) / TRANSITION_SUM.value); + } + } else { // 淡出 + console.log('111我淡出'); + if (nowWidth.value >= TRANSITION_END.value) { + return 1; + } else { + return Math.max(0, 1 - (TRANSITION_END.value - nowWidth.value) / TRANSITION_SUM.value); + } + } + }); + + const btn2Opacity = computed(() => { + return 0; + const initialIndex = swiperIndex.value; + if (initialIndex % 2 === 0) { // 淡入 + console.log('222我淡入'); + if (nowWidth.value <= TRANSITION_START.value) { + return 1; + } else { + return Math.max(0, 1 - (TRANSITION_END.value - nowWidth.value) / TRANSITION_SUM.value); + + } + } else { // 淡出 + console.log('222我淡出'); + if (nowWidth.value >= TRANSITION_END.value) { + return 0; + } else { + return Math.min(1, (nowWidth.value - TRANSITION_START.value) / TRANSITION_SUM.value); + } + } + }); + let swiperIndex = ref(0); // 当前显示第1个(索引0) const isAnimating = ref(false); // 标记动画是否进行中 - const animationfinish = () => { - console.log("动画结束,允许下次点击"); + const animationfinish = ({ + detail + }) => { + swiperIndex.value = detail.current isAnimating.value = false; // 动画结束后重置状态 }; - + // 点击左右切换按钮 const doct_click = (num) => { if (isAnimating.value) return; // 1. 如果动画正在进行,直接忽略点击 isAnimating.value = true; @@ -103,7 +147,13 @@ swiperIndex.value = newIndex; // 更新当前索引 }; - // 选择他 + // 当前宽度 + const transition = ({ + detail + }) => { + nowWidth.value = Math.abs(detail.dx) + } + const select_it = () => { const item = mascotList[swiperIndex.value] common.loading() @@ -118,13 +168,30 @@ 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() }) } - + onLoad(() => { + common.loading() + queryValidTraMascotInfo().then(({ + body + }) => { + Object.assign(mascotList, { + ...body + }) + console.log(mascotList); + common.hideLoading() + }) + }) onMounted(() => { }) @@ -228,8 +295,10 @@ margin-top: 20rpx; width: 80%; height: 120rpx; + position: relative; .img { + position: absolute; width: 100%; height: 100%; } diff --git a/src/pages/me/index.vue b/src/pages/me/index.vue index 9269b5c7..49b0eeae 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() + }) + }