Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.73 KB | None | 0 0
  1. /**
  2. * GRAPECITY MONGOLIA LLC
  3. * PAYMENT SOLUTION DIVISION
  4. * Bilguun.B
  5. * 2018-11-30
  6. */
  7.  
  8. import React, { Component } from 'react';
  9. import { StyleSheet, TouchableOpacity, View, ScrollView, Image, TextInput, Text, Platform } from 'react-native';
  10. import LinearGradient from "react-native-linear-gradient";
  11. import Icon from 'react-native-vector-icons/FontAwesome5';
  12. import { postReq } from './utils/post'
  13. import Crypter from './utils/Crypter';
  14. import base64 from 'react-native-base64';
  15. import { NativeModules } from 'react-native';
  16. import { Buffer } from 'buffer';
  17. import DeviceInfo from 'react-native-device-info';
  18. import { Dialog, ProgressDialog, ConfirmDialog } from 'react-native-simple-dialogs';
  19. import Checkbox from 'react-native-modest-checkbox'
  20. import Toast, { DURATION } from 'react-native-easy-toast'
  21. import { AsyncStorage } from "react-native"
  22. import Globals from './utils/Globals'
  23. import TouchID from 'react-native-touch-id'
  24. import CryptoJS from 'crypto-js'
  25.  
  26. var Aes = NativeModules.Aes;
  27.  
  28. var deviceMac;
  29. var deviceIp;
  30. var deviceId;
  31. var retData;
  32.  
  33.  
  34. var logo = require("./assets/head_logo.gif")
  35. class Login extends Component {
  36. constructor(props) {
  37. super(props);
  38. this.prevUsername = '';
  39. this.prevMobile = '';
  40. this.tanCode = '';
  41. this.sessionToken = '';
  42. this.isTouchID = false;
  43. this.fingerPrintState = 0;
  44. this.prevFingerPrintState = 0;
  45. this.loginWidth = "70%";
  46.  
  47.  
  48. this.state = {
  49. progressVisible: false,
  50. confDialogVisible: false,
  51. tanDialogVisible: false,
  52. rememberme: false,
  53. rememberDev: false,
  54. confPassDialogVisible: false,
  55. touchIDsupport: false,
  56. fingerPrint: false,
  57. mobileErr: false,
  58. userErr: false,
  59. passErr: false
  60. };
  61. }
  62.  
  63. componentDidMount() {
  64. // console.log(this.props.screenProps);
  65. deviceId = this.props.screenProps.deviceId;
  66. // console.log(deviceId);
  67. Globals.OTS_URL = this.props.screenProps.otsUrl;
  68. console.log(Globals.OTS_URL);
  69. this.getDeviceIp();
  70. this.getDeviceMac();
  71. this.retrieveData();
  72. this.setState({
  73. progressVisible: true
  74. })
  75. TouchID.isSupported()
  76. .then(biometryType => {
  77. this.loginWidth = "70%";
  78. this.setState({ touchIDsupport: true });
  79. this.setState({
  80. progressVisible: false
  81. })
  82. })
  83. .catch(error => {
  84. this.loginWidth = "100%";
  85. this.setState({ touchIDsupport: false });
  86. this.setState({
  87. progressVisible: false
  88. })
  89. });
  90. }
  91.  
  92. getDeviceIp = () => {
  93. DeviceInfo.getIPAddress().then(ip => {
  94. deviceIp = ip;
  95. });
  96.  
  97. }
  98.  
  99. getDeviceMac = () => {
  100. DeviceInfo.getMACAddress().then(mac => {
  101. deviceMac = mac;
  102. });
  103. }
  104.  
  105. generateTraceNo = () => {
  106. var today = new Date();
  107. var date = today.getFullYear() + '' + ("0" + (today.getMonth() + 1)).slice(-2) + '' + ("0" + today.getDate()).slice(-2);
  108. var millis = ("0" + today.getMilliseconds()).slice(-2);
  109. var time = ("0" + today.getHours()).slice(-2) + "" + ("0" + today.getMinutes()).slice(-2) + "" + ("0" + today.getSeconds()).slice(-2) + "" + millis;
  110. var dateTime = date + '' + time;
  111. return dateTime;
  112. }
  113.  
  114. touchIDconfirm() {
  115. const optionalConfigObject = {
  116. title: "Нэвтрэх", // Android
  117. imageColor: "#e00606", // Android
  118. imageErrorColor: "#ff0000", // Android
  119. sensorDescription: "Хурууны хээгээ уншуулна уу", // Android
  120. sensorErrorDescription: "Failed", // Android
  121. cancelText: "Cancel", // Android
  122. fallbackLabel: "", // iOS (if empty, then label is hidden)
  123. unifiedErrors: false, // use unified error messages (default false)
  124. passcodeFallback: false // iOS
  125. }
  126.  
  127. var promise = TouchID.authenticate('demo', optionalConfigObject)
  128. .then(success => {
  129. return 0;
  130. })
  131. .catch(error => {
  132. throw (error);
  133. });
  134. return promise;
  135. }
  136.  
  137. login = (fingerPrint) => {
  138. if (this.state.username === undefined || this.state.username === null || this.state.username.length === 0) {
  139. // this.refs.toast.show("Хэрэглэгчийн нэрээ оруулна уу", DURATION.LENGTH_LONG);
  140. this.setState({ userErr: true });
  141. return;
  142. }
  143. if (this.state.phone === undefined || this.state.phone === null || this.state.phone.length !== 8) {
  144. // this.refs.toast.show("Утасны дугаараа оруулна уу", DURATION.LENGTH_LONG);
  145. this.setState({ mobileErr: true });
  146. return;
  147. }
  148. if (((this.prevMobile === '' || this.prevMobile !== String(this.state.phone)) || (this.prevUsername === '' || this.prevUsername !== String(this.state.username))) && this.state.fingerPrint === true) {
  149. this.fingerPrintState = 1;
  150. this.loginFunc();
  151. return;
  152. }
  153. if (((this.prevMobile === String(this.state.phone)) || (this.prevUsername === String(this.state.username))) && this.state.fingerPrint === true && this.prevFingerPrintState === false) {
  154. this.fingerPrintState = 1;
  155. this.loginFunc();
  156. return;
  157. }
  158. if (((this.prevMobile === '' || this.prevMobile === String(this.state.phone)) || (this.prevUsername === '' || this.prevUsername === String(this.state.username))) && this.state.fingerPrint === true && this.prevFingerPrintState === true) {
  159.  
  160. if (fingerPrint === true) {
  161. this.fingerPrintState = 2;
  162. this.touchIDconfirm().then(value => {
  163. if (value !== 0) {
  164. this.setState({
  165. confMsg: 'Хурууны хээ унших алдаа fingerprintState = 2',
  166. confDialogVisible: true
  167. });
  168. return;
  169. } else {
  170. this.loginFunc();
  171. }
  172. }).catch(err => {
  173. console.log(err);
  174. this.setState({
  175. confMsg: 'Хурууны хээ унших алдаа fingerprintState = 2, catch',
  176. confDialogVisible: true
  177. });
  178. return;
  179. });
  180.  
  181. }
  182. else {
  183. this.fingerPrintState = 3;
  184. this.loginFunc();
  185. }
  186. }
  187.  
  188. if (fingerPrint === true) {
  189. this.setState({
  190. fingerPrint: true
  191. });
  192. }
  193.  
  194. if ((this.state.password === undefined || this.state.password === null || this.state.password.length <= 3) && this.fingerPrintState !== 2) {
  195. if (this.state.password === undefined || this.state.password === null || this.state.password.length !== 6) {
  196. // this.refs.toast.show("Нууц үгээ оруулна уу", DURATION.LENGTH_LONG);
  197. this.setState({ passErr: true });
  198. return;
  199. } else if (this.state.password === undefined || this.state.password === null || this.state.password.length !== 4) {
  200. // this.refs.toast.show("Нууц үгээ оруулна уу", DURATION.LENGTH_LONG);
  201. this.setState({ passErr: true });
  202. return;
  203. }
  204. }
  205. if (this.fingerPrintState === 0 && fingerPrint === false) {
  206. this.loginFunc();
  207. }
  208. }
  209.  
  210. loginFunc = () => {
  211. this.setState({
  212. progressVisible: true
  213. })
  214. let pin = Crypter.crypt(this.state.phone + '_' + this.state.password) //pin
  215. let hashpin = Crypter.getHex(Crypter.hash(this.state.phone + '_' + this.state.password)) //hashpin
  216. let secureData = {};
  217. let traceno = this.generateTraceNo();
  218. secureData["srcMsisdn"] = this.state.phone;
  219. secureData["traceNo"] = '2018121017101111';
  220. secureData["loginName"] = this.state.username;
  221. secureData["pin"] = hashpin;
  222. secureData["pinEnc"] = pin;
  223. //console.log(secureData);
  224. let jsonData = JSON.stringify(secureData);
  225. //console.log(jsonData);
  226. let sd = this.encrypt1(jsonData, secureData["traceNo"])
  227. let ek = this.encrypt2(secureData["traceNo"]);
  228. //console.log(ek);
  229. this.makeSg(jsonData).then((res) => {
  230. let sg = base64.encode(this.bin2String(this.hexToBytes(res.cipher)));
  231. //console.log(sg);
  232. var sendingData = {};
  233. sendingData["deviceId"] = deviceId;
  234. sendingData["fingerPrintFlag"] = this.fingerPrintState;
  235. sendingData["SD"] = sd;
  236. sendingData["deviceMac"] = deviceMac;
  237. sendingData["srcInstId"] = 11;
  238. sendingData["deviceAppVersion"] = "1.0";
  239. sendingData["SG"] = sg;
  240. sendingData["EK"] = ek;
  241. sendingData["wallet"] = "TESO_BUMM";
  242. sendingData["sessionType"] = 1;
  243. sendingData["lang"] = 0;
  244. sendingData["pushNotifToken"] = "qwehjhvbsf123";
  245. sendingData["deviceOsVersion"] = DeviceInfo.getSystemVersion();
  246. sendingData["deviceName"] = DeviceInfo.getDeviceName();
  247. sendingData["channel"] = 41;
  248. sendingData["deviceIp"] = deviceIp;
  249. postReq(sendingData, "1000").then((response) => {
  250. this.setState({
  251. progressVisible: false
  252. })
  253. this.loginSuccess(response);
  254. }
  255. ).catch(function (error) {
  256. this.setState({
  257. progressVisible: false
  258. })
  259. //console.log(error.message);
  260. throw error;
  261. });
  262. });
  263. }
  264.  
  265. encrypt1 = (text, keyBase64) => {
  266. // var ivBase64 = "oeLV/tpSCo+KGaq7CtBVrA==";
  267. // if (Platform.OS === 'ios') {
  268. // return Aes.encrypt(text, keyBase64, ivBase64).then(cipher => ({ cipher, iv: ivBase64 }));
  269. // } else {
  270. var ivBase64 = "oeLV/tpSCo+KGaq7CtBVrA==";
  271. let keyHex = Buffer(keyBase64).toString('hex');
  272. let sg = Buffer(base64.decode("a1e2d5feda520a8f8a19aabb0ad055ac")).toString('hex');
  273. let key64 = base64.encode(keyBase64);
  274. let key = CryptoJS.enc.Hex.parse(keyHex);
  275. let iv = CryptoJS.enc.Hex.parse("a1e2d5feda520a8f8a19aabb0ad055ac");
  276. let test = CryptoJS.AES.encrypt(text, key, { iv: iv }).toString();
  277. return test;
  278. // return Aes.encrypt(text, keyHex, "a1e2d5feda520a8f8a19aabb0ad055ac").then(cipher => ({ cipher, iv: ivBase64 }));
  279. // }
  280. };
  281.  
  282. hexToBytes(hex) {
  283. for (var bytes = [], c = 0; c < hex.length; c += 2)
  284. bytes.push(parseInt(hex.substr(c, 2), 16));
  285. return bytes;
  286. }
  287.  
  288. bin2String(array) {
  289. return String.fromCharCode.apply(String, array);
  290. }
  291.  
  292. registerBioDevice(enable) {
  293. secureData["traceNo"] = traceno;
  294. let jsonData = JSON.stringify(secureData);
  295.  
  296. let sd = this.encrypt1(jsonData, secureData["traceNo"]);
  297. let ek = this.encrypt2(secureData["traceNo"]);
  298. //console.log(ek);
  299. return this.makeSg(jsonData).then((res) => {
  300. let sg = base64.encode(this.bin2String(this.hexToBytes(res.cipher)));
  301. //console.log(sg);
  302. var sendingData = {};
  303. sendingData["deviceId"] = deviceId;
  304. sendingData["enable"] = enable;
  305. sendingData["SD"] = sd;
  306. sendingData["srcInstId"] = 11;
  307. sendingData["SG"] = sg;
  308. sendingData["EK"] = ek;
  309. sendingData["sessionToken"] = retData.sessionToken;
  310. sendingData["lang"] = 0;
  311. sendingData["channel"] = 41;
  312. postReq(sendingData, "1009").then((response) => {
  313. this.setState({
  314. progressVisible: false
  315. })
  316. if ((response.responseCode === 0 || response.responseCode === "0")) {
  317. return 0;
  318. } else {
  319. return response.responseDesc;
  320. }
  321. }
  322. ).catch(function (error) {
  323. this.setState({
  324. progressVisible: false
  325. })
  326. //console.log(error.message);
  327. throw error;
  328. });
  329. });
  330. }
  331.  
  332. encrypt2 = (data) => {
  333. var publicKey = '{' +
  334. '"n":"9f4193f6cccb90697a493df8f6faa232a5e760ebf44bae052a6b5e718171ced0c7cbcf5b6847b304db5e7de1c62cab450967a1b212e8a9dfc29586f4ce6fc0d8985bc5cebe9c77890b0de32ec87da89b20ca0daa61c4d8c54100dd408e233d2e1eee81441f99429012027d6337538501078fdc2688132dbe4315991ca3c790d1",' +
  335. '"e":"10001"' +
  336. '}';
  337. var RSAKey = require('react-native-rsa');
  338. var rsa = new RSAKey();
  339. rsa.setPublicString(publicKey);
  340. let test = rsa.encrypt(data);
  341. //console.log('testing');
  342. //console.log(test);
  343. //console.log('testing 1')
  344. var asd = this.hexToBytes(test);
  345. //console.log(asd)
  346. //console.log('testing 2')
  347. //console.log(this.bin2String(asd))
  348. return base64.encode(this.bin2String(asd));
  349. }
  350. makeSg(data) {
  351. return Aes.sha1(data).then(cipher => ({ cipher }));
  352. }
  353. loginSuccess(e) {
  354. //console.log(e);
  355. retData = e;
  356. if (e.responseCode === 0 || e.responseCode === "0") {
  357. this.prevUsername = this.state.username;
  358. this.prevMobile = this.state.phone;
  359. }
  360. if ((e.responseCode === 0 || e.responseCode === "0") && (e.pinBlock === 0 || e.pinBlock === "0")) {
  361. if (this.fingerPrintState === 1) {
  362. this.setState({
  363. progressVisible: true
  364. });
  365. let secureData = {};
  366. let traceno = this.generateTraceNo();
  367. secureData["traceNo"] = traceno;
  368. let jsonData = JSON.stringify(secureData);
  369. sd = this.encrypt1(jsonData, secureData["traceNo"]);
  370. let ek = this.encrypt2(secureData["traceNo"]);
  371. //console.log(ek);
  372. this.makeSg(jsonData).then((res) => {
  373. let sg = base64.encode(this.bin2String(this.hexToBytes(res.cipher)));
  374. //console.log(sg);
  375. var sendingData = {};
  376. sendingData["deviceId"] = deviceId;
  377. sendingData["enable"] = 1;
  378. sendingData["SD"] = sd;
  379. sendingData["srcInstId"] = 11;
  380. sendingData["SG"] = sg;
  381. sendingData["EK"] = ek;
  382. sendingData["sessionToken"] = retData.sessionToken;
  383. sendingData["lang"] = 0;
  384. sendingData["channel"] = 41;
  385. postReq(sendingData, "1009").then((response) => {
  386. this.setState({
  387. progressVisible: false
  388. })
  389. if ((response.responseCode === 0 || response.responseCode === "0")) {
  390. this.touchIDconfirm().then(value => {
  391. if (value !== 0) {
  392. this.setState({
  393. confMsg: 'Хурууны хээ уншихад алдаа гарлаа',
  394. confDialogVisible: true
  395. });
  396. } else {
  397. if (this.state.rememberme === true) {
  398. if (this.state.fingerPrint === true) {
  399. this.prevFingerPrintState = this.state.fingerPrint;
  400. this.saveData(this.state.username, this.state.phone, "1", "1");
  401. } else {
  402. this.saveData(this.state.username, this.state.phone, "1", "0");
  403. }
  404. } else {
  405. this.saveData("", "", "0", "0");
  406. }
  407. this.props.screenProps.callBack(retData);
  408. }
  409. }).catch(err => {
  410. console.log(err);
  411. this.setState({
  412. confMsg: 'Хурууны хээ уншихад алдаа catch()',
  413. confDialogVisible: true
  414. });
  415. return;
  416. });
  417. } else {
  418. this.setState({
  419. confMsg: response.responseDesc,
  420. confDialogVisible: true
  421. });
  422. return;
  423. }
  424. }).catch(function (error) {
  425. this.setState({
  426. progressVisible: false
  427. })
  428. //console.log(error.message);
  429. throw error;
  430. });
  431. });
  432. } else {
  433. if (this.state.rememberme === true) {
  434. if (this.state.fingerPrint === true && (this.fingerPrintState === 2 || this.fingerPrintState === 3)) {
  435. this.saveData(this.state.username, this.state.phone, "1", "1");
  436. } else {
  437. this.saveData(this.state.username, this.state.phone, "1", "0");
  438. }
  439. } else {
  440. this.saveData("", "", "0", "0");
  441. }
  442. this.props.screenProps.callBack(retData);
  443. }
  444.  
  445. // this.props.navigation.pop();
  446. // this.setState({
  447. // confMsg: 'SUCCESS',
  448. // confDialogVisible: true
  449. // });
  450. } else if (e.pinBlock === 1 || e.pinBlock === "1") {
  451. this.setState({
  452. confMsg: 'Таны ПИН түгжигдсэн байна',
  453. confDialogVisible: true
  454. });
  455. } else if (e.responseCode === "12200127" || e.responseCode === 12200127) {
  456. this.setState({
  457. tanDialogVisible: true
  458. });
  459. } else if (e.pinBlock === 2 || e.pinBlock === "2" || e.pinBlock === 3 || e.pinBlock === "3") {
  460. this.sessionToken = e.sessionToken;
  461. this.changePass();
  462. } else if (e.pinBlock === 4 || e.pinBlock === "4" || e.pinBlock === 4 || e.pinBlock === "4") {
  463.  
  464. }
  465. else {
  466. this.setState({
  467. confMsg: e.responseDesc,
  468. confDialogVisible: true
  469. });
  470. }
  471. }
  472.  
  473. confirmTan = () => {
  474. this.setState({
  475. progressVisible: true
  476. })
  477. var secureData = {};
  478. var traceno = this.generateTraceNo();
  479. secureData["srcMsisdn"] = this.state.phone;
  480. secureData["traceNo"] = traceno;
  481. secureData["tan"] = this.tanCode;
  482. //console.log(secureData);
  483. let jsonData = JSON.stringify(secureData);
  484. //console.log(jsonData);
  485. let sd = this.encrypt1(jsonData, secureData["traceNo"])
  486. let ek = this.encrypt2(secureData["traceNo"]);
  487. //console.log(ek);
  488. this.makeSg(jsonData).then((res) => {
  489. let sg = base64.encode(this.bin2String(this.hexToBytes(res.cipher)));
  490. //console.log(sg);
  491. var sendingData = {};
  492. sendingData["SD"] = sd;
  493. if (this.state.rememberDev === true) {
  494. sendingData["deviceId"] = deviceId;
  495. } else {
  496. sendingData["deviceId"] = "";
  497. }
  498. sendingData["EK"] = ek;
  499. sendingData["SG"] = sg;
  500. sendingData["channel"] = 41;
  501. sendingData["lang"] = 0;
  502. sendingData["srcInstId"] = 11;
  503. postReq(sendingData, "5088").then((response) => {
  504. this.setState({
  505. progressVisible: false
  506. })
  507. this.tanSuccess(response);
  508. }
  509. ).catch(function (error) {
  510. this.setState({
  511. progressVisible: false
  512. })
  513. //console.log(error.message);
  514. throw error;
  515. });
  516. });
  517. }
  518. tanSuccess(res) {
  519. //console.log(res);
  520. if (res.responseCode === 0 || res.responseCode === "0") {
  521. this.setState({ tanDialogVisible: false })
  522. this.login();
  523. } else {
  524. this.setState({
  525. confMsg: res.responseDesc,
  526. confDialogVisible: true
  527. })
  528. }
  529. }
  530. rememberme() {
  531. if (this.state.rememberme === false) {
  532. this.setState({
  533. rememberme: true
  534. });
  535. } else {
  536. this.setState({
  537. fingerPrint: false,
  538. rememberme: false
  539. });
  540. }
  541. }
  542.  
  543. rememberDev() {
  544. if (this.state.rememberDev === false) {
  545. this.setState({
  546. rememberDev: true
  547. });
  548. } else {
  549. this.setState({
  550. rememberDev: false
  551. });
  552. }
  553. }
  554.  
  555. passChangeCallback = (e) => {
  556. if (this.state.rememberme === true) {
  557. this.saveData(this.state.username, this.state.phone, "1");
  558. } else {
  559. this.saveData("", "", "0");
  560. }
  561. // this.setState({
  562. // confMsg: 'SUCCESS',
  563. // confDialogVisible: true
  564. // });
  565. this.props.screenProps.callBack(retData);
  566. }
  567.  
  568. changePass = () => {
  569. //console.log("entered");
  570. this.setState({
  571. confMsg: 'Та нууц үгээ солих шаардлагатай',
  572. confPassDialogVisible: true
  573. });
  574. this.props.navigation.navigate('ChangePass', {
  575. mobile: this.state.phone,
  576. sessionToken: this.sessionToken,
  577. onGoBack: (item) => this.passChangeCallback(item),
  578. });
  579. }
  580.  
  581. saveData = (username, mobile, rememberMe, biometric) => {
  582. AsyncStorage.setItem("username", username);
  583. AsyncStorage.setItem("mobile", mobile);
  584. AsyncStorage.setItem("remember", rememberMe);
  585. AsyncStorage.setItem("biometric", biometric);
  586. }
  587.  
  588. retrieveData = () => {
  589. AsyncStorage.getItem("username").then((value) => {
  590. this.setState({ username: value });
  591. this.prevUsername = value;
  592. }).done();
  593. AsyncStorage.getItem("mobile").then((value) => {
  594. this.setState({ phone: value });
  595. this.prevMobile = value;
  596. }).done();
  597. AsyncStorage.getItem("remember").then((value) => {
  598. //console.log(value);
  599. if (value === 1 || value === "1") {
  600. this.setState({ rememberme: true });
  601. } else {
  602. this.setState({ rememberme: false });
  603. }
  604. }).done();
  605. AsyncStorage.getItem("biometric").then((value) => {
  606. //console.log(value);
  607. if (value === 1 || value === "1") {
  608. this.setState({ fingerPrint: true });
  609. this.prevFingerPrintState = true;
  610. } else {
  611. this.setState({ fingerPrint: false });
  612. this.prevFingerPrintState = false;
  613. }
  614. }).done();
  615. }
  616.  
  617. rememberBio() {
  618. if (this.state.fingerPrint === false) {
  619. this.setState({
  620. fingerPrint: true,
  621. rememberme: true
  622. });
  623. } else {
  624. this.setState({
  625. fingerPrint: false
  626. });
  627. }
  628. }
  629.  
  630. render() {
  631. return (
  632. <LinearGradient
  633. style={styles.container}
  634. start={{ x: 1, y: 0 }}
  635. end={{ x: 0, y: 0.7 }}
  636. colors={['#F16A45', '#D45037', '#F0563C']}>
  637. <Dialog
  638. visible={this.state.tanDialogVisible}
  639. title="Тан код"
  640. onTouchOutside={() => this.setState({ tanDialogVisible: false })} >
  641. <View style={{ flexDirection: "column" }}>
  642. <Text>
  643. Та уг гар утаснаас анх удаа хандаж байгаа тул имэйлээр ирсэн ТАН кодыг оруулж баталгаажуулна уу
  644. </Text>
  645. <TextInput
  646. placeholder="Тан код"
  647. placeholderTextColor="rgba(0,0,0,0.5)"
  648. selectionColor="#000"
  649. keyboardType='numeric'
  650. onChangeText={(tanCode) => this.tanCode = tanCode}
  651. underlineColorAndroid="transparent"
  652. />
  653. <Checkbox
  654. checked={this.state.rememberDev}
  655. label='Байнга хандах төхөөрөмж'
  656. onChange={(checked) => this.rememberDev()}
  657. />
  658. <View style={{ flexDirection: "row", justifyContent: 'flex-end' }}>
  659. <TouchableOpacity onPress={this.confirmTan.bind(this)}>
  660. <Text>
  661. Баталгаажуулах
  662. </Text>
  663. </TouchableOpacity>
  664. </View>
  665. </View>
  666. </Dialog>
  667. <ConfirmDialog
  668. message={this.state.confMsg}
  669. visible={this.state.confPassDialogVisible}
  670. onTouchOutside={() => this.setState({ confPassDialogVisible: false })}
  671. positiveButton={{
  672. title: "Ok",
  673. onPress: () => {
  674. this.setState({ confPassDialogVisible: false })
  675. }
  676. }}
  677. />
  678. <ConfirmDialog
  679. message={this.state.confMsg}
  680. visible={this.state.confDialogVisible}
  681. onTouchOutside={() => this.setState({ confDialogVisible: false })}
  682. positiveButton={{
  683. title: "Ok",
  684. onPress: () => { this.setState({ confDialogVisible: false }) }
  685. }}
  686. />
  687. <ProgressDialog
  688. visible={this.state.progressVisible}
  689. message="Please, wait..."
  690. />
  691. <ScrollView>
  692. <View style={styles.header}>
  693. <Image
  694. style={{
  695. width: 180,
  696. height: 60,
  697.  
  698. }}
  699. source={logo}
  700. />
  701. </View>
  702. <View style={styles.box}>
  703. <View style={styles.inputCont}>
  704. <View style={{ marginBottom: 20 }}>
  705. <TextInput
  706. placeholder="Хэрэглэгчийн нэр"
  707. placeholderTextColor="rgba(255,255,255,0.5)"
  708. selectionColor="#fff"
  709. style={styles.input}
  710. value={this.state.username}
  711. onChangeText={(username) => this.setState({ username, userErr: false })}
  712. underlineColorAndroid="transparent"
  713. />
  714. <View style={{ height: 10 }}>
  715. {this.state.userErr &&
  716. <Text
  717. style={styles.loginErr}>
  718. Хэрэглэгчийн нэр оруулна уу
  719. </Text>
  720. }
  721. </View>
  722. <TextInput
  723. placeholder="Утасны дугаар"
  724. placeholderTextColor="rgba(255,255,255,0.5)"
  725. selectionColor="#fff"
  726. keyboardType='numeric'
  727. maxLength={8}
  728. style={styles.input}
  729. value={this.state.phone}
  730. onChangeText={(phone) => this.setState({ phone, mobileErr: false })}
  731. underlineColorAndroid="transparent"
  732. />
  733. <Text
  734. style={styles.loginErr}>
  735. Утасны дугаар оруулна уу
  736. </Text>
  737. <TextInput
  738. placeholder="Нууц үгээ оруулна уу"
  739. placeholderTextColor="rgba(255,255,255,0.5)"
  740. selectionColor="#fff"
  741. style={styles.input}
  742. value={this.password}
  743. maxLength={6}
  744. secureTextEntry={true}
  745. keyboardType='numeric'
  746. onChangeText={(password) => this.setState({ password })}
  747. underlineColorAndroid="transparent"
  748. />
  749. <Text style={styles.loginErr}>
  750. Нууц үг оруулна уу
  751. </Text>
  752. </View>
  753. <View style={{ flexDirection: "column", marginBottom: 20 }}>
  754. <Checkbox
  755. checked={this.state.rememberme}
  756. checkboxStyle={{ tintColor: "#fff" }}
  757. labelStyle={styles.loginCheckBox}
  758. label='Намайг сана'
  759. onChange={(checked) => this.rememberme()}
  760. />
  761. <Checkbox
  762. checked={this.state.fingerPrint}
  763. checkboxStyle={{ tintColor: "#fff" }}
  764. labelStyle={styles.loginCheckBox}
  765. label='Хурууны хээгээр нэвтрэх'
  766. onChange={(checked) => this.rememberBio()}
  767. />
  768. </View>
  769. <View style={{ flexDirection: "row" }}>
  770. <View style={{ width: this.loginWidth, height: 48 }}>
  771. <TouchableOpacity
  772. style={styles.login}
  773. onPress={() => this.login(false)}>
  774. <Text>
  775. Нэвтрэх
  776. </Text>
  777. </TouchableOpacity>
  778. </View>
  779. {this.state.touchIDsupport &&
  780. <View style={{ width: "30%" }}>
  781. <TouchableOpacity style={styles.finger}
  782. onPress={() => this.login(true)}
  783. >
  784. <Icon
  785. name="fingerprint"
  786. size={35}
  787. />
  788. </TouchableOpacity>
  789. </View>
  790. }
  791.  
  792. </View>
  793. </View>
  794. </View>
  795. <Toast ref="toast" position='bottom' />
  796. </ScrollView>
  797. </LinearGradient>
  798. );
  799. }
  800. }
  801.  
  802. var styles = StyleSheet.create({
  803. container: {
  804. flex: 1,
  805. backgroundColor: "rgb(44,189,165)"
  806. },
  807. header: {
  808. flex: 1,
  809. marginTop: 80,
  810. marginBottom: 80,
  811. justifyContent: "center",
  812. alignItems: "center",
  813. },
  814. box: {
  815. height: 450,
  816. },
  817. input: {
  818. borderBottomColor: "#fff",
  819. borderBottomWidth: 0.3,
  820. color: "#fff",
  821. fontSize: 16,
  822. height: 40
  823. },
  824. loginErr: {
  825. color: "#f4f441",
  826. fontSize: 10,
  827. textAlign: 'right',
  828. alignSelf: 'stretch'
  829. },
  830. inputCont: {
  831. paddingLeft: 50,
  832. paddingRight: 50
  833. },
  834. loadingCont: {
  835. flex: 1,
  836. },
  837. pass: {
  838. flexDirection: "row",
  839. flex: 1,
  840. marginTop: 15,
  841. justifyContent: "space-around"
  842. },
  843. row: {
  844. flexDirection: "row"
  845. },
  846. icon: {
  847. color: "#fff",
  848. paddingRight: 6
  849. },
  850. login: {
  851. backgroundColor: "#FF6F00",
  852. justifyContent: "center",
  853. alignItems: "center",
  854. height: 48
  855. },
  856. finger: {
  857. height: 48,
  858. backgroundColor: "#fff",
  859. justifyContent: "center",
  860. alignItems: "center",
  861. },
  862. loginCheckBox: {
  863. color: "#fff"
  864. }
  865. });
  866.  
  867. export default Login;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement