zhangzf 2 viikkoa sitten
vanhempi
commit
88056c5ab8
1 muutettua tiedostoa jossa 78 lisäystä ja 0 poistoa
  1. 78 0
      src/app/(public)/customer/account/edit/page.tsx

+ 78 - 0
src/app/(public)/customer/account/edit/page.tsx

@@ -0,0 +1,78 @@
+"use client";
+import React from "react";
+import { useState } from "react";
+const AccountEditPage = () => {
+  // 统一表单对象
+  const [form, setForm] = useState({
+    firstname: "",
+    lastname: "",
+    email: "",
+    password: "",
+  });
+
+  // 统一处理所有input变化
+  const handleChange = (e) => {
+    const { name, value } = e.target;
+    setForm((prev) => ({
+      ...prev,
+      [name]: value,
+    }));
+  };
+
+  // 统一提交
+  const handleSubmit = (e) => {
+    e.preventDefault();
+    // 直接拿form所有数据
+    console.log("表单数据:", form);
+  };
+  return (
+    <div className="w-full h-full">
+      <form className="overflow-hidden" onSubmit={handleSubmit}>
+        <input name="form_key" type="hidden" value="kW7wucXHATeeem75"></input>
+        <div className="bg-[#f8f8f8] p-[20px_10px]">
+          <div className="text-start">*Name</div>
+          <div className="flex justify-between items-center">
+            <input
+              name="firstname" // 必须和state字段对应
+              value={form.firstname}
+              onChange={handleChange}
+              placeholder="firstname"
+              className="w-43 h-11 rounded-sm border border-solid border-[rgba(102,102,102,1)] indent-4 text-[#a6a6a6] text-base leading-11 font-normal"
+            />
+            <input
+              name="lastname" // 必须和state字段对应
+              value={form.lastname}
+              onChange={handleChange}
+              placeholder="lastname"
+              className="w-43 h-11 rounded-sm border border-solid border-[rgba(102,102,102,1)] indent-4 text-[#a6a6a6] text-base leading-11 font-normal box-[unset]"
+            />
+          </div>
+          <div>
+            <input
+              name="email" // 必须和state字段对应
+              value={form.email}
+              onChange={handleChange}
+              placeholder="用户名"
+            />
+          </div>
+
+          <div>
+            <input
+              type="password"
+              name="password" // name对应key
+              value={form.password}
+              onChange={handleChange}
+              placeholder="密码"
+            />
+          </div>
+
+          <button type="submit" style={{ marginTop: 15 }}>
+            登录提交
+          </button>
+        </div>
+      </form>
+    </div>
+  );
+};
+
+export default AccountEditPage;