1+ /***********************************************
2+ *
3+ * MIT License
4+ *
5+ * Copyright (c) 2016 珠峰课堂,Ramroll
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in all
14+ * copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ * SOFTWARE.
23+ *
24+ */
25+
26+ import React , { Component } from 'react'
27+
28+
29+ import { TextInput , StyleSheet , View , Text , TouchableOpacity , Image } from 'react-native'
30+
31+ import { flexCenter } from 'basic'
32+ import { COLOR_TEXT_LIGHT , COLOR_LIGHT_BLUE , COLOR_PRIMARY } from "domain/def"
33+
34+ import { url_mapper } from "domain/api/http"
35+ import { get_local_token } from "domain/store/storage"
36+ import { get_image } from "domain/api/apis"
37+
38+ export class ZImgCode extends Component {
39+
40+ constructor ( ) {
41+ super ( )
42+
43+ this . state = {
44+ img : null
45+ }
46+
47+ }
48+
49+
50+ async _load ( ) {
51+
52+ const token = await get_local_token ( )
53+ const img = await get_image ( )
54+ this . setState ( {
55+ img
56+ } )
57+
58+ }
59+
60+ componentDidMount ( ) {
61+
62+ this . _load ( )
63+
64+ }
65+
66+ _change ( value ) {
67+ this . props . onChange ( value )
68+ }
69+
70+ render ( ) {
71+ const { error, ...others } = this . props
72+ const { img} = this . state
73+
74+
75+ return < View style = { styles . container } >
76+ < TextInput style = { styles . input } keyboardType = "phone-pad" onChangeText = { this . _change . bind ( this ) } { ...others } placeholder = "图片验证码" />
77+
78+ { img &&
79+ < View style = { { ...styles . btn , ...styles . btnDisabled } } >
80+ < Image style = { { width : 100 , height :42 } } source = { { uri : img } } />
81+ </ View >
82+ }
83+ </ View >
84+ }
85+ }
86+
87+ const styles = {
88+ container : {
89+
90+ marginTop : 20 ,
91+ marginRight : 20 ,
92+ flexDirection : "row" ,
93+ marginLeft : 20 ,
94+ alignItems : "center"
95+
96+ } ,
97+ input : {
98+ borderWidth : 1 ,
99+ borderRadius : 5 ,
100+ borderColor : "#eee" ,
101+ paddingLeft : 20 ,
102+ paddingRight : 20 ,
103+ height : 42 ,
104+ color : COLOR_TEXT_LIGHT ,
105+ flex : 1 ,
106+
107+ } ,
108+ btn : {
109+ borderRadius : 5 ,
110+ borderColor : COLOR_PRIMARY ,
111+ borderWidth : 1 ,
112+ height : 42 ,
113+ paddingLeft : 20 ,
114+ paddingRight : 20 ,
115+ marginLeft : 10 ,
116+ backgroundColor : COLOR_LIGHT_BLUE ,
117+ ...flexCenter
118+
119+
120+ } ,
121+ btnDisabled : {
122+ backgroundColor : "#f2f3f4" ,
123+ borderColor : "#eee"
124+ } ,
125+ btnText : {
126+ color : COLOR_PRIMARY
127+ }
128+
129+ }
0 commit comments