细节优化
This commit is contained in:
59
src/apis.js
59
src/apis.js
@@ -10,6 +10,7 @@ function request(method, url, data = {}) {
|
|||||||
method,
|
method,
|
||||||
header,
|
header,
|
||||||
data,
|
data,
|
||||||
|
timeout: 10000,
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
const { code, data, message } = res.data;
|
const { code, data, message } = res.data;
|
||||||
@@ -55,16 +56,66 @@ function request(method, url, data = {}) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
|
handleRequestError(err, url);
|
||||||
reject(err);
|
reject(err);
|
||||||
uni.showToast({
|
|
||||||
title: "接口调用失败",
|
|
||||||
icon: "none",
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 统一的错误处理函数
|
||||||
|
function handleRequestError(err, url) {
|
||||||
|
console.log('请求失败:', { err, url });
|
||||||
|
|
||||||
|
// 根据错误类型显示不同提示
|
||||||
|
if (err.errMsg) {
|
||||||
|
if (err.errMsg.includes('timeout')) {
|
||||||
|
showCustomToast("请求超时,请稍后重试", "timeout");
|
||||||
|
} else if (err.errMsg.includes('fail')) {
|
||||||
|
// 检查网络状态
|
||||||
|
uni.getNetworkType({
|
||||||
|
success: (res) => {
|
||||||
|
if (res.networkType === 'none') {
|
||||||
|
showCustomToast("网络连接已断开,请检查网络设置", "network");
|
||||||
|
} else {
|
||||||
|
showCustomToast("服务器连接失败,请稍后重试", "server");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
showCustomToast("网络异常,请检查网络连接", "unknown");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
showCustomToast("请求失败,请稍后重试", "general");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
showCustomToast("网络异常,请稍后重试", "unknown");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 自定义提示函数
|
||||||
|
function showCustomToast(message, type) {
|
||||||
|
const config = {
|
||||||
|
title: message,
|
||||||
|
icon: "none",
|
||||||
|
duration: 3000
|
||||||
|
};
|
||||||
|
|
||||||
|
// 根据错误类型可以添加不同的处理逻辑
|
||||||
|
switch (type) {
|
||||||
|
case 'timeout':
|
||||||
|
config.duration = 4000; // 超时提示显示更久
|
||||||
|
break;
|
||||||
|
case 'network':
|
||||||
|
config.duration = 5000; // 网络问题提示显示更久
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.showToast(config);
|
||||||
|
}
|
||||||
|
|
||||||
// 获取全局配置
|
// 获取全局配置
|
||||||
export const getAppConfig = () => {
|
export const getAppConfig = () => {
|
||||||
return request("GET", "/index/appConfig");
|
return request("GET", "/index/appConfig");
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ const rowCount = new Array(6).fill(0);
|
|||||||
width: 30px;
|
width: 30px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
min-height: 30px;
|
min-height: 30px;
|
||||||
border: 1px solid #fff3;
|
border: 1px solid #fff;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
margin-left: -30px;
|
margin-left: -30px;
|
||||||
|
|||||||
@@ -79,6 +79,11 @@ onUnmounted(() => {
|
|||||||
<view>
|
<view>
|
||||||
<Avatar :src="user.avatar" :size="35" />
|
<Avatar :src="user.avatar" :size="35" />
|
||||||
<text class="truncate">{{ user.nickName }}</text>
|
<text class="truncate">{{ user.nickName }}</text>
|
||||||
|
<image
|
||||||
|
class="user-name-image"
|
||||||
|
src="../static/vip1.png"
|
||||||
|
mode="widthFix"
|
||||||
|
/>
|
||||||
</view>
|
</view>
|
||||||
<block v-if="refreshing">
|
<block v-if="refreshing">
|
||||||
<image
|
<image
|
||||||
@@ -121,7 +126,7 @@ onUnmounted(() => {
|
|||||||
<view class="content">
|
<view class="content">
|
||||||
<view class="title-bar">
|
<view class="title-bar">
|
||||||
<view />
|
<view />
|
||||||
<text>成为射灵会员</text>
|
<text>会员续费</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="vip-items">
|
<view class="vip-items">
|
||||||
<view
|
<view
|
||||||
@@ -171,11 +176,15 @@ onUnmounted(() => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.header > view > text:last-child {
|
.header > view > text {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
width: 120px;
|
max-width: 120px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
.header > view > image {
|
||||||
|
margin-left: 5px;
|
||||||
|
width: 20px;
|
||||||
|
}
|
||||||
.header > text:nth-child(2) {
|
.header > text:nth-child(2) {
|
||||||
color: #fed847;
|
color: #fed847;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ const subTitles = ["排位赛积分", "本周MVP次数", "本周十环次数"];
|
|||||||
<Avatar :src="user.avatar" />
|
<Avatar :src="user.avatar" />
|
||||||
<view class="rank-item-content">
|
<view class="rank-item-content">
|
||||||
<text class="truncate">{{ user.nickName }}</text>
|
<text class="truncate">{{ user.nickName }}</text>
|
||||||
<text>{{ user.lvlName }},{{ rankData.TotalGames }}场</text>
|
<text>{{ user.lvlName }},{{ myData.TotalGames }}场</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="rank-item-integral" v-if="selectedIndex === 2">
|
<text class="rank-item-integral" v-if="selectedIndex === 2">
|
||||||
<text
|
<text
|
||||||
|
|||||||
@@ -183,6 +183,10 @@ onShow(async () => {
|
|||||||
: "-"
|
: "-"
|
||||||
}}</text>
|
}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="my-rank-score">
|
||||||
|
<image src="../static/bubble-tip5.png" mode="widthFix" />
|
||||||
|
<text>积分:{{ rankData.user.scores }}</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="rank-type">
|
<view class="rank-type">
|
||||||
<image
|
<image
|
||||||
@@ -379,20 +383,24 @@ onShow(async () => {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
color: #b3b3b3;
|
color: #b3b3b3;
|
||||||
width: 100%;
|
width: 110%;
|
||||||
margin-top: 15px;
|
margin-top: 15px;
|
||||||
|
position: relative;
|
||||||
|
transform: translateX(-5%);
|
||||||
}
|
}
|
||||||
.my-data > view {
|
.my-data > view {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
|
width: 32%;
|
||||||
height: 60px;
|
height: 60px;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
.my-data > view:nth-child(2) {
|
.my-data > view:nth-child(2) {
|
||||||
border-left: 1px solid #48494e;
|
border-left: 1px solid #48494e;
|
||||||
border-right: 1px solid #48494e;
|
border-right: 1px solid #48494e;
|
||||||
padding: 0 20px;
|
padding: 0 15px;
|
||||||
}
|
}
|
||||||
.my-data > view > text:first-child {
|
.my-data > view > text:first-child {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
@@ -544,4 +552,22 @@ onShow(async () => {
|
|||||||
height: 12px;
|
height: 12px;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
.my-rank-score {
|
||||||
|
position: absolute !important;
|
||||||
|
color: #fff;
|
||||||
|
width: 80px !important;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
top: -34px;
|
||||||
|
left: 27px;
|
||||||
|
}
|
||||||
|
.my-rank-score > image {
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.my-rank-score > text {
|
||||||
|
position: relative;
|
||||||
|
font-size: 10px !important;
|
||||||
|
margin-bottom: 7px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
BIN
src/static/bubble-tip5.png
Normal file
BIN
src/static/bubble-tip5.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 715 B |
@@ -7,7 +7,7 @@ export const formatTimestamp = (timestamp) => {
|
|||||||
const month = date.getMonth() + 1;
|
const month = date.getMonth() + 1;
|
||||||
const day = date.getDate();
|
const day = date.getDate();
|
||||||
|
|
||||||
return `${year}年${month}月${day}号`;
|
return `${year}-${month}-${day}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const checkConnection = () => {
|
export const checkConnection = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user