Commit 34236e72 by 姜雷

Merge branch 'develop' into test

parents 89d1b2e5 84b9343c
......@@ -27,30 +27,9 @@ class App extends Component {
userinfo: defaultUserinfo,
updateUserInfo: this.updateUserInfo,
},
loadingText: '加载中...',
};
}
renderLogin = props => {
// const { isWx } = this.state;
const isWx = true;
const { search } = props.location;
const paramsString = search.substring(1);
const searchParams = new URLSearchParams(paramsString);
const code = searchParams.get('code');
const state = searchParams.get('state');
console.log(isWx, code, state);
if (!isWx) {
return <div>请在微信客户端打开链接</div>;
} else if (!code) {
console.log(window.location);
let rUrl = encodeURIComponent('');
window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${APP_ID}&redirect_uri=${rUrl}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`;
return <div>授权中。。。</div>;
} else {
return <Login {...props} code={code} />;
}
};
getParams = str => {
let obj = {};
const searchParams = new URLSearchParams(str);
......@@ -66,11 +45,12 @@ class App extends Component {
userContext: {
userinfo: { login },
},
loadingText,
} = this.state;
const { history, location } = props;
let params = this.getParams(location.search);
if (login) {
return <div style={{ margin: '60px 24px 0' }}>加载中。。。</div>;
return <div style={{ margin: '60px 24px 0' }}>{loadingText}</div>;
}
if (params.code) {
console.log('fetch UserInfo');
......@@ -92,18 +72,22 @@ class App extends Component {
.catch(err => {
console.log(err);
Toast.fail(err.msg || '获取授权失败!');
this.updateUserInfo({ login: true });
this.setState({
loadingText: '请求授权失败!请重新进入或刷新页面!',
});
});
} else {
console.log('go in wxAuth');
this.goWechatAuth();
}
return <div style={{ margin: '60px 24px 0' }}>加载中。。。</div>;
return <div style={{ margin: '60px 24px 0' }}>{loadingText}</div>;
};
goWechatAuth = () => {
let rUrl = encodeURIComponent(window.location.origin);
window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${APP_ID}&redirect_uri=${rUrl}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect`;
return <div>授权中。。。</div>;
return <div style={{ margin: '60px 24px 0' }}>授权中。。。</div>;
};
validateUserinfo = (props, code, Component) => {
const {
......@@ -115,8 +99,8 @@ class App extends Component {
if (!login) {
console.log('no login');
// product 需要修改为去微信授权
return <Component />;
// return this.goWechatAuth();
// return <Component />;
return this.goWechatAuth();
}
let item = author.find(i => i.code === code);
if (item.type) {
......
......@@ -137,11 +137,11 @@ class ReprtRepair extends Component {
Toast.fail('请选择报修人身份!');
return;
}
if (!applyForm.areaId) {
if (!applyForm.area) {
Toast.fail('请选择报修区域!');
return;
}
if (!applyForm.termId) {
if (!applyForm.term) {
Toast.fail('请选择报修项目!');
return;
}
......@@ -149,6 +149,17 @@ class ReprtRepair extends Component {
Toast.fail('请输入报修地址!');
return;
}
let imgList = applyForm.uploadImg.filter(i => i !== null);
if (imgList.length) {
let size = imgList.reduce((totle, item) => {
let fileSize = item.filesList[0].size;
return totle + fileSize;
}, 0);
if (size > 10485760) {
Toast.fail('上传图片过大!');
return;
}
}
return true;
};
startApply = () => {
......
class Store {
constructor() {
this.userId = '34';
this.userId = '';
}
getUserId = () => {
return this.userId;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment