提交 498d48d8 authored 作者: 钟是志's avatar 钟是志

移动端签名组件重构

上级 ba7eb83c
...@@ -21,8 +21,8 @@ function saveSign(url) { ...@@ -21,8 +21,8 @@ function saveSign(url) {
const userInfo = getUserInfo(); const userInfo = getUserInfo();
uaaRequest('/UserApi/saveMySysBackgroundImage', { uaaRequest('/UserApi/saveMySysBackgroundImage', {
username: userInfo.stuNo, username: userInfo.stuNo,
backgroundImageUrl: userInfo.backgroundImageUrl, backgroundImageUrl: userInfo.backgroundImageUrl || 'fakeBackgroundImageUrl', // 假数据
isUseBackImage: userInfo.isUseBackImage, isUseBackImage: userInfo.isUseBackImage || false,
userSign: url, userSign: url,
}) })
.then((g) => { .then((g) => {
...@@ -69,9 +69,8 @@ export default class Index extends Component { ...@@ -69,9 +69,8 @@ export default class Index extends Component {
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
// Should be a controlled component. // Should be a controlled component.
if ('value' in nextProps) { if ('value' in nextProps && nextProps.value) {
const value = nextProps.value; const value = nextProps.value;
this.setState({ url: value }); this.setState({ url: value });
// //
...@@ -96,6 +95,7 @@ export default class Index extends Component { ...@@ -96,6 +95,7 @@ export default class Index extends Component {
this.triggerChange(null); this.triggerChange(null);
}; };
trim = () => { trim = () => {
message.info('正在保存签名,请等待');
const formData = new FormData(); const formData = new FormData();
const xx = dataURLtoBlob(this.sigCanvas.toDataURL('image/png')); const xx = dataURLtoBlob(this.sigCanvas.toDataURL('image/png'));
const file = blobToFile(xx, 'sign.png'); const file = blobToFile(xx, 'sign.png');
...@@ -131,6 +131,7 @@ export default class Index extends Component { ...@@ -131,6 +131,7 @@ export default class Index extends Component {
if (!('value' in this.props)) { if (!('value' in this.props)) {
this.setState({ url: e.response }); this.setState({ url: e.response });
} }
this.changeShowModal();
this.triggerChange(e.response); this.triggerChange(e.response);
} else { } else {
message.error('保存失败'); message.error('保存失败');
...@@ -156,7 +157,14 @@ export default class Index extends Component { ...@@ -156,7 +157,14 @@ export default class Index extends Component {
const { url } = this.state; const { url } = this.state;
if (url) { if (url) {
return <div className={styles.mobileSign}> return <div className={styles.mobileSign}>
<Button type={'primary'}
onClick={this.changeShowModal}
className={styles.reSign}
>
重新签名
</Button>
<img src={config.httpServer + url} style={{}}
/>
</div>; </div>;
} else { } else {
return <div className={styles.mobileSign2}> return <div className={styles.mobileSign2}>
...@@ -177,8 +185,12 @@ export default class Index extends Component { ...@@ -177,8 +185,12 @@ export default class Index extends Component {
width={'100vw'} width={'100vw'}
onCancel={this.changeShowModal} onCancel={this.changeShowModal}
visible={true} visible={true}
onOk={this.trim}
title={'签名'} title={'签名'}
bodyStyle={{minHeight: '350px'}} bodyStyle={{
minHeight: '350px',
padding: '24px 12px',
}}
> >
<div className={styles.borderDiv}> <div className={styles.borderDiv}>
<SignatureCanvas <SignatureCanvas
...@@ -207,11 +219,11 @@ export default class Index extends Component { ...@@ -207,11 +219,11 @@ export default class Index extends Component {
const { url } = this.state; const { url } = this.state;
if (get === 'mobile') { if (get === 'mobile') {
const MobileSign = this.MobileSign; // const MobileSign = this.MobileSign;
const MobileModal = this.MobileModal; // const MobileModal = this.MobileModal;
return <> return <>
<MobileSign /> <this.MobileSign />
<MobileModal /> <this.MobileModal />
</>; </>;
} }
......
...@@ -10,3 +10,13 @@ ...@@ -10,3 +10,13 @@
border: 1px solid #555; border: 1px solid #555;
margin-top: 20px; margin-top: 20px;
} }
.mobileSign{
position: relative;
text-align: center;
img{
max-width: 85%;
max-height: 300px;
}
.reSign{
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论