diff --git a/.env.development b/.env.development index 03bb4069..f1912101 100644 --- a/.env.development +++ b/.env.development @@ -3,7 +3,7 @@ ENV = 'development' # 'development' # VITE_APP_BASE_API_Url = 'https://aits.jlbank.com.cn:7001' -VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' +VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7001' # VITE_APP_BASE_API_Url = 'http://192.168.247.200' # VITE_APP_BASE_API_Url = 'http://aitscdn.jlbank.com.cn:7001' # VITE_APP_BASE_API_Url = 'http://192.168.108.129' @@ -27,7 +27,7 @@ VITE_APP_BASE_API_Url = 'https://aitstest.jlbank.com.cn:7002' # VITE_APP_BASE_H5_API_Url = 'http://25.18.122.65:7001' # VITE_APP_BASE_H5_API_Url = 'http://25.18.122.91:9786' # VITE_APP_BASE_H5_API_Url = 'http://25.18.122.78:9786' -# VITE_APP_BASE_H5_API_Url_TRAAPP = 'http://192.168.247.200' +#VITE_APP_BASE_H5_API_Url_TRAAPP = 'http://192.168.247.200' # VITE_APP_BASE_H5_API_Url_TRASTUDY = 'http://25.64.32.154:9602' -# VITE_APP_BASE_H5_API_Url_TRAEXAM = 'http://192.168.247.200' +#VITE_APP_BASE_H5_API_Url_TRAEXAM = 'http://192.168.247.200' # VITE_APP_BASE_H5_API_Url_TRAASK = 'http://25.64.32.154:9605' diff --git a/.env.development.rd b/.env.development.rd index b22814ce..ca382f2c 100644 --- a/.env.development.rd +++ b/.env.development.rd @@ -2,6 +2,7 @@ ENV = 'development.rd' # 'development.rd' -VITE_APP_BASE_API_Url = 'http://25.18.122.65:7001' +#VITE_APP_BASE_API_Url = 'http://25.18.122.65:7001' +VITE_APP_BASE_API_Url = 'http://25.18.122.91:9786' VITE_APP_BASE_H5_API_Url_TRAEXAM = 'http://25.64.32.154:9604' diff --git a/src/api/login.js b/src/api/login.js index fe1660ef..42ccd781 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -4,6 +4,10 @@ import { queryCurrentValidMascotInfo } from "@/api/mascot.js" +import { + queryCurrentStatus +} from '@/api/pointsAndRank.js'; + import { setToken, setUserInfo, @@ -24,15 +28,26 @@ export const useAccountLoginApp = (data) => request({ }) => { if (rtnCode === '0000') { setToken(body) - const res = await Promise.all([queryCurrentUser(), queryCurrentValidMascotInfo()]) + const res = await Promise.all([queryCurrentUser(), queryCurrentValidMascotInfo() + // queryCurrentStatus() + ]) const userInfo = getUserInfo() const mascotInfo = res[1] setUserInfo({ ...userInfo, 'mascotInfo': mascotInfo }) + // 积分状态 + // const pointsStatus = res[2].body + + common.setValue('points_data', { + badgeNum: pointsStatus['badgeNum'] ?? 0, // 徽章数 + currentPoints: pointsStatus['currentPoints'] ?? 0, // 当前积分 + currentRankAddr: pointsStatus['ossAddr'] ?? '', // 当前段位图片 + currentRankName: pointsStatus['currentRankName']?? '未知', // 当前段位名称 + }) return { - mascotState:!mascotInfo.mascotId + mascotState: !mascotInfo.mascotId } } return Promise.reject({ @@ -40,22 +55,6 @@ export const useAccountLoginApp = (data) => request({ body }) }).catch(res => { - /** - error: "Service Unavailable" - path: "/traapp/access/userLogin" - requestId: "74d60800-104" - status: 503 - timestamp: "2025-06-24T00:53:35.293+00:00" - */ - /** - body: null - channelNo: "FF6944B69A99745C009F4D0B3C3B22B8E81B22F587D68455E354BABBABCCB6246C54ABD28F3C55AAD34224A16CE7E24E" - head: null - message: "系统异常" - rtnCode: "9999" - rtnTime: "2025-06-24 08:54:52" - */ - return Promise.reject(res) }) @@ -72,7 +71,7 @@ export const queryCurrentUser = (data) => request({ method: 'post', data }).then(res => { - + // deptId: "" // deptName: null // loginName: "ADMIN" // todo id @@ -92,107 +91,109 @@ export const queryCurrentUser = (data) => request({ // #ifdef APP-PLUS // 更新用户信息中的头像路径 const updateUserAvatar = (imagePath) => { - const _userInfo = getUserInfo() ?? {} - setUserInfo({ - ..._userInfo, - ...res.body, - 'imagePath': imagePath - }) + const _userInfo = getUserInfo() ?? {} + setUserInfo({ + ..._userInfo, + ...res.body, + 'imagePath': imagePath + }) } - + // 确保目录存在 const ensureDirectoryExists = (dirPath) => { - return new Promise((resolve) => { - plus.io.requestFileSystem(plus.io.PRIVATE_DOC, (fs) => { - fs.root.getDirectory(dirPath, { create: true }, resolve, resolve) - }) - }) + return new Promise((resolve) => { + plus.io.requestFileSystem(plus.io.PRIVATE_DOC, (fs) => { + fs.root.getDirectory(dirPath, { + create: true + }, resolve, resolve) + }) + }) } - + // 生成唯一文件名 const generateUniqueFilename = (pathName) => { - if (!pathName || typeof pathName !== 'string') { - throw new Error('无效的路径'); - } - - // 直接使用原始文件名(带扩展名) - const filename = pathName.split('/').pop(); - - if (!filename) { - throw new Error('无法从路径中提取文件名'); - } - - // 确保文件扩展名为.png (可选,根据实际需求) - const ext = filename.split('.').pop().toLowerCase(); - if (ext === 'png' || ext === 'jpg' || ext === 'jpeg' || ext === 'webp') { - return filename; - } - - // 如果没有有效扩展名,添加.png - return `${filename}.png`; + if (!pathName || typeof pathName !== 'string') { + throw new Error('无效的路径'); + } + + // 直接使用原始文件名(带扩展名) + const filename = pathName.split('/').pop(); + + if (!filename) { + throw new Error('无法从路径中提取文件名'); + } + + // 确保文件扩展名为.png (可选,根据实际需求) + const ext = filename.split('.').pop().toLowerCase(); + if (ext === 'png' || ext === 'jpg' || ext === 'jpeg' || ext === 'webp') { + return filename; + } + + // 如果没有有效扩展名,添加.png + return `${filename}.png`; }; - + // 下载并保存头像 const downloadAndSaveAvatar = async (fileUrl, localFilePath) => { - try { - await ensureDirectoryExists('avatar') - - return new Promise((resolve, reject) => { - console.log('开始下载头像:', fileUrl) - const dtask = plus.downloader.createDownload(fileUrl, { - filename: localFilePath - }, (d, status) => { - if (status === 200) { - console.log("保存路径:", d.filename) - resolve(d.filename) - } else { - console.error("文件下载失败:", status) - reject(new Error(`下载失败,状态码: ${status}`)) - } - }) - - dtask.start() - }) - } catch (error) { - console.error('创建目录失败:', error) - throw error - } + try { + await ensureDirectoryExists('avatar') + + return new Promise((resolve, reject) => { + console.log('开始下载头像:', fileUrl) + const dtask = plus.downloader.createDownload(fileUrl, { + filename: localFilePath + }, (d, status) => { + if (status === 200) { + console.log("保存路径:", d.filename) + resolve(d.filename) + } else { + console.error("文件下载失败:", status) + reject(new Error(`下载失败,状态码: ${status}`)) + } + }) + + dtask.start() + }) + } catch (error) { + console.error('创建目录失败:', error) + throw error + } } - + // 检查文件是否存在 const checkFileExists = (filePath) => { - return new Promise((resolve) => { - uni.getFileInfo({ - filePath, - success: () => resolve(true), - fail: () => resolve(false) - }) - }) + return new Promise((resolve) => { + uni.getFileInfo({ + filePath, + success: () => resolve(true), + fail: () => resolve(false) + }) + }) } - + // 主逻辑 (async () => { - try { - const pathName = res.body.imageAddr - const fileUrl = base_url + pathName - - // 生成保存路径 - const filename = generateUniqueFilename(pathName) - const localFilePath = '_doc/avatar/' + filename - - // 检查文件是否存在 - const exists = await checkFileExists(localFilePath) - - if (exists) { - // console.log('头像已存在,无需下载') - updateUserAvatar(localFilePath) - } else { - const savedPath = await downloadAndSaveAvatar(fileUrl, localFilePath) - updateUserAvatar(savedPath) - } - } catch (error) { - console.error('头像预加载过程发生错误:', error) - } + try { + const pathName = res.body.imageAddr + const fileUrl = base_url + pathName + + // 生成保存路径 + const filename = generateUniqueFilename(pathName) + const localFilePath = '_doc/avatar/' + filename + + // 检查文件是否存在 + const exists = await checkFileExists(localFilePath) + + if (exists) { + // console.log('头像已存在,无需下载') + updateUserAvatar(localFilePath) + } else { + const savedPath = await downloadAndSaveAvatar(fileUrl, localFilePath) + updateUserAvatar(savedPath) + } + } catch (error) { + console.error('头像预加载过程发生错误:', error) + } })() // #endif @@ -230,4 +231,5 @@ export const loginOut = (data) => request({ setUserInfo(null) common.setValue('me_statistics_data', null) // 我的页统计数据缓存 common.setValue('index_statistics_data', null) // 首页统计数据缓存 + common.setValue('points_data', null) // 首页统计数据缓存 }) \ No newline at end of file diff --git a/src/api/pointsAndRank.js b/src/api/pointsAndRank.js index 490b1b86..bab3c9dc 100644 --- a/src/api/pointsAndRank.js +++ b/src/api/pointsAndRank.js @@ -108,4 +108,16 @@ export const queryCurrentStatus = (data) => { method: 'post', data }); -}; \ No newline at end of file +}; + + +/** + * 徽章墙 + */ +export const queryRankWall = (data) => { + return request({ + url: base_url + '/traPointsInfo/queryRankWall', + method: 'post', + data + }); +}; diff --git a/src/common/common.js b/src/common/common.js index 3e2f2054..037c20a2 100644 --- a/src/common/common.js +++ b/src/common/common.js @@ -233,8 +233,8 @@ function setValue(key, value) { uni.setStorageSync(key, value); } -function getValue(key) { - return uni.getStorageSync(key) +function getValue(key, defaultValue=null) { + return uni.getStorageSync(key) ?? defaultValue } function isLogin() { diff --git a/src/components/examination/es-analysis.vue b/src/components/examination/es-analysis.vue index e1a82d6c..a2de879c 100644 --- a/src/components/examination/es-analysis.vue +++ b/src/components/examination/es-analysis.vue @@ -19,7 +19,7 @@ + + diff --git a/src/components/points-and-badge/check-in.vue b/src/components/points-and-badge/check-in.vue new file mode 100644 index 00000000..8d2341b8 --- /dev/null +++ b/src/components/points-and-badge/check-in.vue @@ -0,0 +1,417 @@ + + + + + diff --git a/src/components/points-and-badge/points.vue b/src/components/points-and-badge/points.vue new file mode 100644 index 00000000..02409e35 --- /dev/null +++ b/src/components/points-and-badge/points.vue @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/src/enum.js b/src/enum.js index 81bb449f..d40c7cb8 100644 --- a/src/enum.js +++ b/src/enum.js @@ -33,7 +33,7 @@ export const SUBJECT_TYPE = [{ } ] export const defaultAvatar = '/static/images/me/default_user_avatar.png' -export const defaultAnonymousAvatar = '/static/images/me/default_user_avatar.png' +export const defaultAnonymousAvatar = '/static/images/competition/competition_default_avatar.png' export const styleButton = { style_button_1: { color: '#FFFFFF', diff --git a/src/pages.json b/src/pages.json index 4c3b0ee1..29a19bfc 100644 --- a/src/pages.json +++ b/src/pages.json @@ -375,6 +375,15 @@ } } }, + { + "path": "pages/pointsAndRank/badge", + "style": { + "navigationBarTitleText": "徽章列表", + "app-plus": { + "titleNView": false + } + } + }, { "path": "pages/course/index", "style": { diff --git a/src/pages/learningTasks/components/content-item.vue b/src/pages/learningTasks/components/content-item.vue index 39afeb40..9fa7823b 100644 --- a/src/pages/learningTasks/components/content-item.vue +++ b/src/pages/learningTasks/components/content-item.vue @@ -1,5 +1,5 @@ + + diff --git a/src/pages/pointsAndRank/points.vue b/src/pages/pointsAndRank/points.vue index 89ed500c..93d9ef54 100644 --- a/src/pages/pointsAndRank/points.vue +++ b/src/pages/pointsAndRank/points.vue @@ -59,16 +59,17 @@ import useZpaging from '@/composables/useZpaging.js'; import common from '@/common/common'; import { queryPointsDetail, queryCurrentStatus } from '@/api/pointsAndRank.js'; + const startVal = ref(0); const endVal = ref(0); const countToRef = ref(null); const fetchFunction = (params) => { queryCurrentStatus().then(({ body }) => { const { currentPoints } = body; - console.log('recurrentPointss', currentPoints); - startVal.value = 9999; - endVal.value = 99999; - stdtTmLenRef.value.start(); + if (currentPoints !== endVal.value) { + endVal.value = currentPoints; + countToRef.value.start(); + } }); return queryPointsDetail({ ...params }); }; @@ -76,13 +77,17 @@ fetchFunction }); - onLoad(() => {}); + onLoad(() => { + const points_data = common.getValue('points_data'); + if (points_data) { + startVal.value = points_data.currentPoints; // 徽章数 + endVal.value = points_data.currentPoints; // 徽章数 + } + }); onUnload(() => {});