LogForget.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. import React, { Component } from 'react'
  2. import {
  3. StyleSheet,
  4. ScrollView,
  5. View,
  6. Image,
  7. ImageBackground,
  8. Text,
  9. TextInput,
  10. Dimensions,
  11. StatusBar,
  12. TouchableOpacity,
  13. PixelRatio,
  14. } from 'react-native'
  15. import { connect } from 'react-redux'
  16. import loginButton from '../static/images/login-button.png'
  17. import Icon from '../components/Iconfont/Iconfont'
  18. import { NavigationActions, createAction } from '../utils'
  19. import { HeaderView } from './common/HeaderView'
  20. import Toast from 'react-native-root-toast'
  21. const { width, height } = Dimensions.get('window')
  22. @connect(({ theme }) => ({ ...theme }))
  23. class LogForget extends Component {
  24. constructor(props) {
  25. super(props)
  26. this.state = {
  27. phoneNumber: '',
  28. secureEntry: true,
  29. zhColor: '#EEE',
  30. mmColor: '#EEE',
  31. newpassWord: '',
  32. confirmPassWord: '',
  33. newPwLength: false,
  34. comfirmPwLength: false,
  35. }
  36. // console.disableYellowBox = true;
  37. }
  38. render() {
  39. const { appTheme } = this.props
  40. // 修改密码
  41. if (
  42. this.props.navigation.state.params &&
  43. this.props.navigation.state.params.comefrom == 'modify'
  44. ) {
  45. return (
  46. <View
  47. style={[
  48. styles.container,
  49. // { backgroundColor: appTheme.backgroundColor }
  50. { backgroundColor: '#FFF' },
  51. ]}
  52. >
  53. <StatusBar
  54. animated={true}
  55. barStyle={appTheme.barStyle}
  56. // barStyle={"dark-content"}
  57. backgroundColor={'transparent'}
  58. translucent={true}
  59. />
  60. {HeaderView(this.props.dispatch, '修改默认密码')}
  61. <View
  62. style={{
  63. marginTop: 10,
  64. paddingTop: 6,
  65. paddingBottom: 7,
  66. marginLeft: 21,
  67. marginRight: 28,
  68. flexDirection: 'row',
  69. alignItems: 'center',
  70. borderBottomWidth: 1,
  71. borderBottomColor: this.state.zhColor,
  72. paddingLeft: 14,
  73. }}
  74. >
  75. <Text
  76. style={{
  77. fontSize: 14,
  78. lineHeight: 20,
  79. letterSpacing: 0.38,
  80. color: '#333',
  81. marginRight: 10,
  82. }}
  83. >
  84. 新密码:
  85. </Text>
  86. <TextInput
  87. style={{
  88. flex: 1,
  89. padding: 0,
  90. fontSize: 14,
  91. lineHeight: 20,
  92. letterSpacing: 0.38,
  93. color: '#333',
  94. marginTop: 4,
  95. }}
  96. autoCapitalize="none"
  97. autoCorrect={false}
  98. onFocus={e => this.setState({ zhColor: '#E70013' })}
  99. onBlur={e => {
  100. if (
  101. this.state.newpassWord &&
  102. this.state.newpassWord.length < 6
  103. ) {
  104. this.setState({ newPwLength: true, newpassWord: '' })
  105. clearTimeout(this.newSettime)
  106. this.newSettime = setTimeout(() => {
  107. this.setState({ newPwLength: false })
  108. }, 3000)
  109. }
  110. this.setState({ zhColor: '#EEE' })
  111. }}
  112. underlineColorAndroid={'transparent'}
  113. clearButtonMode="while-editing"
  114. secureTextEntry={this.state.secureEntry}
  115. onChangeText={text => this.setState({ newpassWord: text })}
  116. value={this.state.newpassWord}
  117. multiline={false}
  118. // onSubmitEditing={() => this._searchindex()}
  119. placeholder={'请输入密码'}
  120. placeholderTextColor={'#CCC'}
  121. />
  122. {this.state.newpassWord ? (
  123. <TouchableOpacity
  124. onPress={() =>
  125. this.setState({ secureEntry: !this.state.secureEntry })
  126. }
  127. style={{
  128. paddingTop: 6,
  129. marginLeft: 3,
  130. }}
  131. >
  132. {this.state.secureEntry ? (
  133. <Icon name="icon-icon-kejian" size={20} color={'#999'} />
  134. ) : (
  135. <Icon name="icon-icon-bukejian" size={20} color={'#999'} />
  136. )}
  137. </TouchableOpacity>
  138. ) : null}
  139. </View>
  140. {this.state.newPwLength ? (
  141. <View style={{ paddingLeft: 104, marginTop: 3 }}>
  142. <Text style={{ color: '#E70013', fontSize: 12 }}>
  143. 输入长度不能小于6位
  144. </Text>
  145. </View>
  146. ) : null}
  147. <View
  148. style={{
  149. marginTop: 10,
  150. paddingTop: 6,
  151. paddingBottom: 7,
  152. marginLeft: 21,
  153. marginRight: 28,
  154. flexDirection: 'row',
  155. alignItems: 'center',
  156. borderBottomWidth: 1,
  157. borderBottomColor: this.state.mmColor,
  158. }}
  159. >
  160. <Text
  161. style={{
  162. fontSize: 14,
  163. lineHeight: 20,
  164. letterSpacing: 0.38,
  165. color: '#333',
  166. marginRight: 10,
  167. }}
  168. >
  169. 确认密码:
  170. </Text>
  171. <TextInput
  172. style={{
  173. flex: 1,
  174. padding: 0,
  175. fontSize: 14,
  176. lineHeight: 20,
  177. letterSpacing: 0.38,
  178. color: '#333',
  179. marginTop: 4,
  180. }}
  181. autoCapitalize="none"
  182. autoCorrect={false}
  183. onFocus={e => this.setState({ mmColor: '#E70013' })}
  184. onBlur={e => {
  185. if (
  186. this.state.confirmPassWord &&
  187. this.state.confirmPassWord.length < 6
  188. ) {
  189. this.setState({ comfirmPwLength: true, confirmPassWord: '' })
  190. clearTimeout(this.settime)
  191. this.settime = setTimeout(() => {
  192. this.setState({ comfirmPwLength: false })
  193. }, 3000)
  194. }
  195. this.setState({ mmColor: '#EEE' })
  196. }}
  197. underlineColorAndroid={'transparent'}
  198. clearButtonMode="while-editing"
  199. secureTextEntry={this.state.secureEntry}
  200. onChangeText={text => this.setState({ confirmPassWord: text })}
  201. value={this.state.confirmPassWord}
  202. multiline={false}
  203. // onSubmitEditing={() => this._searchindex()}
  204. placeholder={'请输入密码'}
  205. placeholderTextColor={'#CCC'}
  206. />
  207. {this.state.confirmPassWord ? (
  208. <TouchableOpacity
  209. onPress={() =>
  210. this.setState({ secureEntry: !this.state.secureEntry })
  211. }
  212. style={{
  213. paddingTop: 6,
  214. marginLeft: 3,
  215. }}
  216. >
  217. {this.state.secureEntry ? (
  218. <Icon name="icon-icon-kejian" size={20} color={'#999'} />
  219. ) : (
  220. <Icon name="icon-icon-bukejian" size={20} color={'#999'} />
  221. )}
  222. </TouchableOpacity>
  223. ) : null}
  224. </View>
  225. {this.state.comfirmPwLength ? (
  226. <View style={{ paddingLeft: 104, marginTop: 3 }}>
  227. <Text style={{ color: '#E70013', fontSize: 12 }}>
  228. 输入长度不能小于6位
  229. </Text>
  230. </View>
  231. ) : null}
  232. <ImageBackground
  233. source={loginButton}
  234. resizeMode="stretch"
  235. style={{
  236. alignSelf: 'center',
  237. justifyContent: 'center',
  238. marginTop: 46,
  239. backgroundColor: 'transparent',
  240. width: width * 0.9,
  241. height: 56,
  242. borderRadius: 200,
  243. }}
  244. >
  245. <TouchableOpacity
  246. onPress={() => {
  247. if (this.toast) {
  248. Toast.hide(this.toast)
  249. }
  250. if (this.state.newpassWord && this.state.confirmPassWord) {
  251. if (this.state.newpassWord == this.state.confirmPassWord) {
  252. this.props.dispatch(
  253. createAction('app/modifyPw')({
  254. newpassWord: this.state.newpassWord,
  255. confirmPassWord: this.state.confirmPassWord,
  256. username: this.props.navigation.state.params.username,
  257. })
  258. )
  259. } else {
  260. this.toast = Toast.show('两次输入不一致', {
  261. position: toastHeight,
  262. })
  263. this.setState({ newpassWord: '', confirmPassWord: '' })
  264. }
  265. } else {
  266. this.toast = Toast.show('密码不能为空', {
  267. position: toastHeight,
  268. })
  269. }
  270. }}
  271. >
  272. <Text
  273. style={{
  274. alignSelf: 'center',
  275. fontSize: 14,
  276. lineHeight: 20,
  277. letterSpacing: 0.38,
  278. color: '#FFF',
  279. marginBottom: 5,
  280. }}
  281. >
  282. 修改密码
  283. </Text>
  284. </TouchableOpacity>
  285. </ImageBackground>
  286. </View>
  287. )
  288. } else {
  289. // 忘记密码
  290. return (
  291. <View
  292. style={[
  293. styles.container,
  294. // { backgroundColor: appTheme.backgroundColor }
  295. { backgroundColor: '#FFF' },
  296. ]}
  297. >
  298. <StatusBar
  299. animated={true}
  300. barStyle={appTheme.barStyle}
  301. // barStyle={"dark-content"}
  302. backgroundColor={'transparent'}
  303. translucent={true}
  304. />
  305. {HeaderView(this.props.dispatch, '忘记密码')}
  306. <View
  307. style={{
  308. paddingVertical: 13,
  309. paddingLeft: 5,
  310. marginLeft: 21,
  311. marginRight: 28,
  312. flexDirection: 'row',
  313. alignItems: 'center',
  314. borderBottomWidth: 1,
  315. borderBottomColor: '#EEE',
  316. }}
  317. >
  318. <TextInput
  319. style={{
  320. flex: 1,
  321. padding: 0,
  322. fontSize: 14,
  323. lineHeight: 20,
  324. letterSpacing: 0.38,
  325. color: '#333',
  326. marginTop: 4,
  327. }}
  328. keyboardType={'numeric'}
  329. maxLength={11}
  330. underlineColorAndroid={'transparent'}
  331. clearButtonMode="while-editing"
  332. onChangeText={text => this.setState({ phoneNumber: text })}
  333. value={this.state.phoneNumber}
  334. multiline={false}
  335. // onSubmitEditing={() => this._searchindex()}
  336. placeholder={'请输入手机号'}
  337. placeholderTextColor={'#CCC'}
  338. />
  339. </View>
  340. <ImageBackground
  341. source={loginButton}
  342. resizeMode="stretch"
  343. style={{
  344. alignSelf: 'center',
  345. justifyContent: 'center',
  346. marginTop: 46,
  347. backgroundColor: 'transparent',
  348. width: width * 0.9,
  349. height: 56,
  350. borderRadius: 200,
  351. }}
  352. >
  353. <TouchableOpacity onPress={() => alert('找回密码')}>
  354. <Text
  355. style={{
  356. alignSelf: 'center',
  357. fontSize: 14,
  358. lineHeight: 20,
  359. letterSpacing: 0.38,
  360. color: '#FFF',
  361. marginBottom: 5,
  362. }}
  363. >
  364. 找回密码
  365. </Text>
  366. </TouchableOpacity>
  367. </ImageBackground>
  368. </View>
  369. )
  370. }
  371. }
  372. }
  373. const styles = StyleSheet.create({
  374. container: {
  375. flex: 1,
  376. },
  377. })
  378. export default LogForget