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 = {
|
...fromJS(card.logo.style).toJS(),
|
componentId: card.uuid,
|
uuid: card.logo.uuid,
|
items: []
|
}
|
this.props.triggerEdit(element)
|
}
|
|
editTitle = (e) => {
|
const { card } = this.props
|
e.stopPropagation()
|
let element = {
|
...fromJS(card.title.style).toJS(),
|
componentId: card.uuid,
|
uuid: card.title.uuid,
|
items: ['font'],
|
}
|
this.props.triggerEdit(element)
|
}
|
|
editMsg = (e) => {
|
const { card } = this.props
|
e.stopPropagation()
|
let element = {
|
...fromJS(card.copyright.style).toJS(),
|
componentId: card.uuid,
|
uuid: card.copyright.uuid,
|
items: ['font'],
|
}
|
this.props.triggerEdit(element)
|
}
|
|
editLogin = (e) => {
|
const { card } = this.props
|
e.stopPropagation()
|
let element = {
|
...fromJS(card.login.style).toJS(),
|
componentId: card.uuid,
|
uuid: card.login.uuid,
|
items: ['font', 'background']
|
}
|
this.props.triggerEdit(element)
|
}
|
|
editBox = (e) => {
|
const { card } = this.props
|
e.stopPropagation()
|
let element = {
|
...fromJS(card.box.style).toJS(),
|
componentId: card.uuid,
|
uuid: card.box.uuid,
|
items: ['font', 'padding', 'background'],
|
}
|
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={card.box.style}>
|
{card.logo ? <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> : null}
|
{card.title ? <div className={'plat-name ' + (editId === card.title.uuid ? 'editing' : '')} style={card.title.style} onClick={this.editTitle}>
|
<ContentUpdate element={card.title} updateContent={(ele) => this.updateContent({...card, title: ele})}/>
|
{card.title.content}
|
</div> : null}
|
<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"
|
className={'login ' + (editId === card.login.uuid ? 'editing' : '')}
|
onDoubleClick={() => this.props.doubleClickCard(card.login)}
|
style={card.login.style}
|
onClick={this.editLogin}
|
>
|
<ContentUpdate element={card.login} deletable={false} updateContent={(ele) => this.updateContent({...card, login: ele})}/>
|
{card.login.content}
|
</Button>
|
{card.copyright ? <div className={'company-msg ' + (editId === card.copyright.uuid ? 'editing' : '')} style={card.copyright.style} onClick={this.editMsg}>
|
<ContentUpdate element={card.copyright} updateContent={(ele) => this.updateContent({...card, copyright: ele})}/>
|
{card.copyright.content}
|
</div> : null}
|
</div>
|
)
|
}
|
}
|
|
export default createForm()(MobLogin)
|