feat: 添加用户活动记录
This commit is contained in:
@@ -242,73 +242,146 @@ const details = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const detailPost = () => {
|
||||
// 立即报名
|
||||
let postData = {
|
||||
// env: "any",
|
||||
id: id,
|
||||
tableName: "details",
|
||||
objData: {
|
||||
// ..._.cloneDeep(dataSource),
|
||||
useridArr: [..._.cloneDeep(dataSource?.useridArr ?? []), openId],
|
||||
peopleArr: [
|
||||
..._.cloneDeep(dataSource?.peopleArr ?? []),
|
||||
{
|
||||
openid: openId,
|
||||
status: "1", //待审核
|
||||
},
|
||||
],
|
||||
},
|
||||
okFun: (res: any) => {
|
||||
console.log("res333", res);
|
||||
|
||||
// 报名成功
|
||||
Toast.success({
|
||||
message: "报名成功,审核中",
|
||||
selector: "#vanToast-demo2",
|
||||
onClose: () => {
|
||||
// 更新用户信息
|
||||
userinfoPost();
|
||||
setShow(true);
|
||||
// 刷新数据
|
||||
getDetail();
|
||||
|
||||
// 返回首页 [上一页]
|
||||
// Taro.navigateBack({
|
||||
// // url: "/pages/home/index",
|
||||
// delta: 1,
|
||||
// });
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
console.log("postData", postData);
|
||||
updateTableid({ ...postData });
|
||||
};
|
||||
|
||||
// 更新用户参与活动记录
|
||||
const userinfoPost = () => {
|
||||
let postData = {
|
||||
tableName: "userInfo",
|
||||
keyValue: { openId: openId },
|
||||
okFun: (res: any) => {
|
||||
let newobj = {
|
||||
tableName: "userInfo",
|
||||
id: res?.data?.[0]?._id,
|
||||
objData: {
|
||||
activeidArr: [...(res?.data?.activeidArr ?? []), openId],
|
||||
},
|
||||
okFun: (okFunres: any) => {
|
||||
console.log("添加用户记录", okFunres);
|
||||
//
|
||||
},
|
||||
};
|
||||
updateTableid({ ...newobj });
|
||||
},
|
||||
};
|
||||
|
||||
// 查询openid
|
||||
getTable({ ...postData });
|
||||
};
|
||||
|
||||
return (
|
||||
<View>
|
||||
{Object.keys(dataSource)?.length>0? <View className={`detailContent`}>
|
||||
<View>
|
||||
<View>{dataSource?.title}</View>
|
||||
<Image
|
||||
width="100%"
|
||||
height="180px"
|
||||
fit="cover"
|
||||
// src="https://img.yzcdn.cn/vant/cat.jpeg"
|
||||
src={dataSource?.images?.[0]?.url}
|
||||
/>
|
||||
{Object.keys(dataSource)?.length > 0 ? (
|
||||
<View className={`detailContent`}>
|
||||
<View>
|
||||
<Cell
|
||||
icon="clock"
|
||||
title={`开始时间 ${
|
||||
dataSource?.startTime
|
||||
? moment(dataSource?.startTime).format("YYYY-MM-DD HH:mm:ss")
|
||||
: ""
|
||||
}`}
|
||||
// isLink
|
||||
// linkType="navigateTo"
|
||||
// url="/pages/dashboard/index"
|
||||
/>
|
||||
<Cell
|
||||
icon="clock"
|
||||
title={`结束时间 ${
|
||||
dataSource?.endTime
|
||||
? moment(dataSource?.endTime).format("YYYY-MM-DD HH:mm:ss")
|
||||
: ""
|
||||
}`}
|
||||
// isLink
|
||||
// linkType="navigateTo"
|
||||
// url="/pages/dashboard/index"
|
||||
/>
|
||||
<Cell
|
||||
isLink
|
||||
icon="location"
|
||||
title={`${dataSource?.address}`}
|
||||
linkType="navigateTo"
|
||||
url="/pages/dashboard/index"
|
||||
onClick={() => {
|
||||
Taro.openLocation({
|
||||
latitude: dataSource?.latitude,
|
||||
longitude: dataSource?.longitude,
|
||||
scale: 18,
|
||||
});
|
||||
}}
|
||||
<View>{dataSource?.title}</View>
|
||||
<Image
|
||||
width="100%"
|
||||
height="180px"
|
||||
fit="cover"
|
||||
// src="https://img.yzcdn.cn/vant/cat.jpeg"
|
||||
src={dataSource?.images?.[0]?.url}
|
||||
/>
|
||||
<View>
|
||||
<Cell
|
||||
icon="clock"
|
||||
title={`开始时间 ${
|
||||
dataSource?.startTime
|
||||
? moment(dataSource?.startTime).format(
|
||||
"YYYY-MM-DD HH:mm:ss"
|
||||
)
|
||||
: ""
|
||||
}`}
|
||||
// isLink
|
||||
// linkType="navigateTo"
|
||||
// url="/pages/dashboard/index"
|
||||
/>
|
||||
<Cell
|
||||
icon="clock"
|
||||
title={`结束时间 ${
|
||||
dataSource?.endTime
|
||||
? moment(dataSource?.endTime).format("YYYY-MM-DD HH:mm:ss")
|
||||
: ""
|
||||
}`}
|
||||
// isLink
|
||||
// linkType="navigateTo"
|
||||
// url="/pages/dashboard/index"
|
||||
/>
|
||||
<Cell
|
||||
isLink
|
||||
icon="location"
|
||||
title={`${dataSource?.address}`}
|
||||
linkType="navigateTo"
|
||||
url="/pages/dashboard/index"
|
||||
onClick={() => {
|
||||
Taro.openLocation({
|
||||
latitude: dataSource?.latitude,
|
||||
longitude: dataSource?.longitude,
|
||||
scale: 18,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
|
||||
<Cell
|
||||
icon="friends"
|
||||
// title={`已报名人数 ${dataSource?.useridArr?.length ?? 0}`}
|
||||
title={`已报名人数 ${
|
||||
(dataSource?.peopleArr ?? []).filter((item: any) => {
|
||||
return item?.status === "2" || item?.status === "1";
|
||||
})?.length >> 0
|
||||
}`}
|
||||
<Cell
|
||||
icon="friends"
|
||||
// title={`已报名人数 ${dataSource?.useridArr?.length ?? 0}`}
|
||||
title={`已报名人数 ${
|
||||
(dataSource?.peopleArr ?? []).filter((item: any) => {
|
||||
return item?.status === "2" || item?.status === "1";
|
||||
})?.length >> 0
|
||||
}`}
|
||||
|
||||
// isLink
|
||||
// linkType="navigateTo"
|
||||
// url="/pages/dashboard/index"
|
||||
/>
|
||||
</View>
|
||||
// isLink
|
||||
// linkType="navigateTo"
|
||||
// url="/pages/dashboard/index"
|
||||
/>
|
||||
</View>
|
||||
|
||||
{/* 头像列表 */}
|
||||
{/* <View className="imagesArr">
|
||||
{/* 头像列表 */}
|
||||
{/* <View className="imagesArr">
|
||||
{[1, 2, 3, 4].map((item: any) => {
|
||||
return (
|
||||
<Image
|
||||
@@ -321,64 +394,64 @@ const details = () => {
|
||||
);
|
||||
})}
|
||||
</View> */}
|
||||
</View>
|
||||
{/* 富文本 */}
|
||||
<View onClick={() => {}} className="RichText">
|
||||
{/* <View>{dataSource?.[0]?.actTitle}</View> */}
|
||||
</View>
|
||||
{/* 富文本 */}
|
||||
<View onClick={() => {}} className="RichText">
|
||||
{/* <View>{dataSource?.[0]?.actTitle}</View> */}
|
||||
|
||||
<RichText nodes={dataSource?.richText} />
|
||||
</View>
|
||||
<RichText nodes={dataSource?.richText} />
|
||||
</View>
|
||||
|
||||
<View>
|
||||
<Dialog
|
||||
id="vanDialog3"
|
||||
title="长按二维码识别"
|
||||
showCancelButton={false}
|
||||
showConfirmButton={false}
|
||||
// confirmButtonOpenType="getUserInfo"
|
||||
show={show}
|
||||
onClose={() => setShow(false)}
|
||||
>
|
||||
<View className="wechatCode">
|
||||
<Image
|
||||
showMenuByLongpress={true}
|
||||
width={300}
|
||||
height={300}
|
||||
src={dataSource?.qrCode}
|
||||
// src='cloud://citynew-0givkbre03955d8c.6369-citynew-0givkbre03955d8c-1253655588/images/touxiang/download-1.jpg'
|
||||
></Image>
|
||||
<View>
|
||||
<Dialog
|
||||
id="vanDialog3"
|
||||
title="长按二维码识别"
|
||||
showCancelButton={false}
|
||||
showConfirmButton={false}
|
||||
// confirmButtonOpenType="getUserInfo"
|
||||
show={show}
|
||||
onClose={() => setShow(false)}
|
||||
>
|
||||
<View className="wechatCode">
|
||||
<Image
|
||||
showMenuByLongpress={true}
|
||||
width={300}
|
||||
height={300}
|
||||
src={dataSource?.qrCode}
|
||||
// src='cloud://citynew-0givkbre03955d8c.6369-citynew-0givkbre03955d8c-1253655588/images/touxiang/download-1.jpg'
|
||||
></Image>
|
||||
|
||||
<Button
|
||||
style={{ width: "130px", marginTop: "20px" }}
|
||||
type="primary"
|
||||
round
|
||||
size="small"
|
||||
onClick={() => {
|
||||
setShow(false);
|
||||
}}
|
||||
>
|
||||
关闭
|
||||
</Button>
|
||||
</View>
|
||||
</Dialog>
|
||||
</View>
|
||||
<Button
|
||||
style={{ width: "130px", marginTop: "20px" }}
|
||||
type="primary"
|
||||
round
|
||||
size="small"
|
||||
onClick={() => {
|
||||
setShow(false);
|
||||
}}
|
||||
>
|
||||
关闭
|
||||
</Button>
|
||||
</View>
|
||||
</Dialog>
|
||||
</View>
|
||||
|
||||
<View>
|
||||
<Dialog
|
||||
id="vanDialog4"
|
||||
title="取消后,再次报名,会严格审核"
|
||||
// showCancelButton={false}
|
||||
// showConfirmButton={false}
|
||||
// confirmButtonOpenType="getUserInfo"
|
||||
show={canelshow}
|
||||
onClose={() => setShow(false)}
|
||||
onConfirm={()=>{
|
||||
// 取消报名
|
||||
canelActive()
|
||||
}}
|
||||
>
|
||||
<View className="wechatCode">
|
||||
{/*
|
||||
<View>
|
||||
<Dialog
|
||||
id="vanDialog4"
|
||||
title="取消后,再次报名,会严格审核"
|
||||
// showCancelButton={false}
|
||||
// showConfirmButton={false}
|
||||
// confirmButtonOpenType="getUserInfo"
|
||||
show={canelshow}
|
||||
onClose={() => setShow(false)}
|
||||
onConfirm={() => {
|
||||
// 取消报名
|
||||
canelActive();
|
||||
}}
|
||||
>
|
||||
<View className="wechatCode">
|
||||
{/*
|
||||
<Button
|
||||
style={{ width: "130px", marginTop: "20px" }}
|
||||
type="primary"
|
||||
@@ -391,121 +464,82 @@ const details = () => {
|
||||
>
|
||||
我想好了
|
||||
</Button> */}
|
||||
</View>
|
||||
</Dialog>
|
||||
</View>
|
||||
</View>
|
||||
</Dialog>
|
||||
</View>
|
||||
|
||||
{/* 调试按钮 */}
|
||||
{/* <Cell title="组件调用" onClick={() => setShow(true)} /> */}
|
||||
{/* 调试按钮 */}
|
||||
{/* <Cell title="组件调用" onClick={() => setShow(true)} /> */}
|
||||
|
||||
<View
|
||||
className={`detailBtn`}
|
||||
style={{ bottom: `${bottomheight ?? 0}px` }}
|
||||
>
|
||||
{/* style={{width:'375px'}} */}
|
||||
<Button
|
||||
type={disable ? "warning" : "primary"}
|
||||
block
|
||||
// disabled={disable}
|
||||
onClick={() => {
|
||||
if (disable) {
|
||||
setShow(true);
|
||||
return false;
|
||||
}
|
||||
// if (isCheckin) {
|
||||
if (status === "2") {
|
||||
setcanelshow(true)
|
||||
return false;
|
||||
}
|
||||
|
||||
// 放鸽子
|
||||
if (status === "4") {
|
||||
Toast.fail({
|
||||
message: "再次报名需审核!",
|
||||
selector: "#vanToast-demo2",
|
||||
duration: 2000,
|
||||
onClose: () => {
|
||||
// 跳转到目的页面,打开新页面
|
||||
setShow(true);
|
||||
},
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
let isin: any = phoneLogin();
|
||||
if (!isin) {
|
||||
//重新登录- 跳转到我的页面
|
||||
Toast.fail({
|
||||
message: "请先登录",
|
||||
selector: "#vanToast-demo2",
|
||||
duration: 2000,
|
||||
onClose: () => {
|
||||
// 跳转到目的页面,打开新页面
|
||||
Taro.navigateTo({
|
||||
url: "/pages/my/index",
|
||||
});
|
||||
},
|
||||
});
|
||||
} else {
|
||||
console.log("id", id);
|
||||
// 立即报名
|
||||
let postData = {
|
||||
// env: "any",
|
||||
id: id,
|
||||
tableName: "details",
|
||||
objData: {
|
||||
// ..._.cloneDeep(dataSource),
|
||||
useridArr: [
|
||||
..._.cloneDeep(dataSource?.useridArr ?? []),
|
||||
openId,
|
||||
],
|
||||
peopleArr: [
|
||||
..._.cloneDeep(dataSource?.peopleArr ?? []),
|
||||
{
|
||||
openid: openId,
|
||||
status: "1", //待审核
|
||||
},
|
||||
],
|
||||
},
|
||||
okFun: (res: any) => {
|
||||
console.log("res333", res);
|
||||
// 报名成功
|
||||
Toast.success({
|
||||
message: "报名成功,审核中",
|
||||
selector: "#vanToast-demo2",
|
||||
onClose: () => {
|
||||
setShow(true);
|
||||
// 刷新数据
|
||||
getDetail();
|
||||
|
||||
// 返回首页 [上一页]
|
||||
// Taro.navigateBack({
|
||||
// // url: "/pages/home/index",
|
||||
// delta: 1,
|
||||
// });
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
console.log("postData", postData);
|
||||
updateTableid({ ...postData });
|
||||
}
|
||||
}}
|
||||
<View
|
||||
className={`detailBtn`}
|
||||
style={{ bottom: `${bottomheight ?? 0}px` }}
|
||||
>
|
||||
{/* 立即参加 */}
|
||||
{btnContent()}
|
||||
{/* {`立即报名`} */}
|
||||
</Button>
|
||||
{/* style={{width:'375px'}} */}
|
||||
<Button
|
||||
type={disable ? "warning" : "primary"}
|
||||
block
|
||||
// disabled={disable}
|
||||
onClick={() => {
|
||||
if (disable) {
|
||||
setShow(true);
|
||||
return false;
|
||||
}
|
||||
// if (isCheckin) {
|
||||
if (status === "2") {
|
||||
setcanelshow(true);
|
||||
return false;
|
||||
}
|
||||
|
||||
<Toast id="vanToast-demo2" />
|
||||
// 放鸽子
|
||||
if (status === "4") {
|
||||
Toast.fail({
|
||||
message: "再次报名需审核!",
|
||||
selector: "#vanToast-demo2",
|
||||
duration: 2000,
|
||||
onClose: () => {
|
||||
// 跳转到目的页面,打开新页面
|
||||
setShow(true);
|
||||
},
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
let isin: any = phoneLogin();
|
||||
if (!isin) {
|
||||
//重新登录- 跳转到我的页面
|
||||
Toast.fail({
|
||||
message: "请先登录",
|
||||
selector: "#vanToast-demo2",
|
||||
duration: 2000,
|
||||
onClose: () => {
|
||||
// 跳转到目的页面,打开新页面
|
||||
Taro.navigateTo({
|
||||
url: "/pages/my/index",
|
||||
});
|
||||
},
|
||||
});
|
||||
} else {
|
||||
console.log("id", id);
|
||||
// 立即报名
|
||||
detailPost();
|
||||
}
|
||||
}}
|
||||
>
|
||||
{/* 立即参加 */}
|
||||
{btnContent()}
|
||||
{/* {`立即报名`} */}
|
||||
</Button>
|
||||
|
||||
<Toast id="vanToast-demo2" />
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
:
|
||||
<View>
|
||||
{/* 骨架屏 */}
|
||||
<Skeleton title={true} row={16} />
|
||||
</View>}
|
||||
) : (
|
||||
<View>
|
||||
{/* 骨架屏 */}
|
||||
<Skeleton title={true} row={16} />
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -36,6 +36,8 @@ const my = (props: any) => {
|
||||
const [detailsData, setdetailsData] = useState<any>([]); //活动详情
|
||||
const [currentIndex, setcurrentIndex] = useState(0);
|
||||
const [isin, setisin] = useState(true); //0初始 1未登录 2有手机号
|
||||
const [activeidArr , setactiveidArr ] = useState<any>([]); //用户参与的活动
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
getok();
|
||||
@@ -109,6 +111,8 @@ const my = (props: any) => {
|
||||
definePageConfig({
|
||||
navigationBarTitleText: "我的",
|
||||
});
|
||||
|
||||
// 获取活动详情
|
||||
// getDetails();
|
||||
}, []);
|
||||
|
||||
@@ -182,26 +186,25 @@ const my = (props: any) => {
|
||||
)}
|
||||
</View>
|
||||
|
||||
{/* <View>
|
||||
<View>
|
||||
<Tabs
|
||||
sticky={true}
|
||||
active={currentIndex}
|
||||
onClick={(e: any) => {
|
||||
console.log("e", e);
|
||||
setcurrentIndex(e?.detail?.index ?? 0);
|
||||
|
||||
}}
|
||||
>
|
||||
<Tab title="待审核">
|
||||
<View>{CardCom()}</View>
|
||||
</Tab>
|
||||
<Tab title="已报名">
|
||||
{/* <Tab title="已报名">
|
||||
<View>222</View>
|
||||
</Tab>
|
||||
</Tab> */}
|
||||
<Tab title="待参加">333</Tab>
|
||||
<Tab title="已结束">44</Tab>
|
||||
</Tabs>
|
||||
</View> */}
|
||||
</View>
|
||||
|
||||
<View className="cellArr">
|
||||
<Cell
|
||||
|
||||
@@ -36,6 +36,9 @@ export const addTable: any = ({ env, tableName, objData, okFun }: Typeint) => {
|
||||
success: (res: any) => {
|
||||
okFun(res);
|
||||
},
|
||||
fail:(err:any)=>{
|
||||
console.log('err',err)
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -86,6 +89,9 @@ export const getTableid: any = ({
|
||||
success: (res: any) => {
|
||||
okFun(res);
|
||||
},
|
||||
fail:(err:any)=>{
|
||||
console.log('err',err)
|
||||
}
|
||||
});
|
||||
}else{
|
||||
nowtable
|
||||
@@ -93,6 +99,9 @@ export const getTableid: any = ({
|
||||
success: (res: any) => {
|
||||
okFun(res);
|
||||
},
|
||||
fail:(err:any)=>{
|
||||
console.log('err',err)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -118,6 +127,9 @@ export const updateTableid: any = ({
|
||||
success: (res: any) => {
|
||||
okFun(res);
|
||||
},
|
||||
fail:(err:any)=>{
|
||||
console.log('err',err)
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user