"use client"; import React from "react"; import { Form, Input, Toast } from "antd-mobile"; import { cryptoPassword, generateSignature } from "@/utils/crypto"; import { useRouter, useSearchParams } from "next/navigation"; import baseRequest from "@/utils/baseRequest"; export default function SetPassword() { const router = useRouter(); const searchParams = useSearchParams(); //点击登录 const handleSubmit = async (value) => { if (!value.password) { Toast.show({ content: "请完善信息", }); return; } if (value.password.length < 8) { Toast.show({ content: "密码不得小于8位", }); return; } if (value.password.length > 15) { Toast.show({ content: "密码不得大于15位", }); return; } if (!value.confirm_password) { Toast.show({ content: "请再次输入您的密码", }); return; } if (value.password != value.confirm_password) { Toast.show({ content: "两次输入密码不一致", }); return; } const mobile_phone = searchParams.get("mobile_phone"); const region_code = searchParams.get("region_code"); if (!mobile_phone || !region_code) { Toast.show({ content: "设置出错,请下载app设置密码", }); return; } //MD5加密密码 const encryptedPassword = cryptoPassword(value.password); //设置密码并登录 const base = baseRequest(); const signature = generateSignature({ mobile_phone: mobile_phone, region_code: region_code, new_password: encryptedPassword, ...base, }); try { const response = await fetch( `/api/login/set_password?signature=${signature}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ mobile_phone: mobile_phone, region_code: region_code, new_password: encryptedPassword, ...base, }), } ); const data = await response.json(); console.log(data); if (data.ret === -1) { Toast.show({ content: data.msg, }); router.back(); return; } router.back(); } catch (error) { console.error(error); } }; return (

设置密码

请牢记密码

密码


确认密码

router.back()} className="text-base inline-block text-secondary text-center font-medium mt-4" > 跳过

); }