's'
This commit is contained in:
@@ -335,6 +335,31 @@ const Index = () => {
|
|||||||
// window.alert(value)
|
// window.alert(value)
|
||||||
setopen(value);
|
setopen(value);
|
||||||
};
|
};
|
||||||
|
const createUser = (username, password) => {
|
||||||
|
Taro.request({
|
||||||
|
method: "POST",
|
||||||
|
url: `${process.env.TARO_API_API}/create_user`,
|
||||||
|
data: {
|
||||||
|
username: username,
|
||||||
|
password: password || "123456", // 如果没有传入密码,则使用默认密码
|
||||||
|
},
|
||||||
|
header: {
|
||||||
|
"content-type": "application/json",
|
||||||
|
},
|
||||||
|
success: function (res) {
|
||||||
|
console.log("用户创建结果:", res.data);
|
||||||
|
window.localStorage.setItem("username", res?.data?.username);
|
||||||
|
window.localStorage.setItem("password", res?.data?.password);
|
||||||
|
},
|
||||||
|
fail: function (err) {
|
||||||
|
console.error("创建用户失败:", err);
|
||||||
|
Taro.showToast({
|
||||||
|
title: "请求失败",
|
||||||
|
icon: "error",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const payh5 = (type, total_fee = 1000) => {
|
const payh5 = (type, total_fee = 1000) => {
|
||||||
// console.log("111");
|
// console.log("111");
|
||||||
@@ -372,8 +397,16 @@ const Index = () => {
|
|||||||
function (res) {
|
function (res) {
|
||||||
// 支付成功
|
// 支付成功
|
||||||
if (res.err_msg == "get_brand_wcpay_request:ok") {
|
if (res.err_msg == "get_brand_wcpay_request:ok") {
|
||||||
|
// 新增memos用户
|
||||||
|
// 动态生成用户名,若 username 没传入则使用默认值 "user" + 当前时间戳
|
||||||
|
const finalUsername = `user${Date.now()}`;
|
||||||
|
createUser(finalUsername, "123456");
|
||||||
window.localStorage.setItem(type, 1); //订单类型 book/meetup/video/vip
|
window.localStorage.setItem(type, 1); //订单类型 book/meetup/video/vip
|
||||||
|
window.localStorage.setItem("username", finalUsername);
|
||||||
|
window.localStorage.setItem("password", "123456");
|
||||||
WeixinJSBridge.call("closeWindow");
|
WeixinJSBridge.call("closeWindow");
|
||||||
|
} else {
|
||||||
|
window.alert("支付取消/失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -386,6 +419,41 @@ const Index = () => {
|
|||||||
url: "/pages/book/index",
|
url: "/pages/book/index",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
const handleCopyUsername = () => {
|
||||||
|
Taro.setClipboardData({
|
||||||
|
data: window.localStorage.getItem("username"), // 复制账号
|
||||||
|
success: () => {
|
||||||
|
Taro.showToast({
|
||||||
|
title: "账号已复制",
|
||||||
|
icon: "success",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
Taro.showToast({
|
||||||
|
title: "复制失败",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCopyPassword = () => {
|
||||||
|
Taro.setClipboardData({
|
||||||
|
data: "123456", // 复制密码
|
||||||
|
success: () => {
|
||||||
|
Taro.showToast({
|
||||||
|
title: "密码已复制",
|
||||||
|
icon: "success",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
Taro.showToast({
|
||||||
|
title: "复制失败",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -477,7 +545,6 @@ const Index = () => {
|
|||||||
</AtButton>
|
</AtButton>
|
||||||
) : (
|
) : (
|
||||||
<View className="vipcode">
|
<View className="vipcode">
|
||||||
<Image className="vipcodeImg" src={hackrobot}></Image>
|
|
||||||
<View
|
<View
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
window.location.href = `https://memos.hackrobot.org`;
|
window.location.href = `https://memos.hackrobot.org`;
|
||||||
@@ -485,12 +552,15 @@ const Index = () => {
|
|||||||
>
|
>
|
||||||
👉星球地址: memos.hackrobot.org
|
👉星球地址: memos.hackrobot.org
|
||||||
</View>
|
</View>
|
||||||
|
<View>账号:{window.localStorage.getItem("username")}</View>
|
||||||
|
<Button onClick={handleCopyUsername}>复制账号</Button>
|
||||||
|
<View>密码:{"123456"}</View>{" "}
|
||||||
<View>
|
<View>
|
||||||
添加
|
添加
|
||||||
<span style={{ color: "green" }}>微信好友: hackrobot</span>
|
<span style={{ color: "green" }}>微信好友: hackrobot</span>
|
||||||
</View>
|
</View>
|
||||||
<View>获取 账号</View>
|
<Image className="vipcodeImg" src={hackrobot}></Image>
|
||||||
|
{/* <View>获取 账号</View> */}
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
Reference in New Issue
Block a user