diff --git a/src/components/UserInfo/index.tsx b/src/components/UserInfo/index.tsx index 72cce14..869e102 100644 --- a/src/components/UserInfo/index.tsx +++ b/src/components/UserInfo/index.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from "react"; -import Taro from "@tarojs/taro"; +import Taro, { useDidShow } from "@tarojs/taro"; import { View, Text, Image, Button } from "@tarojs/components"; import "./index.scss"; @@ -48,6 +48,7 @@ interface UserInfoCardProps { on_message?: () => void; on_share?: () => void; set_user_info?: (info: Partial) => void; + onTab?: (tab) => void; } // 处理编辑用户信息 @@ -65,6 +66,7 @@ export const UserInfoCard: React.FC = ({ on_message, on_share, set_user_info, + onTab, }) => { const { updateUserInfo } = useUserActions(); console.log("UserInfoCard 用户信息:", user_info); @@ -78,9 +80,11 @@ export const UserInfoCard: React.FC = ({ useState(false); // 表单状态 - const [form_data] = useState>({ - ...user_info, - }); + const [form_data, set_form_data] = useState>({}); + + useDidShow(() => { + set_form_data({ ...user_info }) + }) // 职业数据 const professions = useProfessions(); @@ -181,6 +185,9 @@ export const UserInfoCard: React.FC = ({ !Array.isArray(field) ) { await updateUserInfo({ ...field }); + set_form_data((prev) => { + return { ...prev, ...field } + }) // 更新本地状态 // setFormData((prev) => ({ ...prev, ...field })); // setUserInfo((prev) => ({ ...prev, ...field })); @@ -188,6 +195,9 @@ export const UserInfoCard: React.FC = ({ // 调用更新用户信息接口,只传递修改的字段 const update_data = { [field as string]: value }; await updateUserInfo(update_data); + set_form_data((prev) => { + return { ...prev, ...update_data } + }) // 更新本地状态 // setFormData((prev) => ({ ...prev, [field as string]: value })); // setUserInfo((prev) => ({ ...prev, [field as string]: value })); @@ -323,13 +333,17 @@ export const UserInfoCard: React.FC = ({ 粉丝 - + onTab?.("hosted")} + > {user_info.stats?.hosted_games_count || 0} 主办 - + onTab?.("participated")} + > {user_info.stats?.participated_games_count || 0} @@ -384,12 +398,18 @@ export const UserInfoCard: React.FC = ({ { + handle_open_edit_modal("gender"); + }} /> )} {user_info.gender === "1" && ( { + handle_open_edit_modal("gender"); + }} /> )} @@ -404,7 +424,11 @@ export const UserInfoCard: React.FC = ({ ) : null} {user_info.ntrp_level !== "0" ? ( - + { + handle_open_edit_modal("ntrp_level"); + }}> {`NTRP ${user_info.ntrp_level}`} ) : is_current_user ? ( @@ -418,7 +442,11 @@ export const UserInfoCard: React.FC = ({ ) : null} {user_info.occupation ? ( - + { + handle_open_edit_modal("occupation"); + }}> {user_info.occupation.split(" ")[2]} @@ -434,7 +462,9 @@ export const UserInfoCard: React.FC = ({ ) : null} {user_info.country || user_info.province || user_info.city ? ( - + handle_open_edit_modal("location")}> {`${user_info.province}${user_info.city}`} ) : is_current_user ? ( diff --git a/src/container/listContainer/index.scss b/src/container/listContainer/index.scss index 170724e..b1db915 100644 --- a/src/container/listContainer/index.scss +++ b/src/container/listContainer/index.scss @@ -30,4 +30,25 @@ font-weight: 500; line-height: 24px; } + + .collapse-btn { + width: 100%; + font-family: PingFang SC; + font-weight: 400; + font-style: Regular; + font-size: 14px; + letter-spacing: 0.38px; + color: rgba(0, 0, 0, .3); + height: 40px; + display: flex; + justify-content: center; + align-items: center; + Image { + width: 16px; + height: 16px; + } + &:not(.fold) Image { + transform: rotate(180deg); + } + } } \ No newline at end of file diff --git a/src/container/listContainer/index.tsx b/src/container/listContainer/index.tsx index e926649..28f5d1d 100644 --- a/src/container/listContainer/index.tsx +++ b/src/container/listContainer/index.tsx @@ -1,4 +1,4 @@ -import { View } from "@tarojs/components"; +import { View, Text, Image } from "@tarojs/components"; import ListCard from "@/components/ListCard"; import ListLoadError from "@/components/ListLoadError"; import ListCardSkeleton from "@/components/ListCardSkeleton"; @@ -8,7 +8,7 @@ import { setStorage, getStorage } from "@/store/storage"; import { NTRPTestEntryCard } from "@/components"; import { EvaluateScene } from "@/store/evaluateStore"; import "./index.scss"; -import { useRef, useEffect } from "react"; +import { useRef, useEffect, useState } from "react"; const ListContainer = (props) => { const { @@ -23,9 +23,14 @@ const ListContainer = (props) => { emptyText, btnText, btnImg, + style, + collapse = false, + defaultShowNum, } = props; const timerRef = useRef(null); + const [showNumber, setShowNumber] = useState(0) + const userInfo = useUserInfo(); useReachBottom(() => { @@ -38,6 +43,14 @@ const ListContainer = (props) => { // }, 500); }); + useEffect(() => { + setShowNumber( + () => { + return defaultShowNum === undefined ? data?.length : defaultShowNum + + }) + }, [data]) + useEffect(() => { return () => { if (timerRef.current) { @@ -97,6 +110,8 @@ const ListContainer = (props) => { ); } + showNumber !== undefined && (list = list.slice(0, showNumber)) + // 渲染数据 return ( <> @@ -113,7 +128,7 @@ const ListContainer = (props) => { }; return ( - + {renderList(data)} {/* 显示骨架屏 */} {loading && renderSkeleton()} @@ -122,7 +137,20 @@ const ListContainer = (props) => { {renderList(recommendList)} */} {/* 到底了 */} - {data?.length > 0 && 到底了} + {collapse ? + data?.length > defaultShowNum ? + data?.length > showNumber ? + { setShowNumber(data?.length) }}> + 更多球局 + + : + { setShowNumber(defaultShowNum) }}> + 收起 + + + : + null + : data?.length > 0 && 到底了} ); }; diff --git a/src/static/userInfo/fold.svg b/src/static/userInfo/fold.svg new file mode 100644 index 0000000..68fedb6 --- /dev/null +++ b/src/static/userInfo/fold.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/user_pages/downloadBill/index.tsx b/src/user_pages/downloadBill/index.tsx index d9b1990..aed74b4 100644 --- a/src/user_pages/downloadBill/index.tsx +++ b/src/user_pages/downloadBill/index.tsx @@ -219,10 +219,10 @@ const DownloadBill: React.FC = () => { transaction_sub_type, date_range, }); - const { bill_example, fileName } = res.data; + const { fileUrl, fileName } = res.data; // 调用下载文件接口 wx.downloadFile({ - url: bill_example, // 文件路径 + url: fileUrl, // 文件路径 success: function (res) { // 只有200状态码表示下载成功 if (res.statusCode === 200) { diff --git a/src/user_pages/myself/index.tsx b/src/user_pages/myself/index.tsx index b321f47..4718a88 100644 --- a/src/user_pages/myself/index.tsx +++ b/src/user_pages/myself/index.tsx @@ -173,6 +173,10 @@ const MyselfPage: React.FC = () => { }); }; + const handleOnTab = (tab) => { + setActiveTab(tab) + } + return ( {/* 主要内容 */} @@ -184,6 +188,7 @@ const MyselfPage: React.FC = () => { is_current_user={is_current_user} is_following={is_following} on_follow={handle_follow} + onTab={handleOnTab} /> {/* 球局订单和收藏功能 */} @@ -219,9 +224,8 @@ const MyselfPage: React.FC = () => { 我主办的 setActiveTab("participated")} > 我参与的 @@ -243,7 +247,10 @@ const MyselfPage: React.FC = () => { btnImg="ICON_ADD" reload={goPublish} isShowNoData={game_records.length === 0} - loadMoreMatches={() => {}} + loadMoreMatches={() => { }} + collapse={true} + style={{ paddingBottom: 0, overflow: "hidden" }} + defaultShowNum={3} /> @@ -267,7 +274,10 @@ const MyselfPage: React.FC = () => { error={null} errorImg="ICON_LIST_EMPTY" isShowNoData={ended_game_records.length === 0} - loadMoreMatches={() => {}} + loadMoreMatches={() => { }} + collapse={true} + style={{ paddingBottom: "90px", overflow: "hidden" }} + defaultShowNum={3} /> {/* */} diff --git a/src/user_pages/other/index.tsx b/src/user_pages/other/index.tsx index c2540fa..84aa223 100644 --- a/src/user_pages/other/index.tsx +++ b/src/user_pages/other/index.tsx @@ -205,6 +205,10 @@ const OtherUserPage: React.FC = () => { }&nickname=${user_info.nickname || ""}`, }); }; + + const handleOnTab = (tab) => { + setActiveTab(tab) + } // 处理球局详情 // const handle_game_detail = (game_id: string) => { @@ -236,6 +240,7 @@ const OtherUserPage: React.FC = () => { is_following={is_following} on_follow={handle_follow} on_message={handle_send_message} + onTab={handleOnTab} /> @@ -265,6 +270,9 @@ const OtherUserPage: React.FC = () => { errorImg="ICON_LIST_EMPTY" emptyText="暂无消息,去互动看看吧" loadMoreMatches={() => {}} + collapse={true} + style={{ paddingBottom: 0, overflow: "hidden" }} + defaultShowNum={3} /> {/* */} @@ -301,6 +309,9 @@ const OtherUserPage: React.FC = () => { errorImg="ICON_LIST_EMPTY" emptyText="暂无消息,去互动看看吧" loadMoreMatches={() => {}} + collapse={true} + style={{ paddingBottom: "90px", overflow: "hidden" }} + defaultShowNum={3} /> {/* */} diff --git a/src/user_pages/setTransactionPassword/index.tsx b/src/user_pages/setTransactionPassword/index.tsx index 8a1871d..e4c3710 100644 --- a/src/user_pages/setTransactionPassword/index.tsx +++ b/src/user_pages/setTransactionPassword/index.tsx @@ -92,9 +92,8 @@ const SetTransactionPassword: React.FC = () => { title: "设置交易密码成功", icon: "success", }); - Taro.redirectTo({ - url: "/user_pages/wallet/index", - }); + let delta = handleType === "set" ? 1 : 2; + Taro.navigateBack({ delta }) } catch (error) { Taro.showToast({ title: "设置交易密码失败",