From 76a5bcca0f18d6e3f1b2ada689694f5702814f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=94=B0=E5=B2=A9?= Date: Fri, 18 Jul 2025 18:26:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91=E5=90=89=E7=A5=A5=E7=89=A9?= =?UTF-8?q?=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- src/api/login.js | 109 +++++--- src/api/mascot.js | 61 +++++ src/api/request.js | 2 + src/enum.js | 4 - .../courseDetail/components/introduce.vue | 3 +- src/pages/courseDetail/index.vue | 2 +- src/pages/index/index.vue | 2 +- src/pages/mascot/mascot_select_list.vue | 253 ++++++++++++++++-- src/pages/setting/index.vue | 42 ++- src/static/images/mascot/bg_1.png | Bin 50288 -> 52345 bytes src/static/images/mascot/btn_1.png | Bin 73428 -> 53312 bytes src/static/images/mascot/btn_2.png | Bin 48300 -> 32042 bytes 13 files changed, 403 insertions(+), 77 deletions(-) create mode 100644 src/api/mascot.js diff --git a/.env.development b/.env.development index c5628d20..42c1ece7 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:7001' +VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' # 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 893c4dba..52b2b984 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -1,5 +1,9 @@ import request from '@/api/request' import common from "@/common/common"; +import { + queryCurrentValidMascotInfo +} from "@/api/mascot.js" + import { setToken, setUserInfo, @@ -21,7 +25,36 @@ 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对象 + }; + + // 图片加载失败 + img.onerror = () => { + console.error(`图片缓存失败: ${url}`); + reject(new Error(`Failed to load image: ${url}`)); + }; + + // 开始加载图片(设置src触发请求,浏览器会自动缓存) + img.src = url; + }) + } + }) const user_data = await queryCurrentUser() + return user_data } @@ -76,46 +109,48 @@ export const queryCurrentUser = (data) => request({ // 预加载头像 // #ifdef APP-PLUS const updateUserAvatar = (imagePath) => { - const userInfo = getUserInfo() - setUserInfo({ - ...userInfo, - 'imagePath': imagePath - }) + const userInfo = getUserInfo() + setUserInfo({ + ...userInfo, + 'imagePath': imagePath + }) } - + try { - const pathName = res.body.imageAddr - const url = base_url + pathName - // 生成唯一文件名,避免冲突 - const filename = pathName.split('/').pop() - 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(); - } - }) + const pathName = res.body.imageAddr + const url = base_url + pathName + // 生成唯一文件名,避免冲突 + const filename = pathName.split('/').pop() + 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(); + } + }) + + } catch (error) { - console.error('头像预加载过程发生错误:', error); + console.error('头像预加载过程发生错误:', error); } // #endif return res.body diff --git a/src/api/mascot.js b/src/api/mascot.js new file mode 100644 index 00000000..e6ffc827 --- /dev/null +++ b/src/api/mascot.js @@ -0,0 +1,61 @@ +import request from '@/api/request' + +const base_url = '/traapp' + + +/** + * 查询吉祥物列表 + * 出参: + mascotId 吉祥物ID String + mascotName 吉祥物名称 String + mascotNameEn 吉祥物英文名称 String + mascotDesc 吉祥物简介 String + mascotNo 吉祥物编号 String + imgAddr 吉祥物图片 String + imgThumbAddr 吉祥物缩略图 String + showOrder 显示顺序 int + */ +export const queryValidTraMascotInfo = (data) => { + return request({ + url: base_url + '/traMascotInfo/queryValidTraMascotInfo', + method: 'post', + toastErrors: true, + data + }); +}; + +/** + * 设置吉祥物 + * 入参: + mascotId 必输项:true 类型:String + */ +export const setTraMascotInfo = (data) => { + return request({ + url: base_url + '/traMascotInfo/setTraMascotInfo', + method: 'post', + toastErrors: true, + data + }); +}; + +// 查询当前已经选择的吉祥物 +/** + * 查询当前已经选择的吉祥物 + * 出参: + mascotId 吉祥物ID String + mascotName 吉祥物名称 String + mascotNameEn 吉祥物英文名称 String + mascotDesc 吉祥物简介 String + mascotNo 吉祥物编号 String + imgAddr 吉祥物图片 String + imgThumbAddr 吉祥物缩略图 String + showOrder 显示顺序 int + */ +export const queryCurrentValidMascotInfo = (data) => { + return request({ + url: base_url + '/traMascotInfo/queryCurrentValidMascotInfo', + method: 'post', + toastErrors: true, + data + }); +}; \ No newline at end of file diff --git a/src/api/request.js b/src/api/request.js index 51116660..b0c4ae38 100644 --- a/src/api/request.js +++ b/src/api/request.js @@ -6,7 +6,9 @@ import common from '@/common/common.js' const ENV = import.meta.env export const get_base_url = url => { + if (ENV.MODE === 'development') { // 开发环境 + return ENV.VITE_APP_BASE_API_Url // H5必须用非https,手机端必须用https // #ifdef H5 const baseUrl = ENV.VITE_APP_BASE_API_Url diff --git a/src/enum.js b/src/enum.js index 33eb71b4..cb791e77 100644 --- a/src/enum.js +++ b/src/enum.js @@ -8,9 +8,5 @@ export const GENDER = [{ { value: "f", label: "女性", - }, - { - value: "o", - label: "其他", } ] // 性别 \ No newline at end of file diff --git a/src/pages/courseDetail/components/introduce.vue b/src/pages/courseDetail/components/introduce.vue index 64df2485..ecf11866 100644 --- a/src/pages/courseDetail/components/introduce.vue +++ b/src/pages/courseDetail/components/introduce.vue @@ -12,7 +12,7 @@ 更新日期 - {{ common.formatDate2(modelValue.mtTime, 'yyyy-MM-dd HH:mm') }} + {{ (modelValue.mtTime || '').substr(0,16) }} @@ -104,6 +104,7 @@ font-size: 22rpx; margin-right: 14rpx; background-color: #f1f3f8; + margin-top: 6rpx; } } .bottom-right { diff --git a/src/pages/courseDetail/index.vue b/src/pages/courseDetail/index.vue index 34b7c40c..711ea9b2 100644 --- a/src/pages/courseDetail/index.vue +++ b/src/pages/courseDetail/index.vue @@ -130,11 +130,11 @@ onMounted(() => { uni.$on('refresh_comment_data', () => { commentRef.value?.getData(); + tabAct.value = 2 }) }) onLoad((params) => { crsNum.value = params.crsNum; - }); onShow(()=>{ getData(); diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 2d55fb31..d80504da 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -487,7 +487,7 @@ flex-direction: column; position: relative; z-index: 0; - + overflow-x: hidden; // 背景图 .bg_img { position: absolute; diff --git a/src/pages/mascot/mascot_select_list.vue b/src/pages/mascot/mascot_select_list.vue index 16b0fc87..ab3a9a2d 100644 --- a/src/pages/mascot/mascot_select_list.vue +++ b/src/pages/mascot/mascot_select_list.vue @@ -1,18 +1,55 @@