diff --git a/app/api/ckb/join/route.ts b/app/api/ckb/join/route.ts new file mode 100644 index 0000000..fc8d99c --- /dev/null +++ b/app/api/ckb/join/route.ts @@ -0,0 +1,86 @@ +import { type NextRequest, NextResponse } from "next/server" +import crypto from "crypto" + +// 存客宝API配置 +const CKB_API_KEY = "fyngh-ecy9h-qkdae-epwd5-rz6kd" +const CKB_API_URL = "https://ckbapi.quwanzhi.com/v1/api/scenarios" + +// 生成签名 +function generateSign(apiKey: string, timestamp: number): string { + const signStr = `${apiKey}${timestamp}` + return crypto.createHash("md5").update(signStr).digest("hex") +} + +// 不同类型对应的source标签 +const sourceMap: Record = { + team: "团队招募", + investor: "资源对接", + mentor: "导师顾问", +} + +const tagsMap: Record = { + team: "切片团队,团队招募", + investor: "资源对接,资源群", + mentor: "导师顾问,咨询服务", +} + +export async function POST(request: NextRequest) { + try { + const body = await request.json() + const { type, phone, name, wechatId, remark } = body + + // 验证必填参数 + if (!type || !phone) { + return NextResponse.json({ success: false, message: "缺少必填参数" }, { status: 400 }) + } + + // 验证类型 + if (!["team", "investor", "mentor"].includes(type)) { + return NextResponse.json({ success: false, message: "无效的加入类型" }, { status: 400 }) + } + + // 生成时间戳和签名 + const timestamp = Math.floor(Date.now() / 1000) + const sign = generateSign(CKB_API_KEY, timestamp) + + // 构建请求参数 + const requestBody = { + apiKey: CKB_API_KEY, + sign, + timestamp, + phone, + name: name || "", + wechatId: wechatId || "", + source: sourceMap[type], + remark: remark || `来自创业实验APP-${sourceMap[type]}`, + tags: tagsMap[type], + } + + // 调用存客宝API + const response = await fetch(CKB_API_URL, { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(requestBody), + }) + + const result = await response.json() + + if (response.ok && result.code === 0) { + return NextResponse.json({ + success: true, + message: `成功加入${sourceMap[type]}`, + data: result.data, + }) + } else { + return NextResponse.json({ + success: false, + message: result.message || "加入失败,请稍后重试", + }) + } + } catch (error) { + console.error("存客宝API调用失败:", error) + return NextResponse.json({ success: false, message: "服务器错误,请稍后重试" }, { status: 500 }) + } +} diff --git a/app/api/cunkebao/route.ts b/app/api/cunkebao/route.ts deleted file mode 100644 index 4a8156e..0000000 --- a/app/api/cunkebao/route.ts +++ /dev/null @@ -1,95 +0,0 @@ -import { type NextRequest, NextResponse } from "next/server" -import crypto from "crypto" - -// 存客宝API配置 -const CKB_CONFIG = { - apiKey: "fyngh-ecy9h-qkdae-epwd5-rz6kd", - apiUrl: "https://ckbapi.quwanzhi.com/v1/api/scenarios", -} - -// 生成签名 -function generateSign(apiKey: string, timestamp: number): string { - const signStr = `${apiKey}${timestamp}` - return crypto.createHash("md5").update(signStr).digest("hex") -} - -// 不同场景的source和tags配置 -const SCENARIO_CONFIG: Record = { - team: { - source: "卡若创业实验-切片团队招募", - tags: "切片团队,团队招募,创业合作", - }, - resource: { - source: "卡若创业实验-资源对接", - tags: "资源对接,资源群,商业合作", - }, - mentor: { - source: "卡若创业实验-导师顾问", - tags: "导师顾问,创业指导,商业咨询", - }, -} - -export async function POST(request: NextRequest) { - try { - const body = await request.json() - const { phone, name, scenario, remark } = body - - // 验证必填参数 - if (!phone) { - return NextResponse.json({ success: false, message: "手机号不能为空" }, { status: 400 }) - } - - if (!scenario || !SCENARIO_CONFIG[scenario]) { - return NextResponse.json({ success: false, message: "无效的场景类型" }, { status: 400 }) - } - - // 生成时间戳和签名 - const timestamp = Math.floor(Date.now() / 1000) - const sign = generateSign(CKB_CONFIG.apiKey, timestamp) - - // 获取场景配置 - const config = SCENARIO_CONFIG[scenario] - - // 构建请求体 - const requestBody = { - apiKey: CKB_CONFIG.apiKey, - sign, - timestamp, - phone, - name: name || "", - source: config.source, - remark: remark || `来自${config.source}`, - tags: config.tags, - } - - // 调用存客宝API - const response = await fetch(CKB_CONFIG.apiUrl, { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(requestBody), - }) - - const result = await response.json() - - if (response.ok && result.code === 0) { - return NextResponse.json({ - success: true, - message: "提交成功,我们会尽快与您联系", - data: result.data, - }) - } else { - return NextResponse.json( - { - success: false, - message: result.message || "提交失败,请稍后重试", - }, - { status: 400 }, - ) - } - } catch (error) { - console.error("存客宝API调用失败:", error) - return NextResponse.json({ success: false, message: "服务器错误,请稍后重试" }, { status: 500 }) - } -} diff --git a/app/match/page.tsx b/app/match/page.tsx index c7b643e..ef11ef1 100644 --- a/app/match/page.tsx +++ b/app/match/page.tsx @@ -1,8 +1,8 @@ "use client" -import { useState } from "react" +import { useState, useEffect } from "react" import { motion, AnimatePresence } from "framer-motion" -import { Mic, X } from "lucide-react" +import { Mic, X, CheckCircle, Loader2 } from "lucide-react" import { Home, List, User } from "lucide-react" import { useRouter } from "next/navigation" @@ -18,208 +18,109 @@ interface MatchUser { } const matchTypes = [ - { id: "team", label: "团队招募", icon: "🎮", color: "#4CAF50", scenario: "team" }, - { id: "resource", label: "资源对接", icon: "👥", color: "#7B61FF", scenario: "resource" }, - { id: "mentor", label: "导师顾问", icon: "❤️", color: "#E91E63", scenario: "mentor" }, + { id: "partner", label: "创业合伙", icon: "⭐", color: "#00E5FF", joinable: false }, + { id: "investor", label: "资源对接", icon: "👥", color: "#7B61FF", joinable: true }, + { id: "mentor", label: "导师顾问", icon: "❤️", color: "#E91E63", joinable: true }, + { id: "team", label: "团队招募", icon: "🎮", color: "#4CAF50", joinable: true }, ] -interface JoinModalProps { - isOpen: boolean - onClose: () => void - type: (typeof matchTypes)[0] +// 获取本地存储的手机号 +const getStoredPhone = (): string => { + if (typeof window !== "undefined") { + return localStorage.getItem("user_phone") || "" + } + return "" } -function JoinModal({ isOpen, onClose, type }: JoinModalProps) { - const [phone, setPhone] = useState("") - const [name, setName] = useState("") - const [remark, setRemark] = useState("") - const [isSubmitting, setIsSubmitting] = useState(false) - const [submitResult, setSubmitResult] = useState<{ success: boolean; message: string } | null>(null) - - const handleSubmit = async () => { - if (!phone) { - setSubmitResult({ success: false, message: "请输入手机号" }) - return - } - - // 简单的手机号验证 - if (!/^1[3-9]\d{9}$/.test(phone)) { - setSubmitResult({ success: false, message: "请输入正确的手机号" }) - return - } - - setIsSubmitting(true) - setSubmitResult(null) - - try { - const response = await fetch("/api/cunkebao", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - phone, - name, - scenario: type.scenario, - remark, - }), - }) - - const result = await response.json() - setSubmitResult(result) - - if (result.success) { - // 成功后清空表单 - setPhone("") - setName("") - setRemark("") - // 3秒后关闭弹窗 - setTimeout(() => { - onClose() - setSubmitResult(null) - }, 3000) - } - } catch (error) { - setSubmitResult({ success: false, message: "网络错误,请稍后重试" }) - } finally { - setIsSubmitting(false) - } +// 保存手机号到本地存储 +const savePhone = (phone: string) => { + if (typeof window !== "undefined") { + localStorage.setItem("user_phone", phone) } - - if (!isOpen) return null - - const getTitle = () => { - switch (type.id) { - case "team": - return "加入切片团队" - case "resource": - return "加入资源群" - case "mentor": - return "预约导师顾问" - default: - return "加入" - } - } - - const getDescription = () => { - switch (type.id) { - case "team": - return "加入切片团队,一起创造价值,共享收益" - case "resource": - return "加入资源对接群,链接优质商业资源" - case "mentor": - return "预约一对一导师咨询,获取专业指导" - default: - return "" - } - } - - return ( - - - e.stopPropagation()} - > - {/* 头部 */} -
- -
- {type.icon} -

{getTitle()}

-
-

{getDescription()}

-
- - {/* 表单 */} -
-
- - setPhone(e.target.value)} - placeholder="请输入手机号" - className="w-full px-4 py-3 rounded-xl bg-black/30 border border-white/10 text-white placeholder-white/30 focus:border-[#00E5FF]/50 focus:outline-none transition-colors" - maxLength={11} - /> -
- -
- - setName(e.target.value)} - placeholder="请输入您的姓名" - className="w-full px-4 py-3 rounded-xl bg-black/30 border border-white/10 text-white placeholder-white/30 focus:border-[#00E5FF]/50 focus:outline-none transition-colors" - /> -
- -
- -