wtt
2 天以前 7a02930f8781c99c67142f3785face66734af8e5
登录添加验证功能
3个文件已修改
118 ■■■■■ 已修改文件
manifest.json 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/ZLGL/QualityReportStep/QualityReportStepBill.vue 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/index/login.vue 100 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
manifest.json
@@ -2,8 +2,8 @@
    "name" : "智云LMES",
    "appid" : "__UNI__B002F49",
    "description" : "",
    "versionName" : "3.022",
    "versionCode" : 322,
    "versionName" : "3.026",
    "versionCode" : 326,
    "transformPx" : false,
    /* 5+App特有相关 */
    "app-plus" : {
pages/ZLGL/QualityReportStep/QualityReportStepBill.vue
@@ -1248,22 +1248,20 @@
            },
            // 设置为自动
            setAuto() {
                if (uni.getSystemInfoSync().platform === 'android' ||
                      uni.getSystemInfoSync().platform === 'ios') {
                    plus.screen.unlockOrientation();
                }
                //#ifdef APP-PLUS
                plus.screen.unlockOrientation()
                //#endif
            },
            // 设置为竖屏
            setPortrait() {
              if (uni.getSystemInfoSync().platform === 'android' ||
                  uni.getSystemInfoSync().platform === 'ios') {
                //#ifdef APP-PLUS
                plus.screen.lockOrientation('portrait');
              }
              //#endif
            },
            
        },
        async onLoad(e) {
            //this.setAuto();
            this.setAuto();
            this.operationType = e.operationType || 1;
            this.hform.HInterID = e.linterid || 0;
            if (this.operationType == 1) {
pages/index/login.vue
@@ -291,6 +291,87 @@
                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({
@@ -308,6 +389,24 @@
                        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
@@ -433,6 +532,7 @@
                        });
                    }
                    }); // checkLoginAuth回调结束
                }
            }
        }