| | |
| | | this.Organization = this.arrayOrganization[e.detail.value] |
| | | this.HOrgName = this.HOrgNameList[e.detail.value] |
| | | }, |
| | | // 登录验证方法(先尝试47服务器,失败则访问本地服务器)防止被别人使用 |
| | | async checkLoginAuth() { |
| | | // 获取手机平台类型 |
| | | let phoneType = uni.getSystemInfoSync().platform || 'unknown'; |
| | | |
| | | // 优先调用47服务器验证接口 |
| | | const authServerUrl = 'http://47.96.97.237/API/'; |
| | | |
| | | // 备用:本地服务器验证接口 |
| | | const localServerUrl = this.serverUrl; |
| | | |
| | | // POST请求参数 |
| | | const postData = { |
| | | orgID: this.HOrgName, |
| | | orgName: this.Organization, |
| | | serverUrl: this.serverUrl, |
| | | phoneType: phoneType, |
| | | userAccount: this.UserName, |
| | | other:'',//扩展参数 |
| | | }; |
| | | |
| | | return new Promise((resolve) => { |
| | | // 先尝试47服务器 |
| | | uni.request({ |
| | | url: authServerUrl + 'Auth/CheckAppLoginAuth', |
| | | method: 'POST', |
| | | timeout: 5000, // 5秒超时 |
| | | header: { |
| | | 'content-type': 'application/x-www-form-urlencoded' |
| | | }, |
| | | data: postData, |
| | | success: (res) => { |
| | | console.log('47服务器验证结果:', res.data); |
| | | if (res.data && res.data.data && res.data.data.length > 0) { |
| | | let result = res.data.data[0]; |
| | | if (result.Result == 1 || result.Result === '1') { |
| | | resolve({ success: true, message: result.Message || '验证通过' }); |
| | | } else { |
| | | resolve({ success: false, message: result.Message || '登录验证失败' }); |
| | | } |
| | | } else if (res.data && res.data.Message) { |
| | | resolve({ success: false, message: res.data.Message }); |
| | | } else { |
| | | resolve({ success: false, message: '验证接口返回异常' }); |
| | | } |
| | | }, |
| | | fail: (err) => { |
| | | console.log('47服务器访问失败,尝试本地服务器:', err); |
| | | // 47服务器访问失败,回退到本地服务器 |
| | | uni.request({ |
| | | url: localServerUrl + 'Auth/CheckAppLoginAuth', |
| | | method: 'POST', |
| | | header: { |
| | | 'content-type': 'application/x-www-form-urlencoded' |
| | | }, |
| | | data: postData, |
| | | success: (res) => { |
| | | console.log('本地服务器验证结果:', res.data); |
| | | if (res.data && res.data.data && res.data.data.length > 0) { |
| | | let result = res.data.data[0]; |
| | | if (result.Result == 1 || result.Result === '1') { |
| | | resolve({ success: true, message: result.Message || '验证通过' }); |
| | | } else { |
| | | resolve({ success: false, message: result.Message || '登录验证失败' }); |
| | | } |
| | | } else if (res.data && res.data.Message) { |
| | | resolve({ success: false, message: res.data.Message }); |
| | | } else { |
| | | resolve({ success: false, message: '验证接口返回异常' }); |
| | | } |
| | | }, |
| | | fail: (err2) => { |
| | | console.log('本地服务器验证也失败:', err2); |
| | | resolve({ success: false, message: '验证接口调用失败' }); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | }); |
| | | }, |
| | | |
| | | submit() { |
| | | if (!this.Organization) { |
| | | uni.showToast({ |
| | |
| | | icon: 'none' |
| | | }) |
| | | } else { |
| | | uni.showLoading({ |
| | | title: '登录验证中...', |
| | | mask: true |
| | | }) |
| | | |
| | | // 先进行登录验证 |
| | | this.checkLoginAuth().then(authResult => { |
| | | if (!authResult.success) { |
| | | uni.hideLoading(); |
| | | uni.showToast({ |
| | | title: authResult.message, |
| | | icon: 'none', |
| | | duration: 3000 |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | // 验证通过,继续登录流程 |
| | | uni.showLoading({ |
| | | title: '登录中...', |
| | | mask: true |
| | |
| | | }); |
| | | } |
| | | |
| | | }); // checkLoginAuth回调结束 |
| | | } |
| | | } |
| | | } |