|
|
@@ -0,0 +1,129 @@
|
|
|
+"use client"
|
|
|
+
|
|
|
+import React, { useState } from "react"
|
|
|
+import { Form, Input, Button, App, ConfigProvider } from "antd"
|
|
|
+import { clientPost } from "@/utils/clientRequest"
|
|
|
+
|
|
|
+const { TextArea } = Input
|
|
|
+
|
|
|
+interface ServiceFormValues {
|
|
|
+ name: string
|
|
|
+ phone: string
|
|
|
+ content: string
|
|
|
+}
|
|
|
+
|
|
|
+function ServiceForm() {
|
|
|
+ const [form] = Form.useForm<ServiceFormValues>()
|
|
|
+ const [loading, setLoading] = useState(false)
|
|
|
+ const { message } = App.useApp()
|
|
|
+
|
|
|
+ const onFinish = async (values: ServiceFormValues) => {
|
|
|
+ setLoading(true)
|
|
|
+ try {
|
|
|
+ const res = await clientPost("/webSite/save", values)
|
|
|
+ if (res.code === 200) {
|
|
|
+ message.success("您的咨询已提交,我们会尽快联系您!")
|
|
|
+ form.resetFields()
|
|
|
+ } else {
|
|
|
+ message.error(res.msg || "提交失败,请稍后重试")
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ message.error("提交出错,请检查网络连接")
|
|
|
+ } finally {
|
|
|
+ setLoading(false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div className="bg-white/5 backdrop-blur-sm p-6 rounded-2xl border border-white/10 shadow-2xl">
|
|
|
+ <Form
|
|
|
+ form={form}
|
|
|
+ layout="vertical"
|
|
|
+ onFinish={onFinish}
|
|
|
+ requiredMark={false}
|
|
|
+ autoComplete="off"
|
|
|
+ >
|
|
|
+ <div className="grid grid-cols-2 gap-4">
|
|
|
+ <Form.Item
|
|
|
+ label={<span className="text-gray-300 font-medium text-sm">联系人姓名</span>}
|
|
|
+ name="name"
|
|
|
+ className="mb-4"
|
|
|
+ rules={[{ required: true, message: "请输入您的姓名" }]}
|
|
|
+ >
|
|
|
+ <Input
|
|
|
+ placeholder="请输入您的姓名"
|
|
|
+ className="h-10 border-white/20 bg-white/5 text-white placeholder:text-gray-500 text-sm"
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+
|
|
|
+ <Form.Item
|
|
|
+ label={<span className="text-gray-300 font-medium text-sm">联系电话</span>}
|
|
|
+ name="phone"
|
|
|
+ className="mb-4"
|
|
|
+ rules={[
|
|
|
+ { required: true, message: "请输入您的手机号码" },
|
|
|
+ { pattern: /^1[3-9]\d{9}$/, message: "请输入正确的手机号码格式" }
|
|
|
+ ]}
|
|
|
+ >
|
|
|
+ <Input
|
|
|
+ placeholder="请输入您的手机号码"
|
|
|
+ className="h-10 border-white/20 bg-white/5 text-white placeholder:text-gray-500 text-sm"
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <Form.Item
|
|
|
+ label={<span className="text-gray-300 font-medium text-sm">留言备注</span>}
|
|
|
+ name="content"
|
|
|
+ className="mb-4"
|
|
|
+ >
|
|
|
+ <TextArea
|
|
|
+ placeholder="请输入您的其他需求或备注信息(选填)"
|
|
|
+ rows={2}
|
|
|
+ className="border-white/20 bg-white/5 text-white placeholder:text-gray-500 hover:border-blue-500 text-sm"
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+
|
|
|
+ <Form.Item className="mb-0">
|
|
|
+ <Button
|
|
|
+ type="primary"
|
|
|
+ htmlType="submit"
|
|
|
+ loading={loading}
|
|
|
+ className="w-full h-11 bg-orange-500 hover:bg-orange-600 border-none text-base font-bold rounded-xl transition-all duration-300 transform hover:scale-[1.01] active:scale-[0.99] shadow-lg shadow-orange-500/30"
|
|
|
+ >
|
|
|
+ 免费咨询报价
|
|
|
+ </Button>
|
|
|
+ </Form.Item>
|
|
|
+ </Form>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+export default function ServiceFormClient() {
|
|
|
+ return (
|
|
|
+ <App>
|
|
|
+ <ConfigProvider
|
|
|
+ theme={{
|
|
|
+ token: {
|
|
|
+ colorTextPlaceholder: "rgba(255, 255, 255, 0.4)",
|
|
|
+ colorBgContainer: "rgba(255, 255, 255, 0.1)",
|
|
|
+ colorBorder: "rgba(255, 255, 255, 0.2)",
|
|
|
+ colorText: "#fff",
|
|
|
+ },
|
|
|
+ components: {
|
|
|
+ Input: {
|
|
|
+ hoverBorderColor: "#3b82f6",
|
|
|
+ activeBorderColor: "#3b82f6",
|
|
|
+ colorBgContainer: "rgba(255, 255, 255, 0.05)",
|
|
|
+ },
|
|
|
+ TextArea: {
|
|
|
+ colorText: "#fff",
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <ServiceForm />
|
|
|
+ </ConfigProvider>
|
|
|
+ </App>
|
|
|
+ )
|
|
|
+}
|