king
2020-07-01 9a16cb432ed0a597caf9ba78c9dda63ad2134207
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { InputItem, Icon, Checkbox, List, Button } from 'antd-mobile'
import { createForm } from 'rc-form'
 
import zhCN from '@/locales/zh-CN/mob.js'
import enUS from '@/locales/en-US/mob.js'
import ContentUpdate from '@/mob/contupdate'
import './index.scss'
 
const CheckboxItem = Checkbox.CheckboxItem
// const PlaceHolder = ({ active = false, children}) => (
//   <div>{active ? <div></div> : null}{children}</div>
// )
 
class MobLogin extends Component {
  static propTpyes = {
    card: PropTypes.object,
    editId: PropTypes.any,
    triggerEdit: PropTypes.func,
    updateConfig: PropTypes.func,
    onDoubleClick: PropTypes.func
  }
 
  state = {
    dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    rember: true,
    param: {
      background: {color: '#000000', image: ''},
      logo: {width: ''}
    }
  }
 
  UNSAFE_componentWillMount () {
 
  }
 
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
  }
 
  onChange = (e) => {
    const { rember } = this.state
    e.stopPropagation()
 
    this.setState({
      rember: !rember
    })
  }
 
  onChangeLang = (value) => {
    this.setState({
      lang: value
    })
  }
 
  editLogo = (e) => {
    const { card } = this.props
    e.stopPropagation()
    let element = {
      uuid: card.logo.uuid,
      items: ['picture'],
      item: fromJS(card.logo).toJS()
    }
    this.props.triggerEdit(element)
  }
 
  editTitle = (e) => {
    const { card } = this.props
    e.stopPropagation()
    let element = {
      uuid: card.title.uuid,
      items: ['font'],
      item: fromJS(card.title).toJS()
    }
    this.props.triggerEdit(element)
  }
 
  editMsg = (e) => {
    const { card } = this.props
    e.stopPropagation()
    let element = {
      uuid: card.copyright.uuid,
      items: ['font'],
      item: fromJS(card.copyright).toJS()
    }
    this.props.triggerEdit(element)
  }
 
  editBox = (e) => {
    const { card } = this.props
    e.stopPropagation()
    let element = {
      uuid: card.box.uuid,
      items: ['font', 'padding', 'background'],
      item: fromJS(card.box).toJS()
    }
    this.props.triggerEdit(element)
  }
 
  updateContent = (card) => {
    this.props.updateConfig(card)
  }
 
  render () {
    const { card, editId } = this.props
    const { getFieldProps } = this.props.form
    const { rember } = this.state
 
    return (
      <div className="mob-login" onClick={this.editBox} style={{paddingTop: `calc(17vh - 10px)`}}>
        <div className={'logo ' + (editId === card.logo.uuid ? 'editing' : '')} onClick={this.editLogo}>
          <ContentUpdate element={card.logo} updateContent={(ele) => this.updateContent({...card, logo: ele})}/>
          <img src={card.logo.content} alt=""/>
        </div>
        <div className={'plat-name ' + (editId === card.title.uuid ? 'editing' : '')} onClick={this.editTitle}>
          <ContentUpdate element={card.title} updateContent={(ele) => this.updateContent({...card, title: ele})}/>
          {card.title.content}
        </div>
        <InputItem
          placeholder="UserName"
          prefixListCls="mk-login-item am-list"
          {...getFieldProps('userName', {
            initialValue: 'admin',
          })}
          disabled={true}
        >
          <Icon type="check-circle-o" />
        </InputItem>
        <InputItem
          placeholder="Password"
          prefixListCls="mk-login-item am-list"
          {...getFieldProps('password', {
            initialValue: '123456',
          })}
          type={'password'}
          disabled={true}
        >
          <Icon type="check-circle" />
        </InputItem>
        <div className="other-setting">
          <CheckboxItem checked={rember} onChange={this.onChange}>
            <span onClick={this.onChange}>记住密码</span>
          </CheckboxItem>
          {/* <Picker data={langs} value={lang} cols={1} onChange={this.onChangeLang} className="forss">
            <List.Item>{lang}</List.Item>
          </Picker> */}
          <List.Item className="lang">中文简体</List.Item>
          <div className="clear-both"></div>
        </div>
        <Button type="primary" onDoubleClick={() => this.props.doubleClickCard(card.login)}>登录</Button>
        <div className={'company-msg ' + (editId === card.copyright.uuid ? 'editing' : '')} onClick={this.editMsg}>
          <ContentUpdate element={card.copyright} updateContent={(ele) => this.updateContent({...card, copyright: ele})}/>
          <p>{card.copyright.content}</p>
        </div>
      </div>
    )
  }
}
 
export default createForm()(MobLogin)