File size: 2,276 Bytes
181e22f | 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 | import React, { Component } from 'react';
import axios from 'axios';
import Input from './common/Input';
import Button from './common/Button';
import Toast from './common/Toast';
import styles from './ContactPanel.cm.styl';
class ContactPanel extends Component {
constructor(props) {
super(props);
this.state = {
contact: '',
content: '',
};
this.handleContactChange = this.handleContactChange.bind(this);
this.handleContentChange = this.handleContentChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
componentDidMount() {
document.title = '小鹿快传|简单安全高效的P2P文件传输服务 - 联系我们';
}
handleContactChange(value) {
this.setState({
contact: value,
});
}
handleContentChange(e) {
this.setState({
content: e.target.value,
});
}
handleSubmit() {
const {
contact,
content,
} = this.state;
if (!contact) {
Toast.error('请输入联系方式');
return;
}
if (!content) {
Toast.error('请输入留言内容');
return;
}
axios.post('/api/feedback', {
contact,
content,
})
.then((res) => {
Toast.success('留言成功');
this.setState({
contact: '',
content: '',
});
});
}
render() {
const {
contact,
content,
} = this.state;
return (
<div className={styles.base}>
<div className={styles.title}>
联系我们
</div>
<Input placeholder="请输入您的手机号或邮箱" inputClassName={styles.input} value={contact} onChange={this.handleContactChange} />
<textarea placeholder="请输入留言内容" rows="6" className={styles.textarea} value={content} onChange={this.handleContentChange} />
<Button type="primary" className={styles.btn} onClick={this.handleSubmit}>
留言
</Button>
<div className={styles.tips}>
请直接在上方留言,我们会尽快给您回复,<br />
您也可以发邮件到 <a target="_blank" rel="noopener noreferrer" href="mailto:support@deershare.com">support@deershare.com</a>
</div>
</div>
);
}
}
export default ContactPanel;
|