feat: 首页-微信官方的渲染bug

This commit is contained in:
huxiaoshuang
2022-11-25 16:27:48 +08:00
parent 10112ed5d4
commit 2651275abd
4 changed files with 69 additions and 57 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -46,9 +46,8 @@ const Home = () => {
// 系统配置 // 系统配置
const [systemConfig, setsystemConfig] = useState<any>({}); const [systemConfig, setsystemConfig] = useState<any>({});
const [openid,setopenid]=useState() const [openid, setopenid] = useState();
const [isIn,setisIn]=useState(false) const [isIn, setisIn] = useState(false);
const onChange = (e) => {}; const onChange = (e) => {};
@@ -66,29 +65,33 @@ const Home = () => {
withShareTicket: true, withShareTicket: true,
success() {}, success() {},
}); });
getsystemConfig(); //获取系统配置
getdetails(); //获取活动详情
}, []); }, []);
useEffect(()=>{ useEffect(() => {
getsystemConfig(); //获取系统配置
setTimeout(()=>{
getdetails(); //获取活动详情
},500)
}, []);
useEffect(() => {
Taro.cloud.callFunction({ Taro.cloud.callFunction({
name: "getOpenid", name: "getOpenid",
complete: async (res: any) => { complete: async (res: any) => {
console.log("callFunction test result: ", res); console.log("callFunction test result: ", res);
let newopenid = res?.result?.event?.userInfo?.openId; let newopenid = res?.result?.event?.userInfo?.openId;
setopenid(newopenid) setopenid(newopenid);
}, },
}); });
},[isIn]) }, [isIn]);
const getdetails = async () => { const getdetails = async () => {
let objParams = { let objParams = {
tableName: "details", tableName: "details",
// id: "80516fb66370bcf300b8f43c5f4dd52b", // id: "80516fb66370bcf300b8f43c5f4dd52b",
okFun: (res: any) => { okFun: async (res: any) => {
console.log("details--", res); console.log("details--", res);
setdetails(res?.data ?? []); await setdetails(res?.data ?? []);
}, },
}; };
await getTable(objParams); await getTable(objParams);
@@ -98,9 +101,9 @@ const Home = () => {
let objParams = { let objParams = {
tableName: "systemConfig", tableName: "systemConfig",
// id: "80516fb66370bcf300b8f43c5f4dd52b", // id: "80516fb66370bcf300b8f43c5f4dd52b",
okFun: (res: any) => { okFun: async (res: any) => {
console.log("systemConfig--", res); console.log("systemConfig--", res);
setsystemConfig(res?.data ?? []); await setsystemConfig(res?.data ?? []);
}, },
}; };
await getTable(objParams); await getTable(objParams);
@@ -115,13 +118,12 @@ const Home = () => {
success: (res: any) => { success: (res: any) => {
// get resource ID // get resource ID
console.log("res", res?.fileID); console.log("res", res?.fileID);
checkIn({imageUrl:res?.fileID}) checkIn({ imageUrl: res?.fileID });
// 跳转到目的页面,打开新页面 // 跳转到目的页面,打开新页面
// Taro.navigateTo({ // Taro.navigateTo({
// url: `/pages/home/components/CheckIn/index?fileID=${res?.fileID}`, // url: `/pages/home/components/CheckIn/index?fileID=${res?.fileID}`,
// }); // });
}, },
fail: (err: any) => { fail: (err: any) => {
// handle error // handle error
@@ -145,7 +147,7 @@ const Home = () => {
}; };
// 签到 // 签到
const checkIn = async (data:any) => { const checkIn = async (data: any) => {
let postData = { let postData = {
tableName: "userInfo", tableName: "userInfo",
keyValue: { openId: openid }, keyValue: { openId: openid },
@@ -160,7 +162,7 @@ const Home = () => {
...(res?.data?.[0]?.checkInArr ?? []), ...(res?.data?.[0]?.checkInArr ?? []),
{ {
imageUrl: data?.imageUrl, imageUrl: data?.imageUrl,
checkTime :new Date().valueOf(),//打卡时间 checkTime: new Date().valueOf(), //打卡时间
// remark: fieldValues?.remark, // remark: fieldValues?.remark,
// location: address, // location: address,
}, },
@@ -174,7 +176,6 @@ const Home = () => {
duration: 2000, duration: 2000,
onClose: () => { onClose: () => {
// 跳转到打卡页面 // 跳转到打卡页面
// 返回首页 [上一页] // 返回首页 [上一页]
// Taro.navigateBack({ // Taro.navigateBack({
// delta: 1, // delta: 1,
@@ -317,11 +318,19 @@ const Home = () => {
paginationVisible paginationVisible
onChange={onChange} onChange={onChange}
> >
{(systemConfig?.[0]?.imagesArr ?? []).map((item: any, index: any) => ( {systemConfig?.length > 0 &&
<SwiperItem key={`swiper#demo1${index}`}> (systemConfig?.[0]?.imagesArr ?? []).map(
<Image src={item?.url} fit="cover" width="100%" height="200px" /> (item: any, index: any) => (
</SwiperItem> <SwiperItem key={`swiper#demo1${index}`}>
))} <Image
src={item?.url}
fit="cover"
width="100%"
height="200px"
/>
</SwiperItem>
)
)}
</Swiper> </Swiper>
</View> </View>
@@ -334,7 +343,7 @@ const Home = () => {
onClick={async () => { onClick={async () => {
// getLocation(); // getLocation();
let isin: any = await phoneLogin(); let isin: any = await phoneLogin();
setisIn(true) setisIn(true);
console.log("isin", isin); console.log("isin", isin);
if (isin) { if (isin) {
chooseImage(); chooseImage();
@@ -425,21 +434,25 @@ const Home = () => {
</Tabs> */} </Tabs> */}
{/* 截取数组2个活动 */} {/* 截取数组2个活动 */}
{details.splice(0, 2).map((item: any, index: any) => { {details?.length > 0 && (
return ( <View>
<View {(details?.splice(0, 2) ?? []).map((item: any, index: any) => {
onClick={() => { return (
console.log("Card"); <View
Taro.navigateTo({ onClick={() => {
url: `/pages/activityList/components/details/index?id=${item?._id}`, console.log("Card");
}); Taro.navigateTo({
}} url: `/pages/activityList/components/details/index?id=${item?._id}`,
> });
{/* 活动卡片 */} }}
<ActiveCard dataSource={item} /> >
</View> {/* 活动卡片 */}
); <ActiveCard dataSource={item} />
})} </View>
);
})}
</View>
)}
{/* 直播live专区 */} {/* 直播live专区 */}
{/* <View>视频号直播</View> */} {/* <View>视频号直播</View> */}

View File

@@ -207,7 +207,7 @@ const my = (props: any) => {
{type !== "people" || {type !== "people" ||
(true && ( (true && (
<Cell <Cell
icon="manager" icon="star"
title="打卡记录" title="打卡记录"
isLink isLink
onClick={() => { onClick={() => {
@@ -226,7 +226,7 @@ const my = (props: any) => {
/> />
))} ))}
<Cell {/* <Cell
icon="star" icon="star"
title="我参与的" title="我参与的"
isLink isLink
@@ -243,24 +243,21 @@ const my = (props: any) => {
// }); // });
} }
}} }}
/> /> */}
<Cell <Cell
icon="manager" icon="manager"
title="申请成为领队" title="申请成为领队"
isLink isLink
onClick={() => { onClick={() => {
if (isin) { Toast.fail({
// 跳转到目的页面,打开新页面 message: "首次参加活动后,可申请成为领队",
// Taro.navigateTo({ selector: "#vanToast-demo2",
// url: "/pages/my/components/CheckinDetail/index", });
// }); // 跳转到目的页面,打开新页面
} else { // Taro.navigateTo({
// Toast.fail({ // url: "/pages/formSubmit/index",
// message: "请先登录", // });
// selector: "#vanToast-demo2",
// });
}
}} }}
/> />
@@ -293,7 +290,7 @@ const my = (props: any) => {
/> />
)} )}
<Cell {/* <Cell
icon="friends" icon="friends"
title="关于我们" title="关于我们"
isLink isLink
@@ -303,7 +300,9 @@ const my = (props: any) => {
url: "/pages/my/components/AbountUs/index", url: "/pages/my/components/AbountUs/index",
}); });
}} }}
/> /> */}
{/* <Cell {/* <Cell
icon="setting" icon="setting"
title="版本日志" title="版本日志"