修改图片鉴权后的头像和吉祥物不显示问题
This commit is contained in:
+20
-16
@@ -11,7 +11,8 @@ import {
|
||||
import {
|
||||
setToken,
|
||||
setUserInfo,
|
||||
getUserInfo
|
||||
getUserInfo,
|
||||
getToken
|
||||
} from "@/common/common";
|
||||
import {
|
||||
get_base_url
|
||||
@@ -71,7 +72,6 @@ export const queryCurrentUser = (data) => request({
|
||||
method: 'post',
|
||||
data
|
||||
}).then(res => {
|
||||
|
||||
// deptId: ""
|
||||
// deptName: null
|
||||
// loginName: "ADMIN" // todo id
|
||||
@@ -87,6 +87,7 @@ export const queryCurrentUser = (data) => request({
|
||||
})
|
||||
// console.log('预加载头像');
|
||||
const base_url = get_base_url()
|
||||
const token = getToken()
|
||||
// 预加载头像
|
||||
// #ifdef APP-PLUS
|
||||
// 更新用户信息中的头像路径
|
||||
@@ -175,22 +176,25 @@ export const queryCurrentUser = (data) => request({
|
||||
(async () => {
|
||||
try {
|
||||
const pathName = res.body.imageAddr
|
||||
const fileUrl = base_url + pathName
|
||||
if (pathName) {
|
||||
const fileUrl = base_url + pathName + '?tk=' + token
|
||||
console.log('fileUrl', fileUrl);
|
||||
// 生成保存路径
|
||||
const filename = generateUniqueFilename(pathName)
|
||||
const localFilePath = '_doc/avatar/' + filename
|
||||
|
||||
// 生成保存路径
|
||||
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)
|
||||
// 检查文件是否存在
|
||||
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)
|
||||
}
|
||||
|
||||
+5
-4
@@ -2,7 +2,7 @@ import request from '@/api/request'
|
||||
import {
|
||||
get_base_url
|
||||
} from '@/api/request.js'
|
||||
|
||||
import { getToken } from '@/common/common.js'
|
||||
const app_url = '/traapp'
|
||||
|
||||
|
||||
@@ -77,8 +77,9 @@ export const queryCurrentValidMascotInfo = (data) => {
|
||||
if (body.imgAddr) {
|
||||
console.log('body.imgAddrmascotNo');
|
||||
const base_url = get_base_url()
|
||||
const token = getToken()
|
||||
const pathName = body.imgAddr
|
||||
const fileUrl = base_url + pathName
|
||||
const fileUrl = base_url + pathName + '?tk=' + token
|
||||
const localFilePath = '_doc/mascot/' + body.mascotNo + '.png'
|
||||
console.log('fileUrl', fileUrl);
|
||||
// 将 Promise 回调函数声明为 async
|
||||
@@ -86,10 +87,10 @@ export const queryCurrentValidMascotInfo = (data) => {
|
||||
// 现在可以在这里使用 await 了
|
||||
const exists = await checkFileExists(localFilePath)
|
||||
if (exists) {
|
||||
console.log('已存在,无需下载')
|
||||
// console.log('已存在,无需下载吉祥物')
|
||||
resolve({...body, imgAddr:localFilePath})
|
||||
} else {
|
||||
console.log('开始下载吉祥物:', fileUrl)
|
||||
// console.log('开始下载吉祥物:', fileUrl)
|
||||
const dtask = plus.downloader.createDownload(fileUrl, {
|
||||
filename: localFilePath
|
||||
}, (d, status) => {
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
</view>
|
||||
</scroll-view>
|
||||
<view class="switch-div" @click="switchStatus()">
|
||||
<view class="back_div">
|
||||
<view class="back_div" :class="expand ? 'up' : 'down'">
|
||||
<view class="back-icon"></view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -133,9 +133,8 @@
|
||||
checkInLoading.value = false;
|
||||
isSigned.value = true;
|
||||
continuousDay.value = days;
|
||||
generate() // 签到完重新计算日历样式
|
||||
generate(); // 签到完重新计算日历样式
|
||||
checkInSuccessCallback(true, days, res.body.points, res.body.pointsBadges);
|
||||
|
||||
},
|
||||
failCb: (res) => {
|
||||
checkInLoading.value = false;
|
||||
@@ -226,7 +225,7 @@
|
||||
} catch (err) {
|
||||
console.error(err.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
const open = (isSignedStatus, days, onCheckInClick = () => {}, onCheckInSuccess = () => {}) => {
|
||||
isSigned.value = isSignedStatus; // 今日签到状态
|
||||
continuousDay.value = days; // 连续签到
|
||||
@@ -235,8 +234,8 @@
|
||||
checkInClickCallback = onCheckInClick;
|
||||
checkInSuccessCallback = onCheckInSuccess;
|
||||
// 示例:X=10时,以"10天前"为第1天,生成35天列表
|
||||
generate()
|
||||
|
||||
generate();
|
||||
|
||||
popup.value.open();
|
||||
};
|
||||
defineExpose({ open, close });
|
||||
@@ -374,8 +373,13 @@
|
||||
height: 40%;
|
||||
border-top: 2rpx solid #bfbfbf;
|
||||
border-left: 2rpx solid #bfbfbf;
|
||||
}
|
||||
&.up {
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
&.down {
|
||||
transform: rotate(-135deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
.calendar-div {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<view class="title_text font_pf">欢迎登录</view>
|
||||
<image src="/static/images/login/clap.png" class="title_text_img"></image>
|
||||
</view>
|
||||
<view class="title_text_tip font_pf">登录账号即可查看更多精彩咨询</view>
|
||||
<view class="title_text_tip font_pf">登录账号即可查看更多精彩内容</view>
|
||||
<view class="fl1"></view>
|
||||
</view>
|
||||
<view class="account_password_div">
|
||||
|
||||
Reference in New Issue
Block a user