Login.js 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. import React, { Component } from 'react';
  2. import { connect } from 'dva';
  3. import { Form, Input, Modal, Button } from 'antd';
  4. import styles from './Login.less';
  5. import global from '@/global.less';
  6. import {
  7. failTip,
  8. sucTip,
  9. setLocalStorageTime,
  10. sldSvgIcon,
  11. saveSettleData,
  12. sldCheckMobile,
  13. getSldImgSet,sldComLanguage,mobile_reg
  14. } from '@/utils/utils';
  15. import router from 'umi/router';
  16. const FormItem = Form.Item;
  17. let admin_login_logo = require('../../assets/logo.png');
  18. let main_seller_center_logo_local = admin_login_logo;
  19. let com_img_login_info = getSldImgSet('com_img_login_info');
  20. if (com_img_login_info != '') {
  21. admin_login_logo = com_img_login_info.filter(item => item.name == 'main_seller_center_logo')[0].imageUrl || main_seller_center_logo_local;
  22. //admin_login_logo = com_img_info
  23. }
  24. const default_login_img = {
  25. admin_login_bg: require('../../assets/supplier_login_bg.jpg'),//登录背景
  26. admin_login_left_bg: require('../../assets/sld_login_left.png'),//登录左侧图片
  27. main_seller_center_logo: admin_login_logo,//登录页logo
  28. vendor_login_head_portrait: require('../../assets/touxiang@2x.png'),//操作成功头像
  29. };
  30. @connect(({ login, common }) => ({
  31. login, common,
  32. }))
  33. @Form.create()
  34. export default class LoginPage extends Component {
  35. state = {
  36. countDownC: false, //短信验证码防抖动
  37. countDownM: 0, //短信验证码倒计时
  38. type: 'account',
  39. autoLogin: true,
  40. login_img: {},
  41. error_info: '', //登录错误提示信息
  42. is_show_err: false,
  43. register_error_info: '', //注册错误提示信息
  44. is_show_registe_err: false,
  45. register_captcha: '',//注册——图形验证码
  46. login_captcha: '',//登录——图形验证码
  47. visibleModal: false,
  48. modal_type: 'register', //区分忘记密码和立即注册弹框
  49. visibleModalSuccess: false,
  50. //商家账号
  51. is_show_account_err:false,
  52. account_error_info:'',
  53. //手机号
  54. is_show_phone_err:false,
  55. phone_error_info:'',
  56. //验证码
  57. is_show_code_err:false,
  58. code_error_info:'',
  59. //短信验证码
  60. is_show_phonecode_err:false,
  61. phonecode_error_info:'',
  62. //邮箱
  63. is_show_email_err:false,
  64. email_error_info:'',
  65. //密码
  66. is_show_pwd_err:false,
  67. pwd_error_info:'',
  68. //确认密码
  69. is_show_comfirepwd_err:false,
  70. comfirepwd_error_info:'',
  71. // 提交注册按钮加载loading
  72. loading: false
  73. };
  74. register_captcha = '';//注册——图形验证码key
  75. login_captcha = '';//登录——图形验证码key
  76. componentDidMount() {
  77. localStorage.clear();
  78. this.get_init_img();
  79. this.get_login_out_img();
  80. this.getCaptcha('register_captcha');
  81. this.getCaptcha('login_captcha');
  82. }
  83. //获取图形验证码
  84. getCaptcha = (type) => {
  85. const { dispatch } = this.props;
  86. dispatch({
  87. type: 'common/get_captcha',
  88. callback: (res) => {
  89. if (res.state == 200) {
  90. this[type] = res.data.key;
  91. this.setState({ [type]: 'data:image/png;base64,' + res.data.captcha });
  92. }
  93. },
  94. });
  95. };
  96. //获取登陆页面logo
  97. get_login_out_img = () => {
  98. const { dispatch } = this.props;
  99. let { login_img } = this.state;
  100. dispatch({
  101. type: 'login/get_login_out_img',
  102. callback: (res) => {
  103. if (res.state == 200) {
  104. login_img = { ...default_login_img };
  105. res.data.map(item => {
  106. if (item.imageUrl) {
  107. login_img[item.name] = item.imageUrl;
  108. }
  109. });
  110. localStorage.setItem('com_img_login_info', JSON.stringify(res.data));
  111. this.setState({ login_img });
  112. }
  113. },
  114. });
  115. }
  116. //获取登陆后左上角logo
  117. get_init_img = () => {
  118. const { dispatch } = this.props;
  119. dispatch({
  120. type: 'login/get_login_img',
  121. callback: (res) => {
  122. if (res.state == 200) {
  123. localStorage.setItem('com_img_info', JSON.stringify(res.data));
  124. }
  125. },
  126. });
  127. };
  128. //登录操作
  129. handleSubmits = () => {
  130. this.props.form.validateFieldsAndScroll(['username', 'password', 'verifyCode'], (err, values) => {
  131. if (values.username == undefined || values.username == '') {
  132. failTip(`${sldComLanguage('用户名不能为空')}`);
  133. } else if (values.password == undefined || values.password == '') {
  134. failTip(`${sldComLanguage('密码不能为空')}`);
  135. } else if (values.verifyCode == undefined || values.verifyCode == '') {
  136. failTip(`${sldComLanguage('验证码不能为空')}`);
  137. } else {
  138. //用户登录
  139. values.verifyKey = this.login_captcha;
  140. const { dispatch } = this.props;
  141. dispatch({
  142. type: 'login/login',
  143. payload: { ...values },
  144. callback: (res) => {
  145. if (res.state == 200 || res.state == 267) {
  146. localStorage.setItem('sld_token', res.data.access_token);
  147. localStorage.setItem('sld_refresh_token', res.data.refresh_token);
  148. {
  149. setLocalStorageTime();
  150. }
  151. localStorage.setItem('user_info', JSON.stringify({ user_name: res.data.vendorName, vendorMobile: res.data.vendorMobile }));
  152. if (res.state == 267) {
  153. //登录的时候初始化入驻状态
  154. if (res.data.applyState == 0) {
  155. //未入驻
  156. saveSettleData('state', '');
  157. saveSettleData('cur_step', 0);
  158. router.push('/apply/settled_protocol');
  159. } else {
  160. saveSettleData('cur_step', 3);
  161. router.push('/apply/open_up');
  162. }
  163. } else {
  164. // dispatch({ type: 'global/get_site_list_data' });
  165. }
  166. } else {
  167. failTip(res.msg);
  168. this.getCaptcha('login_captcha');
  169. }
  170. },
  171. });
  172. }
  173. });
  174. };
  175. showDefault = (type) => {
  176. let { login_img } = this.state;
  177. login_img[type] = default_login_img[type];
  178. this.setState({ login_img });
  179. };
  180. handleUserRegisterAgreement = () => {
  181. window.open("/agreement/detail?type=1", '_blank');
  182. };
  183. handleUserPrivacyPolicy = () => {
  184. window.open("/agreement/detail?type=2", '_blank');
  185. };
  186. handleForgetPwd = () => {
  187. this.setState({
  188. title: `${sldComLanguage('找回密码')}`,
  189. visibleModal: true,
  190. modal_type: 'forgetPwd',
  191. });
  192. };
  193. handleRegister = () => {
  194. this.getCaptcha('register_captcha');
  195. this.setState({
  196. title: `${sldComLanguage('商家账号注册')}`,
  197. visibleModal: true,
  198. modal_type: 'register',
  199. });
  200. };
  201. //验证商家账户
  202. checkVendorName = (rule, value, callback) => {
  203. if(!value){
  204. callback('');
  205. this.setState({
  206. is_show_account_err: true,
  207. account_error_info: `${sldComLanguage('请输入商家账号')}`,
  208. });
  209. return;
  210. }
  211. if (value.length < 6 || value.length > 20) {
  212. callback('');
  213. this.setState({
  214. is_show_account_err: true,
  215. account_error_info: `${sldComLanguage('请输入6-20位的字母、数字或符号的商家账号')}`,
  216. });
  217. }
  218. // else if (!(/^[0-9a-zA-Z]+$/.test(value))) {
  219. // callback('');
  220. // this.setState({
  221. // is_show_account_err: true,
  222. // account_error_info: `${sldComLanguage('商户账号只能输入数字和字母')}`,
  223. // });
  224. // } else if (/^[0-9]+$/.test(value)) {
  225. // callback('');
  226. // this.setState({
  227. // is_show_account_err: true,
  228. // account_error_info: `${sldComLanguage('商户账号不能输入纯数字')}`,
  229. // });
  230. // } else if (/^[a-zA-Z]+$/.test(value)) {
  231. // callback('');
  232. // this.setState({
  233. // is_show_account_err: true,
  234. // account_error_info: `${sldComLanguage('商户账号不能输入纯字母')}`,
  235. // });
  236. // }
  237. else {
  238. callback();
  239. this.setState({
  240. is_show_account_err: false,
  241. account_error_info: `${sldComLanguage('')}`,
  242. });
  243. }
  244. };
  245. //验证图像验证码
  246. checkImgCode = (rule, value, callback) => {
  247. if(!value){
  248. callback('');
  249. this.setState({
  250. is_show_code_err: true,
  251. code_error_info: `${sldComLanguage('请输入图形验证码')}`,
  252. });
  253. return;
  254. }
  255. if (value.length < 4 || !(/^[0-9a-zA-Z]+$/.test(value))) {
  256. callback('');
  257. this.setState({
  258. is_show_code_err: true,
  259. code_error_info: `${sldComLanguage('请输入正确的图形验证码')}`,
  260. });
  261. }else {
  262. callback();
  263. this.setState({
  264. is_show_code_err: false,
  265. code_error_info: `${sldComLanguage('')}`,
  266. });
  267. }
  268. };
  269. //验证短信验证码
  270. checkSmsCode = (rule, value, callback) => {
  271. if(!value){
  272. callback('');
  273. this.setState({
  274. is_show_phonecode_err: true,
  275. phonecode_error_info: `${sldComLanguage('请输入短信验证码')}`,
  276. });
  277. return;
  278. }
  279. if (value.length < 6 || !(/^[0-9]+$/.test(value))) {
  280. callback('');
  281. this.setState({
  282. is_show_phonecode_err: true,
  283. phonecode_error_info: `${sldComLanguage('请输入正确的短信验证码')}`,
  284. });
  285. }else {
  286. callback();
  287. this.setState({
  288. is_show_phonecode_err: false,
  289. phonecode_error_info: `${sldComLanguage('')}`,
  290. });
  291. }
  292. };
  293. checkPassword = (rule, value, callback) => {
  294. if(!value){
  295. callback('');
  296. this.setState({
  297. is_show_pwd_err: true,
  298. pwd_error_info: `${sldComLanguage('请输入密码')}`,
  299. });
  300. return
  301. }
  302. if (value.length < 6 || value.length > 20) {
  303. callback('');
  304. this.setState({
  305. is_show_pwd_err: true,
  306. pwd_error_info: `${sldComLanguage('请输入6~20位密码')}`,
  307. });
  308. } else {
  309. if (/[\u4E00-\u9FA5]/g.test(value)) {
  310. callback('');
  311. this.setState({
  312. is_show_pwd_err: true,
  313. pwd_error_info: `${sldComLanguage('密码不可以有中文')}`,
  314. });
  315. }else if(!(/^\S*$/.test(value))){
  316. callback('');
  317. this.setState({
  318. is_show_pwd_err: true,
  319. pwd_error_info: `${sldComLanguage('密码中不可以有空格')}`,
  320. });
  321. }
  322. callback();
  323. this.setState({
  324. is_show_pwd_err: false,
  325. pwd_error_info: `${sldComLanguage('')}`,
  326. });
  327. }
  328. };
  329. //确认密码
  330. checkConfirmPassword = (rule, value, callback) => {
  331. if(!value){
  332. callback('');
  333. this.setState({
  334. is_show_comfirepwd_err: true,
  335. comfirepwd_error_info: `${sldComLanguage('请输入确认密码')}`,
  336. });
  337. return
  338. }
  339. if (value.length < 6 || value.length > 20) {
  340. callback('');
  341. this.setState({
  342. is_show_comfirepwd_err: true,
  343. comfirepwd_error_info: `${sldComLanguage('请输入6~20位密码')}`,
  344. });
  345. } else {
  346. if (/[\u4E00-\u9FA5]/g.test(value)) {
  347. callback('');
  348. this.setState({
  349. is_show_comfirepwd_err: true,
  350. comfirepwd_error_info: `${sldComLanguage('密码不可以有中文')}`,
  351. });
  352. }else if(!(/^\S*$/.test(value))){
  353. callback('');
  354. this.setState({
  355. is_show_comfirepwd_err: true,
  356. comfirepwd_error_info: `${sldComLanguage('密码中不可以有空格')}`,
  357. });
  358. }
  359. callback();
  360. this.setState({
  361. is_show_comfirepwd_err: false,
  362. comfirepwd_error_info: `${sldComLanguage('')}`,
  363. });
  364. }
  365. };
  366. //验证手机
  367. checkMobile = (rule, value, callback) => {
  368. if(!value){
  369. callback('');
  370. this.setState({
  371. is_show_phone_err: true,
  372. phone_error_info: `${sldComLanguage('请输入手机号')}`,
  373. });
  374. return
  375. }
  376. if (!mobile_reg.test(value)) {
  377. callback('');
  378. this.setState({
  379. is_show_phone_err: true,
  380. phone_error_info: `${sldComLanguage('请输入正确的手机号')}`,
  381. });
  382. } else {
  383. callback();
  384. this.setState({
  385. is_show_phone_err: false,
  386. phone_error_info: `${sldComLanguage('')}`,
  387. });
  388. }
  389. };
  390. //验证邮箱
  391. checkEmail = (rule, value, callback) => {
  392. let emailReg = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
  393. if (value&&value.length != undefined && value.length > 100) {
  394. callback('');
  395. this.setState({
  396. is_show_email_err: true,
  397. email_error_info: `${sldComLanguage('最多输入100位')}`,
  398. });
  399. }
  400. if (value && !emailReg.test(value)) {
  401. callback('');
  402. this.setState({
  403. is_show_email_err: true,
  404. email_error_info: `${sldComLanguage('请输入正确的邮箱')}`,
  405. });
  406. } else {
  407. callback();
  408. this.setState({
  409. is_show_email_err: false,
  410. email_error_info: `${sldComLanguage('')}`,
  411. });
  412. }
  413. };
  414. handleCancelModal = () => {
  415. this.setState({
  416. visibleModal: false,
  417. visibleModalSuccess: false,
  418. //商家账号
  419. is_show_account_err:false,
  420. account_error_info:'',
  421. //手机号
  422. is_show_phone_err:false,
  423. phone_error_info:'',
  424. //验证码
  425. is_show_code_err:false,
  426. code_error_info:'',
  427. //短信验证码
  428. is_show_phonecode_err:false,
  429. phonecode_error_info:'',
  430. //邮箱
  431. is_show_email_err:false,
  432. email_error_info:'',
  433. //密码
  434. is_show_pwd_err:false,
  435. pwd_error_info:'',
  436. //确认密码
  437. is_show_comfirepwd_err:false,
  438. comfirepwd_error_info:'',
  439. });
  440. this.props.form.resetFields();
  441. };
  442. handleOkModal = (e) => {
  443. e.preventDefault();
  444. const { modal_type } = this.state;
  445. if (modal_type == 'register') {
  446. this.handleOkModalRegister();
  447. } else {
  448. this.handleOkModalForget();
  449. }
  450. };
  451. handleOkModalRegister = () => {
  452. let _this = this;
  453. this.props.form.validateFieldsAndScroll(['vendorName', 'vendorPassword', 'vendorEmail', 'confirmPassword', 'vendorMobile', 'verifyCode', 'smsCode'], (err, values) => {
  454. if(!err){
  455. if (values.vendorPassword != values.confirmPassword) {
  456. this.setState({
  457. pwd_error_info: `${sldComLanguage('密码和确认密码不一致')}`,
  458. is_show_pwd_err: true,
  459. });
  460. return false;
  461. }
  462. this.setState({loading: true});
  463. values.verifyKey = this.register_captcha;
  464. const { dispatch } = this.props;
  465. dispatch({
  466. type: 'login/register',
  467. payload: values,
  468. callback: res => {
  469. if (res.state == 267) {
  470. {
  471. setLocalStorageTime();
  472. }
  473. localStorage.setItem('sld_token', res.data.access_token);
  474. localStorage.setItem('sld_refresh_token', res.data.refresh_token);
  475. localStorage.setItem('user_info', JSON.stringify({ user_name: values.vendorNam, vendorMobile: values.vendorMobile }));
  476. saveSettleData('state', '');
  477. saveSettleData('cur_step', 0);
  478. this.setState({
  479. visibleModal: false,
  480. visibleModalSuccess: true,
  481. }, () => {
  482. //自动请求更新验证码
  483. _this.getCaptcha('register_captcha');
  484. });
  485. } else {
  486. //自动请求更新验证码
  487. this.getCaptcha('register_captcha');
  488. if(res.msg == '短信验证码不正确'){
  489. this.setState({
  490. is_show_phonecode_err: true,
  491. phonecode_error_info: res.msg,
  492. });
  493. }
  494. else if(res.msg == '图形验证码不正确'){
  495. this.setState({
  496. is_show_code_err: true,
  497. code_error_info: res.msg,
  498. });
  499. }
  500. else if(res.msg == '该手机号已注册'){
  501. this.setState({
  502. is_show_phone_err: true,
  503. phone_error_info: res.msg,
  504. });
  505. }
  506. else{
  507. this.setState({
  508. is_show_registe_err: true,
  509. register_error_info: res.msg,
  510. });
  511. }
  512. }
  513. this.setState({loading: false});
  514. },
  515. });
  516. }else{
  517. }
  518. });
  519. };
  520. handleOkModalForget = () => {
  521. this.props.form.validateFieldsAndScroll(['vendorPassword', 'confirmPassword', 'vendorName', 'vendorMobile', 'smsCode'], (err, values) => {
  522. if (!err) {
  523. if (values.vendorPassword != values.confirmPassword) {
  524. this.setState({
  525. pwd_error_info: `${sldComLanguage('新密码和确认密码不一致')}`,
  526. is_show_pwd_err: true,
  527. });
  528. return false;
  529. }
  530. const { dispatch } = this.props;
  531. let param = {};
  532. param.mobile = values.vendorMobile;
  533. param.smsCode = values.smsCode;
  534. param.newPwd = values.vendorPassword;
  535. param.vendorName = values.vendorName;
  536. param.confirmPwd = values.confirmPassword;
  537. dispatch({
  538. type: 'login/lookForPwd',
  539. payload: param,
  540. callback: res => {
  541. if (res.state == 200) {
  542. sucTip(`${sldComLanguage('恭喜你!成功找回密码')}`);
  543. this.handleCancelModal();
  544. // this.setState({
  545. // visibleModal: false,
  546. // });
  547. } else {
  548. if(res.msg == '对不起,该手机号未注册' || res.msg == '该手机号已被其他账号绑定,请重新填写'){
  549. this.setState({
  550. is_show_phone_err: true,
  551. phone_error_info: res.msg,
  552. });
  553. }
  554. else if(res.msg == '短信验证码不正确'){
  555. this.setState({
  556. is_show_phonecode_err: true,
  557. phonecode_error_info: res.msg,
  558. });
  559. }
  560. else if(res.msg == '新密码与确认密码不一致'){
  561. this.setState({
  562. is_show_pwd_err: true,
  563. pwd_error_info: res.msg,
  564. });
  565. }
  566. else{
  567. this.setState({
  568. is_show_registe_err: true,
  569. register_error_info: res.msg,
  570. });
  571. }
  572. }
  573. },
  574. });
  575. }
  576. });
  577. };
  578. handleSuccessBtn = () => {
  579. let { modal_type } = this.state;
  580. if (modal_type == 'register') {
  581. //去入驻
  582. router.replace('/apply/settled_protocol');
  583. } else {
  584. //去登陆
  585. router.replace('/user/login');
  586. }
  587. };
  588. handleChangeRegister = () => {
  589. this.setState({
  590. is_show_registe_err: false,
  591. });
  592. };
  593. //倒计时
  594. countDown = () => {
  595. let { countDownM } = this.state;
  596. countDownM = countDownM - 1;
  597. let _this = this;
  598. this.setState({
  599. countDownM,
  600. }, () => {
  601. if (countDownM == 0) {
  602. clearTimeout(_this.timeOutId);
  603. } else {
  604. _this.timeOutId = setTimeout(() => _this.countDown(), 1000);
  605. }
  606. });
  607. };
  608. //获取短信验证码
  609. getSmsCode(type) {
  610. if (this.state.countDownC) {
  611. return;
  612. } else if (this.state.countDownM) {
  613. return;
  614. }
  615. let mobile = this.props.form.getFieldValue('vendorMobile');
  616. let captcha = this.props.form.getFieldValue('verifyCode');//图形验证码
  617. if (mobile == undefined || (mobile != undefined && !mobile)) {
  618. this.setState({
  619. is_show_phone_err: true,
  620. phone_error_info: `${sldComLanguage('请输入手机号')}`,
  621. });
  622. } else if (!sldCheckMobile(mobile)) {
  623. this.setState({
  624. is_show_phone_err: true,
  625. phone_error_info: `${sldComLanguage('请输入正确的手机号')}`,
  626. });
  627. } else if (type == 'register' && (captcha == undefined || (captcha != undefined && !captcha))) {
  628. this.setState({
  629. is_show_code_err: true,
  630. code_error_info: `${sldComLanguage('请输入图形验证码')}`,
  631. });
  632. } else {
  633. const { dispatch } = this.props;
  634. let _this = this;
  635. let param = {};
  636. param.mobile = mobile;
  637. param.type = type;
  638. if (type == 'register') {
  639. param.verifyCode = captcha;
  640. param.verifyKey = this.register_captcha;
  641. }
  642. this.setState({
  643. countDownC: true,
  644. })
  645. dispatch({
  646. type: 'common/get_sms_code',
  647. payload: param,
  648. callback: (res) => {
  649. if (res.state == 200) {
  650. this.setState({
  651. countDownM: 60,
  652. countDownC: false,
  653. }, () => {
  654. _this.countDown();
  655. });
  656. } else {
  657. this.setState({
  658. countDownC: false,
  659. is_show_phonecode_err: true,
  660. phonecode_error_info: res.msg,
  661. });
  662. }
  663. },
  664. });
  665. }
  666. }
  667. render() {
  668. const { getFieldDecorator } = this.props.form;
  669. const {
  670. login_img,
  671. error_info,
  672. modal_type,
  673. is_show_err,
  674. register_captcha,
  675. login_captcha,
  676. title,
  677. visibleModal,
  678. visibleModalSuccess,
  679. register_error_info,
  680. is_show_registe_err,
  681. countDownM,
  682. loading
  683. } = this.state;
  684. return (
  685. <div className={styles.full_screen}
  686. style={{
  687. backgroundImage: window.location.href.indexOf('user') != -1 ? 'url(' + login_img.admin_login_bg + ')' : 'none',
  688. backgroundSize: '100% 100%',
  689. }}>
  690. <div className={styles.left_bg}>
  691. <img
  692. src={login_img.admin_login_left_bg}
  693. onError={() => this.showDefault('admin_login_left_bg')}
  694. />
  695. <div className={`${global.flex_row_center_center} ${styles.login_logo_wrap}`}>
  696. <img className={styles.login_logo} src={login_img.main_seller_center_logo} onError={(e) => {
  697. e.target.onerror = null;
  698. e.target.src = main_seller_center_logo_local;
  699. }}/>
  700. </div>
  701. <p className={styles.main_title}>{sldComLanguage('欢迎登录商家中心后台')}</p>
  702. <div className={styles.right_bg}>
  703. <div className={styles.formlogin}>
  704. <Form layout="horizontal" onSubmit={(e) => this.handleSubmits(e)}>
  705. <FormItem
  706. >
  707. {getFieldDecorator('username')(
  708. <Input
  709. maxLength={50}
  710. placeholder={sldComLanguage('请输入用户名')}
  711. prefix={<img src={require('../../assets/sld_login_username.png')}
  712. style={{ color: 'rgba(0,0,0,.25)' }}/>}
  713. onPressEnter={() => this.props.form.submit(this.handleSubmits)}
  714. />,
  715. )}
  716. </FormItem>
  717. <FormItem
  718. style={{ marginTop: 20 }}
  719. >
  720. {getFieldDecorator('password')(
  721. <Input
  722. maxLength={50}
  723. type="password"
  724. placeholder={sldComLanguage('请输入密码')}
  725. prefix={<img src={require('../../assets/sld_login_pwd.png')}/>}
  726. onPressEnter={() => this.props.form.submit(this.handleSubmits)}
  727. />,
  728. )}
  729. </FormItem>
  730. <FormItem
  731. style={{ marginTop: 20 }}
  732. >
  733. {getFieldDecorator('verifyCode')(
  734. <Input
  735. maxLength={4}
  736. placeholder={sldComLanguage('请输入验证码')}
  737. prefix={<img src={require('../../assets/sld_login_img_code.png')}
  738. style={{ color: 'rgba(0,0,0,.25)' }}/>}
  739. suffix={<img src={login_captcha} onClick={() => this.getCaptcha('login_captcha')}
  740. className={styles.verification_code}/>}
  741. onPressEnter={() => this.props.form.submit(this.handleSubmits)}
  742. />,
  743. )}
  744. </FormItem>
  745. <div className={`${styles.sld_login_btn_wrap} ${global.flex_column_start_start}`}>
  746. <div className={`${styles.sld_login_btn} ${global.flex_row_center_center}`}
  747. onClick={() => this.props.form.submit(this.handleSubmits)}>
  748. {sldComLanguage('立即登录')}
  749. </div>
  750. <div className={`${global.flex_row_between_center} ${styles.operate}`}>
  751. <a onClick={this.handleForgetPwd}>{sldComLanguage('忘记密码')}</a>
  752. <a onClick={this.handleRegister}>{sldComLanguage('立即注册')}</a>
  753. </div>
  754. <div className={`${global.flex_row_between_center} ${styles.operate}`}>
  755. <a onClick={this.handleUserRegisterAgreement}>{sldComLanguage('<<用户注册协议>>')}</a>
  756. <a onClick={this.handleUserPrivacyPolicy}>{sldComLanguage('<<隐私政策>>')}</a>
  757. </div>
  758. </div>
  759. </Form>
  760. </div>
  761. </div>
  762. </div>
  763. {/* 注册、找回密码弹出框 */}
  764. <Modal
  765. title={title}
  766. visible={visibleModal}
  767. footer={false}
  768. onCancel={this.handleCancelModal}
  769. width={450}
  770. >
  771. <div className={styles.form_login_modal}>
  772. <Form onSubmit={(e) => this.handleOkModal(e)}>
  773. {modal_type == 'register' &&
  774. <FormItem
  775. style={{ textAlign: 'center' }}
  776. >
  777. {getFieldDecorator('vendorName', {
  778. rules: [
  779. {
  780. validator: this.checkVendorName,
  781. },
  782. ],
  783. })(
  784. <Input
  785. maxLength={20}
  786. onChange={this.handleChangeRegister}
  787. placeholder={sldComLanguage('请输入6~20位字母组合')}
  788. allowClear
  789. prefix={<p className={styles.user_name}><span className={styles.must}>*</span>{sldComLanguage('商家账号')}</p>}
  790. />,
  791. )}
  792. </FormItem>
  793. }
  794. {modal_type == 'register' && this.state.is_show_account_err &&
  795. <div className={styles.register_error}>
  796. {sldSvgIcon('#ef1216', 16, 16, 'cuowutishi')}
  797. {this.state.account_error_info}~
  798. </div>
  799. }
  800. <FormItem
  801. style={{ marginTop: 20, textAlign: 'center' }}
  802. >
  803. {getFieldDecorator('vendorMobile', {
  804. rules: [
  805. {
  806. validator: this.checkMobile,
  807. },
  808. ],
  809. })(
  810. <Input
  811. maxLength={11}
  812. onChange={this.handleChangeRegister}
  813. placeholder={sldComLanguage('请输入手机号')}
  814. allowClear
  815. prefix={<p className={styles.user_name}><span className={styles.must}>*</span>{sldComLanguage('手机号')}</p>}
  816. />,
  817. )}
  818. </FormItem>
  819. {this.state.is_show_phone_err &&
  820. <div className={styles.register_error}>
  821. {sldSvgIcon('#ef1216', 16, 16, 'cuowutishi')}
  822. {this.state.phone_error_info}~
  823. </div>
  824. }
  825. {modal_type == 'register' &&
  826. <FormItem
  827. style={{ marginTop: 20, textAlign: 'center' }}
  828. >
  829. {getFieldDecorator('verifyCode', {
  830. rules: [
  831. {
  832. validator: this.checkImgCode,
  833. },
  834. ],
  835. })(
  836. <Input
  837. maxLength={4}
  838. onChange={this.handleChangeRegister}
  839. placeholder={sldComLanguage('请输入验证码')}
  840. prefix={<p className={styles.user_name}><span className={styles.must}>*</span>{sldComLanguage('验证码')}</p>}
  841. suffix={<img src={register_captcha} onClick={() => this.getCaptcha('register_captcha')}
  842. className={styles.verification_code}/>}
  843. />,
  844. )}
  845. </FormItem>
  846. }
  847. {this.state.is_show_code_err &&
  848. <div className={styles.register_error}>
  849. {sldSvgIcon('#ef1216', 16, 16, 'cuowutishi')}
  850. {this.state.code_error_info}~
  851. </div>
  852. }
  853. <FormItem
  854. style={{ marginTop: 20, textAlign: 'center' }}
  855. >
  856. {getFieldDecorator('smsCode', {
  857. rules: [
  858. {
  859. validator: this.checkSmsCode,
  860. },
  861. ],
  862. })(
  863. <Input
  864. maxLength={6}
  865. onChange={this.handleChangeRegister}
  866. placeholder={sldComLanguage('请输入短信验证码')}
  867. prefix={<p className={styles.user_name}><span className={styles.must}>*</span>{sldComLanguage('短信验证码')}</p>}
  868. suffix={<div className={`${global.flex_row_between_center} ${styles.get_sms_code_wrap}`}><span
  869. className={`${styles.v_split}`}>|</span><span className={styles.sms_code}
  870. style={{ opacity: countDownM > 0 ? 0.3 : 1 }}
  871. onClick={() => this.getSmsCode(modal_type == 'register' ? 'register' : 'retrieve')}>{countDownM ? `${countDownM}${sldComLanguage('s后重新获取')}` : `${sldComLanguage('获取验证码')}`}</span>
  872. </div>}
  873. />,
  874. )}
  875. </FormItem>
  876. {this.state.is_show_phonecode_err &&
  877. <div className={styles.register_error}>
  878. {sldSvgIcon('#ef1216', 16, 16, 'cuowutishi')}
  879. {this.state.phonecode_error_info}~
  880. </div>
  881. }
  882. {modal_type == 'register' &&
  883. <FormItem
  884. style={{ marginTop: 20, textAlign: 'center' }}
  885. >
  886. {getFieldDecorator('vendorEmail', {
  887. rules: [
  888. {
  889. validator: this.checkEmail,
  890. },
  891. ],
  892. })(
  893. <Input
  894. maxLength={100}
  895. onChange={this.handleChangeRegister}
  896. placeholder={sldComLanguage('请输入邮箱')}
  897. allowClear
  898. prefix={<p className={styles.user_name}>{sldComLanguage('邮箱')}</p>}
  899. />,
  900. )}
  901. </FormItem>
  902. }
  903. {this.state.is_show_email_err &&
  904. <div className={styles.register_error}>
  905. {sldSvgIcon('#ef1216', 16, 16, 'cuowutishi')}
  906. {this.state.email_error_info}~
  907. </div>
  908. }
  909. {modal_type == 'forgetPwd' &&
  910. <FormItem
  911. style={{marginTop: 20, textAlign: 'center'}}
  912. >
  913. {getFieldDecorator('vendorName', {
  914. rules: [
  915. {
  916. validator: this.checkVendorName,
  917. },
  918. ],
  919. })(
  920. <Input
  921. maxLength={20}
  922. onChange={this.handleChangeRegister}
  923. placeholder={sldComLanguage('请输入商家账号')}
  924. prefix={<p className={styles.user_name}><span
  925. className={styles.must}>*</span>{sldComLanguage('商家账号')}
  926. </p>}
  927. />,
  928. )}
  929. </FormItem>}
  930. {modal_type == 'forgetPwd' && this.state.is_show_account_err &&
  931. <div className={styles.register_error}>
  932. {sldSvgIcon('#ef1216', 16, 16, 'cuowutishi')}
  933. {this.state.account_error_info}~
  934. </div>
  935. }
  936. <FormItem
  937. style={{ marginTop: 20, textAlign: 'center' }}
  938. >
  939. {getFieldDecorator('vendorPassword', {
  940. rules: [
  941. {
  942. validator: this.checkPassword,
  943. },
  944. ],
  945. })(
  946. <Input.Password
  947. maxLength={20}
  948. onChange={this.handleChangeRegister}
  949. placeholder={sldComLanguage('请设置6~20位字母、数字或符号组成的密码')}
  950. prefix={<p className={styles.user_name}><span
  951. className={styles.must}>*</span>{modal_type == 'register' ? `${sldComLanguage('设置密码')}` : `${sldComLanguage('新密码')}`}</p>}
  952. />,
  953. )}
  954. </FormItem>
  955. {this.state.is_show_pwd_err &&
  956. <div className={styles.register_error}>
  957. {sldSvgIcon('#ef1216', 16, 16, 'cuowutishi')}
  958. {this.state.pwd_error_info}~
  959. </div>
  960. }
  961. <FormItem
  962. style={{ marginTop: 20, textAlign: 'center' }}
  963. >
  964. {getFieldDecorator('confirmPassword', {
  965. rules: [
  966. {
  967. required: true,
  968. whitespace: true,
  969. message: ' ',
  970. },
  971. {
  972. validator: this.checkConfirmPassword,
  973. },
  974. ],
  975. })(
  976. <Input.Password
  977. maxLength={20}
  978. onChange={this.handleChangeRegister}
  979. placeholder={sldComLanguage('请再次输入密码')}
  980. prefix={<p className={styles.user_name}><span className={styles.must}>*</span>{sldComLanguage('确认密码')}</p>}
  981. />,
  982. )}
  983. </FormItem>
  984. {this.state.is_show_comfirepwd_err &&
  985. <div className={styles.register_error}>
  986. {sldSvgIcon('#ef1216', 16, 16, 'cuowutishi')}
  987. {this.state.comfirepwd_error_info}~
  988. </div>
  989. }
  990. {is_show_registe_err &&
  991. <div className={styles.register_error}>
  992. {sldSvgIcon('#ef1216', 16, 16, 'cuowutishi')}
  993. {register_error_info}~
  994. </div>
  995. }
  996. <FormItem
  997. style={{ textAlign: 'center' }}
  998. >
  999. <Button loading={loading} htmlType="submit" size={'small'} style={{ height: 40 }}
  1000. className={styles.registerBtn}>{modal_type == 'register' ? `${sldComLanguage('提交注册')}` : `${sldComLanguage('找回密码')}`}</Button>
  1001. </FormItem>
  1002. </Form>
  1003. </div>
  1004. </Modal>
  1005. {/* 操作成功提示框 */}
  1006. <Modal
  1007. title={title}
  1008. visible={visibleModalSuccess}
  1009. footer={false}
  1010. onCancel={this.handleCancelModal}
  1011. width={450}
  1012. >
  1013. <div className={styles.success_wrap}>
  1014. <div className={`${styles.head_wrap} ${global.flex_column_center_center}`}>
  1015. {sldSvgIcon('rgba(255, 74, 33, .2)', 65, 65, 'ziyuan113')}
  1016. <p style={{ fontSize: 16, marginTop: 10 }}>{sldComLanguage('注册成功')}</p>
  1017. </div>
  1018. <Button className={styles.success_btn}
  1019. onClick={this.handleSuccessBtn}>{sldComLanguage('点击入驻')}</Button>
  1020. </div>
  1021. </Modal>
  1022. </div>
  1023. );
  1024. }
  1025. }