-
Notifications
You must be signed in to change notification settings - Fork 0
/
Feedback.js
87 lines (83 loc) · 3.26 KB
/
Feedback.js
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
import 'babel-polyfill'
import React, { Component } from 'react'
import RCUpload from 'rc-upload'
class Feedback extends Component {
constructor(props) {
super(props)
this.state = {
captures: [],
error: '',
content: '',
}
}
hideDialogOnOverlay() {
}
render() {
const { captures, error, content } = this.state
return (
<div className="feedback" onClick={this.hideDialogOnOverlay}>
<div className="dialog-container">
<form ref={c => (this._dialog = c)} className="dialog" onSubmit={this.submit}>
<div className="close" onClick={this.hideDialog}>×</div>
<div className="title">请填写反馈内容</div>
<div className="editor">
<textarea name="feedback" value={content} onChange={this.handleChange} placeholder="请填写" maxLength={1000} />
{error && <div className="error">{error}</div>}
</div>
<div className="title">上传图片</div>
<div className="captures">
<RCUpload
className="pic add"
multiple
accept="image/*,.txt,.doc,.docx"
withCredentials
name="file"
style={{}} // if it's undefined now, but not in snapshot, or the opposite, it would throw errors.
beforeUpload={this.handleBeforeUpload}
onStart={this.handleUploadStart}
onError={this.handleUploadError}
onSuccess={this.handleUploadSuccess}
>
<div className="h-line" />
<div className="v-line" />
</RCUpload>
{captures.map(item => {
let content
if (item.state === 'success') {
content = (
<div className="msg success">
{!this.isImage(item.name) && [
<FaFile size={50} className="icon" />,
<div className="name">{item.name}</div>
]}
</div>
)
} else if (item.state === 'error') {
content = <div className="msg error">{item.msg || '上传失败'}</div>
} else if (item.state === 'pending') {
content = <div className="msg info">{item.msg}</div>
}
return (
<div
key={item.uid}
className="pic"
style={item.url ? {backgroundImage: `url("${item.url}")`} : {}}
>
<div className="del" onClick={() => this.remove(item)}>
<MdClose className="icon" />
</div>
{/* <div className="del" onClick={() => this.remove(item)}>×</div> */}
{content}
</div>
)
})}
</div>
<div className="tips">可以上传不超过3个文件,每个限制最大为1MB,类型限制为 jpg / jpeg / gif / png / txt / docx / doc</div>
<div className="btn-submit" onClick={this.submit}>好了,发送反馈</div>
</form>
</div>
</div>
)
}
}
export default Feedback;