RegisterScreen.js 5.0 KB

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