RegisterScreen.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /* eslint-disable camelcase */
  2. import * as WebBrowser from 'expo-web-browser';
  3. import * as React from 'react';
  4. import {
  5. Image,
  6. StyleSheet,
  7. } from 'react-native';
  8. import { useModel } from 'flooks';
  9. import {
  10. Layout,
  11. Text,
  12. useTheme,
  13. Button,
  14. } from '@ui-kitten/components';
  15. import { useFocusEffect } from '@react-navigation/native';
  16. import FormInput from '../components/FormInput';
  17. import ScrollPage from '../components/ScrollPage';
  18. import ConnectButton from '../components/ConnectButton';
  19. import SmsInput from "../components/SmsInput";
  20. const styles = StyleSheet.create({
  21. container: {
  22. flex: 1,
  23. alignItems: 'center',
  24. justifyContent: 'center',
  25. paddingTop: 10,
  26. paddingBottom: 33,
  27. },
  28. tabContent: {
  29. backgroundColor: '#fff',
  30. marginTop: 20,
  31. },
  32. logo: {
  33. width: 100,
  34. height: 100,
  35. alignSelf: 'center',
  36. },
  37. logo2: {
  38. width: 97,
  39. height: 21,
  40. alignSelf: 'center',
  41. marginTop: 2,
  42. },
  43. text: {
  44. marginTop: 16,
  45. },
  46. layoutLeft: {
  47. flexDirection: 'row',
  48. paddingVertical: 10,
  49. justifyContent: 'center',
  50. },
  51. form: {
  52. paddingHorizontal: 16,
  53. paddingVertical: 20,
  54. alignSelf: 'stretch',
  55. },
  56. });
  57. const img1 = require('../assets/images/logo_1.png')
  58. const img2 = require('../assets/images/logo_2.png')
  59. export default function RegisterScreen() {
  60. const theme = useTheme();
  61. const { changeBackground } = useModel('barModel');
  62. const {
  63. welcom,
  64. register_form_1,
  65. register_pla_1,
  66. register_form_2,
  67. register_pla_2,
  68. register_form_4,
  69. register_pla_4,
  70. login_form_3,
  71. login_pla_3,
  72. login_form_2,
  73. login_pla_2,
  74. register_form_3,
  75. register_pla_3,
  76. next,
  77. login_btn_code_1,
  78. } = useModel('wordsModel');
  79. useFocusEffect(
  80. React.useCallback(() => {
  81. changeBackground(theme['background-basic-color-1']);
  82. }, []),
  83. );
  84. const [name, changeName] = React.useState('');
  85. const [showName, changeShowName] = React.useState('');
  86. const [phone, changePhone] = React.useState('');
  87. const [password, changePassword] = React.useState('');
  88. const [password2, changePassword2] = React.useState('');
  89. const [code, changeCode] = React.useState('');
  90. const canNext = React.useMemo(() => {
  91. if (
  92. name
  93. && showName
  94. && phone
  95. && code
  96. && password
  97. && password === password2
  98. ) {
  99. return true;
  100. }
  101. return false;
  102. }, [name, showName, phone, password, code, password2]);
  103. const { registerFirst } = useModel('userModel', true);
  104. return (
  105. <ScrollPage>
  106. <Layout style={styles.container}>
  107. <Image source={img1} style={styles.logo} />
  108. <Image source={img2} style={styles.logo2} />
  109. <Text style={styles.text} category="h6">
  110. {welcom}
  111. </Text>
  112. <Layout style={styles.form}>
  113. {/* 输入商家名称 */}
  114. <FormInput
  115. label={`${register_form_1}:`}
  116. value={name}
  117. placeholder={register_pla_1}
  118. onChange={changeName}
  119. textAlign="right"
  120. />
  121. {/* 显示名称: */}
  122. <FormInput
  123. label={`${register_form_2}:`}
  124. value={showName}
  125. placeholder={register_pla_2}
  126. onChange={changeShowName}
  127. textAlign="right"
  128. />
  129. {/* 手机号 */}
  130. <FormInput
  131. label={`${register_form_4}:`}
  132. value={phone}
  133. type="phone"
  134. placeholder={register_pla_4}
  135. onChange={changePhone}
  136. textAlign="right"
  137. />
  138. {/* 验证码 */}
  139. <SmsInput
  140. label={`${login_form_3}:`}
  141. placeholder={login_pla_3}
  142. phone={phone}
  143. onCodeChange={changeCode}
  144. />
  145. {/* 密码 */}
  146. <FormInput
  147. label={`${login_form_2}:`}
  148. value={password}
  149. type="password"
  150. placeholder={login_pla_2}
  151. onChange={changePassword}
  152. textAlign="right"
  153. />
  154. {/* 确认密码 */}
  155. <FormInput
  156. label={`${register_form_3}:`}
  157. value={password2}
  158. type="password"
  159. placeholder={register_pla_3}
  160. onChange={changePassword2}
  161. textAlign="right"
  162. />
  163. <Layout style={styles.layoutLeft} level="1">
  164. <Button
  165. status="primary"
  166. disabled={!canNext}
  167. onPress={() =>
  168. registerFirst({
  169. name,
  170. showName,
  171. phone,
  172. password,
  173. })
  174. }
  175. >
  176. {next}
  177. </Button>
  178. </Layout>
  179. </Layout>
  180. <ConnectButton />
  181. </Layout>
  182. </ScrollPage>
  183. );
  184. }