隐藏load ,提高用户体验

This commit is contained in:
张成
2025-09-29 10:35:34 +08:00
parent 090a44fd6e
commit 9b6e3e15d0
5 changed files with 36 additions and 170 deletions

View File

@@ -163,11 +163,11 @@ const ListPage = () => {
Taro.stopPullDownRefresh();
// 显示刷新成功提示
Taro.showToast({
title: "刷新成功",
icon: "success",
duration: 1000,
});
// Taro.showToast({
// title: "刷新成功",
// icon: "success",
// duration: 1000,
// });
} catch (error) {
// 刷新失败时也停止动画
Taro.stopPullDownRefresh();
@@ -207,7 +207,7 @@ const ListPage = () => {
updateFilterOptions(params);
};
const handleSearchChange = () => { };
const handleSearchChange = () => { };
// 距离筛选
const handleDistanceOrQuickChange = (name, value) => {
@@ -228,8 +228,8 @@ const ListPage = () => {
});
};
// 初始化字典数据
const initDictionaryData = async () => {
// 初始化字典数据
const initDictionaryData = async () => {
try {
const { fetchDictionary } = useDictionaryStore.getState();
await fetchDictionary();
@@ -238,9 +238,9 @@ const ListPage = () => {
}
}
useEffect(() => {
initDictionaryData()
}, []);
useEffect(() => {
initDictionaryData()
}, []);
return (
<>
@@ -255,21 +255,21 @@ const ListPage = () => {
{/* 列表内容 */}
<View className={styles.listPage} style={{ paddingTop: totalHeight }}>
{/* 综合筛选 */}
{isShowFilterPopup && (
<View>
<FilterPopup
loading={loading}
onCancel={toggleShowPopup}
onConfirm={handleFilterConfirm}
onChange={handleUpdateFilterOptions}
filterOptions={filterOptions}
onClear={clearFilterOptions}
visible={isShowFilterPopup}
onClose={toggleShowPopup}
statusNavbarHeigh={statusNavbarHeightInfo?.totalHeight}
/>
</View>
)}
{isShowFilterPopup && (
<View>
<FilterPopup
loading={loading}
onCancel={toggleShowPopup}
onConfirm={handleFilterConfirm}
onChange={handleUpdateFilterOptions}
filterOptions={filterOptions}
onClear={clearFilterOptions}
visible={isShowFilterPopup}
onClose={toggleShowPopup}
statusNavbarHeigh={statusNavbarHeightInfo?.totalHeight}
/>
</View>
)}
<View
className={`${styles.listTopSearchWrapper}`}
>

View File

@@ -1,134 +0,0 @@
import httpService from './httpService'
import type { ApiResponse } from './httpService'
// 用户信息接口
export interface UserProfile {
id: string
nickname: string
avatar?: string
age?: number
gender: 'male' | 'female'
interests: string[]
acceptNotification: boolean
}
// 反馈评价接口
export interface Feedback {
id: string
matchId: string
userId: string
photos: string[]
rating: number
recommend: 'yes' | 'no' | 'neutral'
aspects: string[]
comments: string
createdAt: string
}
// DynamicFormDemo页面API服务类
class DemoApiService {
// ==================== 用户信息相关接口 ====================
// 获取用户信息
async getUserProfile(): Promise<ApiResponse<UserProfile>> {
return httpService.get('/user/profile')
}
// 更新用户信息
async updateUserProfile(data: Partial<UserProfile>): Promise<ApiResponse<UserProfile>> {
return httpService.put('/user/profile', data, {
showLoading: true,
loadingText: '保存中...'
})
}
// 上传头像
async uploadAvatar(filePath: string): Promise<ApiResponse<{ url: string }>> {
return httpService.post('/user/avatar', { filePath }, {
showLoading: true,
loadingText: '上传头像中...'
})
}
// ==================== 反馈评价相关接口 ====================
// 提交活动评价
async submitFeedback(data: {
matchId: string
photos?: string[]
rating: number
recommend: 'yes' | 'no' | 'neutral'
aspects: string[]
comments: string
}): Promise<ApiResponse<Feedback>> {
return httpService.post('/feedback', data, {
showLoading: true,
loadingText: '提交评价中...'
})
}
// 获取我的评价列表
async getMyFeedbacks(params?: {
page?: number
limit?: number
}): Promise<ApiResponse<{ list: Feedback[]; total: number }>> {
return httpService.get('/feedback/my', params)
}
// 获取活动的所有评价
async getMatchFeedbacks(matchId: string, params?: {
page?: number
limit?: number
}): Promise<ApiResponse<{ list: Feedback[]; total: number }>> {
return httpService.get(`/feedback/match/${matchId}`, params)
}
// ==================== 通用表单提交接口 ====================
// 提交表单数据(通用接口)
async submitForm(formType: string, formData: any[]): Promise<ApiResponse<any>> {
return httpService.post('/forms/submit', {
type: formType,
data: formData
}, {
showLoading: true,
loadingText: '提交中...'
})
}
// 保存表单草稿
async saveFormDraft(formType: string, formData: any[]): Promise<ApiResponse<{ id: string }>> {
return httpService.post('/forms/draft', {
type: formType,
data: formData
}, {
showLoading: true,
loadingText: '保存中...'
})
}
// 获取表单草稿
async getFormDrafts(formType: string): Promise<ApiResponse<{ id: string; data: any[]; createdAt: string }[]>> {
return httpService.get('/forms/drafts', { type: formType })
}
// 删除表单草稿
async deleteFormDraft(id: string): Promise<ApiResponse<{ success: boolean }>> {
return httpService.delete(`/forms/draft/${id}`)
}
// ==================== 兴趣爱好相关接口 ====================
// 获取兴趣爱好选项
async getInterestOptions(): Promise<ApiResponse<{ label: string; value: string }[]>> {
return httpService.get('/interests')
}
// 获取推荐的兴趣爱好
async getRecommendedInterests(): Promise<ApiResponse<string[]>> {
return httpService.get('/interests/recommended')
}
}
// 导出API服务实例
export default new DemoApiService()

View File

@@ -139,7 +139,7 @@ export class FollowService {
API_CONFIG.USER.FOLLOW,
{ following_id: user_id },
{
showLoading: true,
showLoading: false,
loadingText: '关注中...'
}
);
@@ -162,7 +162,7 @@ export class FollowService {
API_CONFIG.USER.UNFOLLOW,
{ following_id: user_id },
{
showLoading: true,
showLoading: false,
loadingText: '取消关注中...'
}
);

View File

@@ -53,7 +53,7 @@ export const getGamesIntegrateList = async (params?: Record<string, any>) => {
*/
export const getGamesCount = async (params?: Record<string, any>) => {
try {
return httpService.post('/games/count', params, { showLoading: true })
return httpService.post('/games/count', params, { showLoading: false })
} catch (error) {
console.error("列表数量获取失败:", error);
throw error;
@@ -68,7 +68,7 @@ export const getGamesCount = async (params?: Record<string, any>) => {
export const getSearchHistory = async (params) => {
try {
// 调用HTTP服务获取搜索历史记录
return httpService.post('/games/search_history', params, { showLoading: true })
return httpService.post('/games/search_history', params, { showLoading: false })
} catch (error) {
// 捕获并打印错误信息
console.error("历史记录获取失败:", error);
@@ -84,7 +84,7 @@ export const getSearchHistory = async (params) => {
export const clearHistory = async (params) => {
try {
// 调用HTTP服务清除搜索历史记录
return httpService.post('/games/search_history/delete_all', params, { showLoading: true })
return httpService.post('/games/search_history/delete_all', params, { showLoading: false })
} catch (error) {
// 捕获并打印错误信息
console.error("清除历史记录失败:", error);

View File

@@ -40,23 +40,23 @@ export interface UnreadMountResponse {
class NoticeService {
// 获取用户消息通知列表
async getNotificationList({ notification_type, is_read }: NoticeListParams): Promise<ApiResponse<NoticeListResponse>> {
return httpService.post("/notifications/list", { notification_type, is_read }, { showLoading: true });
return httpService.post("/notifications/list", { notification_type, is_read }, { showLoading: false });
}
// 获取消息通知详情
async getNotificationDetail(notification_id: number): Promise<ApiResponse<Notice>> {
return httpService.post("/notifications/detail", { notification_id }, { showLoading: true });
return httpService.post("/notifications/detail", { notification_id }, { showLoading: false });
}
// 标记消息为已读
async markNotificationRead({ notification_ids, mark_all }: MarkReadParams): Promise<ApiResponse<{ marked_count: number }>> {
return httpService.post("/notifications/mark_read", { notification_ids, mark_all }, { showLoading: true });
return httpService.post("/notifications/mark_read", { notification_ids, mark_all }, { showLoading: false });
}
// 删除消息通知
async delNotification({ notification_ids, delete_all }: DeleteParams): Promise<ApiResponse<{ deleted_count: number }>> {
return httpService.post("/notifications/delete", { notification_ids, delete_all }, { showLoading: true });
return httpService.post("/notifications/delete", { notification_ids, delete_all }, { showLoading: false });
}
// 获取未读消息数量
async getNotificationUnreadCount(): Promise<ApiResponse<UnreadMountResponse>> {
return httpService.post("/notifications/unread_count", {}, { showLoading: true });
return httpService.post("/notifications/unread_count", {}, { showLoading: false });
}
}