login.tsx 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. import React, { useState } from "react";
  2. import { Form, Input, Button, Tabs, message } from "antd";
  3. import Icon from "@ant-design/icons";
  4. import styles from "./login.module.css";
  5. // import { sendCode, loginBySendCode, login } from "../../http/sso";
  6. import { login } from "../../http/sso";
  7. import LogoIcon from "@src/assets/images/login/logo.svg?react";
  8. import GonganIcon from "@src/assets/images/login/gongan.png";
  9. const LoginPage: React.FC = () => {
  10. // const [form] = Form.useForm();
  11. // const [loading, setLoading] = useState(false);
  12. // const [sendingCode, setSendingCode] = useState(false);
  13. // const [countdown, setCountdown] = useState(0);
  14. const [accountForm] = Form.useForm();
  15. const [accountLoading, setAccountLoading] = useState(false);
  16. // const handlePhoneLogin = async (values: any) => {
  17. // try {
  18. // setLoading(true);
  19. // const { phone, code } = values;
  20. // const success = await loginBySendCode(phone, code);
  21. // if (success) {
  22. // // Redirect will be handled by the login function
  23. // }
  24. // } catch (error) {
  25. // message.error((error as Error)?.message || "登录失败,请重试");
  26. // } finally {
  27. // setLoading(false);
  28. // }
  29. // };
  30. // const handleSendCode = async () => {
  31. // try {
  32. // const phone = form.getFieldValue("phone");
  33. // if (!phone) {
  34. // message.error("请输入手机号");
  35. // return;
  36. // }
  37. // if (!/^1[3-9]\d{9}$/.test(phone)) {
  38. // message.error("请输入正确的手机号");
  39. // return;
  40. // }
  41. // setSendingCode(true);
  42. // const success = await sendCode(phone);
  43. // if (success) {
  44. // let count = 60;
  45. // setCountdown(count);
  46. // const timer = setInterval(() => {
  47. // count -= 1;
  48. // setCountdown(count);
  49. // if (count <= 0) {
  50. // clearInterval(timer);
  51. // setCountdown(0);
  52. // }
  53. // }, 1000);
  54. // }
  55. // } catch (error) {
  56. // message.error(
  57. // (error as Error)?.message || "发送验证码失败,请重试"
  58. // );
  59. // } finally {
  60. // setSendingCode(false);
  61. // }
  62. // };
  63. const handleAccountLogin = async (values: any) => {
  64. try {
  65. setAccountLoading(true);
  66. const { account, password } = values;
  67. const success = await login(account, password);
  68. if (success) {
  69. // Redirect will be handled by the login function
  70. }
  71. } catch (error) {
  72. message.error((error as Error)?.message || "登录失败,请重试");
  73. } finally {
  74. setAccountLoading(false);
  75. }
  76. };
  77. return (
  78. <div className={styles.loginContainer}>
  79. <div className={styles.leftSection}>
  80. <div className={styles.logoSection}>
  81. <Icon component={LogoIcon} />
  82. <span>票圈内容合作平台</span>
  83. </div>
  84. <div className={styles.platformTitle}>票圈内容合作平台</div>
  85. </div>
  86. <div className={styles.rightSection}>
  87. <div className={styles.loginBox}>
  88. <div className={styles.tabsContainer}>
  89. <Tabs
  90. defaultActiveKey="account"
  91. items={[
  92. // {
  93. // key: "phone",
  94. // label: "验证码登录",
  95. // children: (
  96. // <Form
  97. // form={form}
  98. // name="phone_login"
  99. // onFinish={handlePhoneLogin}
  100. // layout="vertical"
  101. // size="large"
  102. // >
  103. // <Form.Item
  104. // name="phone"
  105. // rules={[
  106. // {
  107. // required: true,
  108. // message: "请输入手机号",
  109. // },
  110. // {
  111. // pattern:
  112. // /^1[3-9]\d{9}$/,
  113. // message:
  114. // "请输入正确的手机号",
  115. // },
  116. // ]}
  117. // >
  118. // <Input
  119. // variant="borderless"
  120. // addonBefore={
  121. // <div
  122. // className={
  123. // styles.phonePrefix
  124. // }
  125. // >
  126. // +86
  127. // </div>
  128. // }
  129. // placeholder="手机号"
  130. // className={
  131. // styles.phoneInput +
  132. // " border-b-[1px] border-b-gray-400"
  133. // }
  134. // />
  135. // </Form.Item>
  136. // <Form.Item
  137. // name="code"
  138. // rules={[
  139. // {
  140. // required: true,
  141. // message: "请输入验证码",
  142. // },
  143. // ]}
  144. // >
  145. // <div className={styles.codeRow}>
  146. // <Input
  147. // variant="borderless"
  148. // placeholder="验证码"
  149. // className={
  150. // styles.codeInput + ' !rounded-none !border-b-[1px] !border-b-gray-400'
  151. // }
  152. // />
  153. // <Button
  154. // onClick={handleSendCode}
  155. // disabled={countdown > 0}
  156. // loading={sendingCode}
  157. // type="text"
  158. // className={
  159. // styles.getCodeBtn
  160. // }
  161. // >
  162. // {countdown > 0
  163. // ? `${countdown}s`
  164. // : "获取验证码"}
  165. // </Button>
  166. // </div>
  167. // </Form.Item>
  168. // <Form.Item>
  169. // <Button
  170. // type="primary"
  171. // htmlType="submit"
  172. // block
  173. // loading={loading}
  174. // className={styles.loginBtn}
  175. // >
  176. // 登录
  177. // </Button>
  178. // </Form.Item>
  179. // </Form>
  180. // ),
  181. // },
  182. {
  183. key: "account",
  184. label: "账号登录",
  185. children: (
  186. <Form
  187. form={accountForm}
  188. name="account_login"
  189. onFinish={handleAccountLogin}
  190. layout="vertical"
  191. size="large"
  192. >
  193. <Form.Item
  194. name="account"
  195. rules={[
  196. {
  197. required: true,
  198. message: "请输入账号",
  199. },
  200. ]}
  201. >
  202. <Input
  203. placeholder="账号"
  204. variant="borderless"
  205. className="!rounded-none !border-b-[1px] !border-b-gray-400"
  206. />
  207. </Form.Item>
  208. <Form.Item
  209. name="password"
  210. rules={[
  211. {
  212. required: true,
  213. message: "请输入密码",
  214. },
  215. ]}
  216. >
  217. <Input.Password
  218. placeholder="密码"
  219. variant="borderless"
  220. className="!rounded-none !border-b-[1px] !border-b-gray-400"
  221. />
  222. </Form.Item>
  223. <Form.Item>
  224. <Button
  225. type="primary"
  226. htmlType="submit"
  227. block
  228. loading={accountLoading}
  229. className={styles.loginBtn}
  230. >
  231. 登录
  232. </Button>
  233. </Form.Item>
  234. </Form>
  235. ),
  236. },
  237. ]}
  238. />
  239. </div>
  240. </div>
  241. </div>
  242. <div className={styles.decorationBottom}>
  243. {/* You can add a decoration image here */}
  244. <p>© 2020 湖南为趣时代网络科技有限公司</p>
  245. <p>
  246. <span className="link cursor-pointer" onClick={() => window.open('https://rescdn.yishihui.com/agreement/piaoquantvservice.html')}>
  247. 用户服务协议
  248. </span>
  249. <span className="mx-1">|</span>
  250. <span className="link cursor-pointer" onClick={() => window.open('https://rescdn.yishihui.com/agreement/piaoquantvagreement.html')}>
  251. 隐私政策
  252. </span>
  253. <span className="mx-1">|</span>
  254. <span className="link cursor-pointer" onClick={() => window.open('https://www.piaoquantv.com/upload/help')}>
  255. 帮助中心
  256. </span>
  257. <span className="mx-1">|</span>
  258. 客服及举报: 0731-85679198、18974809627
  259. <span className="mx-1">|</span>
  260. 举报邮箱:piaoquankefu@new.piaoquantv.com
  261. </p>
  262. <p className="flex items-center justify-center">
  263. <span className="link cursor-pointer" onClick={() => window.open('https://beian.miit.gov.cn/')}>
  264. 湘ICP备16013107-06号
  265. </span>
  266. | <img style={{ width: '16px', height: '16px' }} src={GonganIcon} />
  267. <span className="link cursor-pointer" onClick={() => window.open('https://beian.mps.gov.cn/#/query/webSearch')}>
  268. 湘公网安备:43019002001624
  269. </span>
  270. </p>
  271. </div>
  272. </div>
  273. );
  274. };
  275. export default LoginPage;