<template>
    <view>
        <!-- pages/login/login.wxml -->
        <nav-bar :navbarData="navbarData"></nav-bar>
        <view v-if="loginStaus == 'N'" class="LoginBody" :style="'min-height: calc(100vh - ' + (height * 2 + 80) + 'rpx)'">
            <view class="topimg">
                <view class="version">
                    <text class="version-text">{{ appVersion != '' ? 'V' : '' }}{{ appVersion }}</text>
                    <image
                        @tap="help"
                        class="help"
                        :src="imgDomain + '/images/icon/doctor/helpandback.png'"
                    ></image>
                </view>
                <view class="brand">
                    <view class="logo-wrap">
                        <image v-if="appInfo && appInfo.hospLogo && appInfo.hospLogo !== ''" class="logo" :src="appInfo.hospLogo"></image>
                        <text v-else class="logo-text">医</text>
                        <view class="logo-add-icon">+</view>
                    </view>
                    <view class="brand-title">{{ appInfo && appInfo.docAppName ? appInfo.docAppName : '互联网医院医生端' }}</view>
                    <view class="brand-subtitle">医生工作台</view>
                </view>
            </view>

            <form class="login-form" @submit="formSubmit">
                <view class="logincon">
                    <view class="login-panel">
                    <!-- loginuser -->
                    <view class="useript">
                        <view class="field-label">账号</view>
                        <input type="text" placeholder="请输入账号" @input="userNameFun" name="phonenum" placeholder-style="color:#9aa8bd;" />
                    </view>
                    <!-- loginpw -->
                    <view class="useript">
                        <view class="field-label">密码</view>
                        <input
                            :value="passWord"
                            type="password"
                            placeholder="请输入密码"
                            @blur="passWordBlur"
                            @input="passWordFun"
                            password="1"
                            name="code"
                            placeholder-style="color:#9aa8bd;"
                        />
                    </view>
                    <view class="useript" v-if="verificationFlag == 'Y'">
                        <view class="field-label">手机号</view>
                        <input type="text" placeholder="请输入手机号" @input="phoneNumberFun" name="phoneNumber" placeholder-style="color:#9aa8bd;" />
                    </view>
                    <view class="useript" v-if="verificationFlag == 'Y'">
                        <view class="field-label field-label-long">验证码</view>
                        <input type="text" placeholder="请输入验证码" @input="verificationCodeFun" name="verificationCode" placeholder-style="color:#9aa8bd;" />
                    </view>

                    <view v-if="verificationFlag == 'Y'" class="code" @tap="getverificationCode">
                        <view :class="sendState ? (getState ? 'node' : 'node') : 'node1'">
                            <text class="control-count-down">{{ verificationSecond }}</text>
                        </view>
                        {{ sendState ? (getState ? '获取中...' : '获取验证码') : '秒后重新获取' }}
                    </view>
                    <!-- <view class='useript'>
        <input type='number' disabled="true " placeholder='科室' value="{{locInfo}} " placeholder-style='color:#ccc;'>
        </input>
      </view> -->
                    <!-- logbtn -->

                    <button class="logbtn" @tap="login">
                        <text v-if="loginState" class="login-dot"></text>
                        {{ loginState ? '正在登录...' : '登录' }}
                    </button>

                    </view>
                </view>
            </form>
        </view>
        <view v-if="loginStaus == 'Y'" class="personalcenter" :style="'min-height: calc(100vh - ' + (height * 2 + 80) + 'rpx)'">
            <personalcenter id="personalcenter" @loginOut="loginOut($event, { tagId: 'personalcenter' })" @hide="hidePage($event, { tagId: 'personalcenter' })" />
        </view>
    </view>
</template>

<script>
import personalcenter from '../personalcenter/personalcenter';
import navBar from '@/pages/components/navbar/index';
// pages/yzlogin/yzlogin.js
import Aes from '../../../config/Aes.js';
import messageUtil from '../../../utils/message.js';
import Util from '../../../utils/util.js';
import { $http } from '../../../config/https.js';
import { httpconfig } from '../../../config/httpconfig';
import Cache from '../../../utils/cache.js';
const app = getApp();
export default {
    components: {
        personalcenter,
        navBar
    },
    data() {
        return {
            imgDomain: httpconfig.imgDomain,
            canIUse: uni.canIUse('button.open-type.getUserInfo'),
            loginStaus: 'N',
            userName: '',
            passWord: '',
            locIDIndex: '',
            locInfo: '',
            ip: '127.0.0.1',

            navbarData: {
                background: "url('" + httpconfig.imgDomain + "/images/icon/myhead.png')",
                title: '我的',
                //导航栏 中间的标题
                height: '100',
                bottom: true,
                cleanPat: 'Y'
            },

            height: app.globalData.height,
            appVersion: '0.0.0.0',

            appInfo: {
                hospLogo: ''
            },

            verificationFlag: 'N',

            //是否需要短信验证
            verificationCode: '',

            //短信验证码
            phoneNumber: '',

            //手机号
            sendState: true,

            /**验证码发送状态 */
            getState: false,

            verificationState: null,
            verificationSecond: '',
            verificationTimer: null,
            loginState: false,
            verificationCheck: false,
            tabBar: '',
            locDisabled: false,
            locList: ''
        };
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that = this;
        uni.request({
            url: httpconfig.domain + '/localIP',
            success: function (e) {
                console.log('IP地址:', e);
                that.setData({
                    ip: e.data.ipv4
                });
            }
        });
        let userData = Cache.get('userData');
        if (userData && userData.userID) {
            this.setData({
                loginStaus: 'Y'
            });
            return;
        }

        // 单点登录：检测 URL 中的 data 和 hospID 参数
        var ssoData = (options && options.data) || (app.globalData && app.globalData.ssoData);
        var ssoHospID = (options && options.hospID) || (app.globalData && app.globalData.ssoHospID) || '88';
        if (ssoData) {
            // 清除全局数据中的 SSO 参数，避免重复触发
            if (app.globalData) {
                app.globalData.ssoData = '';
                app.globalData.ssoHospID = '';
            }
            if (app.globalData && app.globalData.handleSSO) {
                app.globalData.handleSSO(ssoData, ssoHospID, options || {});
            }
            return;
        }
        var accountInfo = typeof uni.getAccountInfoSync === 'function' ? uni.getAccountInfoSync() : { miniProgram: { version: '', appId: '' } };
        this.setData({
            appVersion: accountInfo.miniProgram.version
        });
        var appID = accountInfo.miniProgram.appId;
        uni.login({
            success(res) {
                if (res.code) {
                    Util.getOpenID(res.code, (openid) => {
                        // 登录接口
                        let data = {
                            params: [
                                {
                                    openID: openid,
                                    appID: appID,
                                    status: 'Y'
                                }
                            ]
                        };
                        $http.post('urlDeault', this, {
                            code: '03100014',
                            data: data,
                            success: function (res) {
                                if (res.errorCode == '0') {
                                    if (res.result && res.result.userID) {
                                        if (res.result.userCode.indexOf('xyskf') > -1) {
                                            locInfo.userID = 'KF001';
                                            uni.setStorage({
                                                key: 'userData',
                                                data: res.result,
                                                success: function () {
                                                    setTimeout(() => {
                                                        that.redirectAfterLogin();
                                                    }, 1000);
                                                }
                                            });
                                        } else {
                                            uni.setStorage({
                                                key: 'userData',
                                                data: res.result,
                                                success: function () {}
                                            });
                                            that.setData(
                                                {
                                                    loginStaus: 'Y',
                                                    navbarData: {
                                                        background: "url('" + httpconfig.imgDomain + "/images/icon/myhead.png')",
                                                        title: '我的',
                                                        //导航栏 中间的标题
                                                        height: '100',
                                                        bottom: false
                                                    }
                                                },
                                                () => {
                                                    setTimeout(() => {
                                                        that.redirectAfterLogin();
                                                    }, 1000);
                                                }
                                            );
                                        }
                                    } else {
                                        that.setData({
                                            loginStaus: 'N'
                                        });
                                    }
                                } else {
                                    that.setData({
                                        loginStaus: 'N'
                                    });
                                }
                            },
                            fail: function (res) {
                                that.setData({
                                    loginStaus: 'N'
                                });
                            }
                        });
                    });
                } else {
                    that.setData({
                        loginStaus: 'N'
                    });
                }
            },
            fail: function () {
                that.setData({
                    loginStaus: 'N'
                });
            }
        });
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {
        this.personalcenter = this.zpSelectComponent('#personalcenter');
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        let userData = Cache.get('userData');
        let appInfo = Cache.get('appInfo');
        var accountInfo = typeof uni.getAccountInfoSync === 'function' ? uni.getAccountInfoSync() : { miniProgram: { version: '' } };
        if (userData && userData.userID) {
            this.setData({
                loginStaus: 'Y',
                navbarData: {
                    background: "url('" + httpconfig.imgDomain + "/images/icon/myhead.png')",
                    title: '我的',
                    //导航栏 中间的标题
                    height: '100',
                    bottom: false
                },
                appInfo: appInfo,
                verificationFlag: 'N',
                appVersion: accountInfo.miniProgram.version
            });
        } else {
            this.setData({
                loginStaus: 'N',
                navbarData: {
                    background: '',
                    title: '登录',
                    //导航栏 中间的标题
                    height: '100',
                    bottom: false
                },
                appInfo: appInfo,
                verificationFlag: 'N',
                appVersion: accountInfo.miniProgram.version
            });
        }
    },
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {
        this.clearVerificationTimer();
    },
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {
        this.clearVerificationTimer();
        // wx.reLaunch({
        //   url: '../index/index'
        // })
    },
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {},
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {},
    onTabItemTap: function (e) {
        console.log(e);
    },
    methods: {
        /**
         * 获取用户信息
         */
        bindGetUserInfo(e) {
            console.log(e.detail.userInfo);
        },

        userNameFun: function (e) {
            this.setData({
                locInfo: '',
                userName: e.detail.value,
                passWord: '',
                phoneNumber: '',
                verificationCode: ''
            });
        },

        passWordFun: function (e) {
            if (e.detail.value.length > 12) {
                uni.showToast({
                    title: '密码不能超过12位',
                    icon: 'none'
                });
            }
            this.setData({
                locInfo: '',
                passWord: e.detail.value.substring(0, 12)
            });
        },

        phoneNumberFun: function (event) {
            if (event.detail.value && /^1[3456789]\d{9}$/.test(event.detail.value.replace(/\s*/g, ''))) {
                this.setData({
                    verificationState: null,
                    sendState: true,
                    getState: false
                });
                this.setData({
                    phoneNumber: event.detail.value
                });
            } else {
                this.setData({
                    phoneNumber: ''
                });
            }
        },

        start() {
            this.clearVerificationTimer();

            let remaining = Math.max(1, Math.ceil((Number(this.verificationState) || 60000) / 1000));
            this.setData({
                verificationSecond: remaining
            });
            this.verificationTimer = setInterval(() => {
                remaining -= 1;
                if (remaining <= 0) {
                    this.finished();
                    return;
                }
                this.setData({
                    verificationSecond: remaining
                });
            }, 1000);
        },

        clearVerificationTimer() {
            if (this.verificationTimer) {
                clearInterval(this.verificationTimer);
                this.verificationTimer = null;
            }
        },

        finished() {
            this.clearVerificationTimer();
            this.setData({
                verificationState: null,
                verificationSecond: '',
                sendState: true,
                getState: false
            });
        },

        verificationCodeFun: function (e) {
            this.setData({
                verificationCode: e.detail.value
            });
        },

        /**获取验证码
         * **/
        getverificationCode: function () {
            this.setData({
                getState: true
            });
            if (!this.phoneNumber) {
                uni.showModal({
                    title: '提示',
                    content: '手机号码有误!',
                    showCancel: false
                });
                this.setData({
                    getState: false,
                    loginState: false
                });
                return;
            }
            if (!this.sendState) {
                this.setData({
                    getState: false,
                    loginState: false
                });
                return;
            }
            var accountInfo = typeof uni.getAccountInfoSync === 'function' ? uni.getAccountInfoSync() : { miniProgram: { appId: '' } };
            var appID = accountInfo.miniProgram.appId;
            let data = {
                params: [
                    {
                        mobile: this.phoneNumber,
                        HISFlag: 'N',
                        UPPFlag: 'N',
                        typeCode: 'WeChatPatient',
                        flag: 'D',
                        appID: appID,
                        code: this.userName
                    }
                ]
            };
            $http.post(
                'urlS',
                this,
                {
                    code: '03100149',
                    data: data,
                    success: function (res) {
                        if (+res.errorCode === 0) {
                            let that = this;
                            let a = res.result ? res.result.effectTime * 1000 : 60 * 1000;
                            this.setData({
                                verificationState: a,
                                sendState: false
                            });
                            setTimeout(function () {
                                that.setData({
                                    getState: false
                                });
                                that.start();
                            }, 1000);
                        } else {
                            uni.showToast({
                                title: res.errorMessage,
                                icon: 'none'
                            });
                            this.setData({
                                sendState: true,
                                getState: false
                            });
                        }
                    }
                },
                {
                    error: 'Y'
                }
            );
        },

        login: function (e) {
            var that = this;
            if (this.passWord.length < 6) {
                uni.showToast({
                    title: '密码长度小于6位',
                    icon: 'none'
                });
                return;
            }
            if (this.userName == '' || this.passWord == '') {
                uni.showModal({
                    title: '提示',
                    content: '输入信息不完整，请检查!',
                    showCancel: false
                });
                return;
            } else {
                this.setData(
                    {
                        loginState: true,
                        verificationCheck: false
                    },
                    () => {
                        if (this.verificationFlag == 'Y') {
                            that.checkCerificationCode(() => {
                                that.runPasswordLogin();
                            });
                            return;
                        } else {
                            that.runPasswordLogin();
                        }
                    }
                );
            }
        },

        runPasswordLogin: function () {
            // #ifdef H5
            this.verificationPassword();
            // #endif

            // #ifndef H5
            uni.login({
                success: (res) => {
                    if (res.code) {
                        //发起网络请求
                        Cache.set('wechatCode', res.code);
                        this.verificationPassword();
                    } else {
                        console.log('登录失败！' + res.errMsg);
                        this.setData({
                            loginState: false
                        });
                    }
                },
                fail: () => {
                    uni.showToast({
                        title: '登录异常,请检查网络',
                        icon: 'none',
                        duration: 3000
                    });
                    this.setData({
                        loginState: false
                    });
                }
            });
            // #endif
        },

        //校验短信验证码
        checkCerificationCode: function (callback) {
            let { phoneNumber, verificationCode } = this;
            if (phoneNumber == '') {
                uni.showModal({
                    title: '提示',
                    content: '手机号码有误!',
                    showCancel: false
                });
                this.setData({
                    loginState: false
                });
                return false;
            }
            if (this.verificationCode == '') {
                uni.showModal({
                    title: '提示',
                    content: '请输入验证码!',
                    showCancel: false
                });
                this.setData({
                    loginState: false
                });
                return false;
            }
            let data = {
                params: [
                    {
                        mobile: this.phoneNumber,
                        verifyCode: this.verificationCode
                    }
                ]
            };
            $http.post(
                'urlS',
                this,
                {
                    code: '03100150',
                    data: data,
                    success: function (res) {
                        if (+res.errorCode === 0) {
                            this.setData(
                                {
                                    verificationCheck: true
                                },
                                () => {
                                    callback();
                                }
                            );
                        } else {
                            this.setData({
                                loginState: false
                            });
                            uni.showToast({
                                title: res.errorMessage,
                                icon: 'none'
                            });
                        }
                    }
                },
                {
                    error: 'Y'
                }
            );
            return true;
        },

        loginOut: function (e, _dataset) {
            /* ---处理dataset begin--- */
            this.handleDataset(e, _dataset);
            /* ---处理dataset end--- */
            this.setData({
                loginStaus: 'N',
                userName: '',
                passWord: '',
                locIDIndex: '',
                locInfo: ''
            });
            // 清理与当前医生账号相关的本地缓存
            Cache.set('userData', {});
            Cache.set('wechatCode', '');
            Cache.remove('TIMInfo');
            Cache.remove('patientData');
            // 重置消息角标
            uni.setTabBarBadge({ index: 1, text: '' });
            uni.hideTabBarRedDot({ index: 1 });
            uni.showToast({ title: '已退出登录', icon: 'none' });
        },

        newuser: function () {},

        bindPickerChange: function (e) {
            this.setData({
                locIDIndex: e.detail.value
            });
        },

        locTouchStart: function (e) {
            this.verificationPassword();
        },

        checkData: function () {
            let { userName, passWord } = this;
            if (userName == '' || passWord == '') {
                uni.showModal({
                    title: '提示',
                    content: '请输入工号和密码',
                    showCancel: false
                });
                return false;
            }
            return true;
        },

        passWordBlur: function (e) {
            //密码失去焦点时调用
            //this.verificationPassword();
        },

        verificationPassword: function (e) {
            let { userName, passWord } = this;
            // 登录接口
            let data = {
                params: [
                    {
                        userName: userName,
                        passWord: Aes.Encrypt(passWord),
                        phoneCheck: this.verificationCheck ? 'Y' : 'N',
                        mobileFlag: 'Y'
                    }
                ]
            };
            let that = this;
            $http.post(
                'urlDeault',
                this,
                {
                    code: '1001',
                    data: data,
                    success: function (res) {
                        let errorCode = res.errorCode;
                        that.setData({
                            loginState: false
                        });
                        if (errorCode == '0') {
                            let locInfo = res.result[0];
                            if (locInfo.userCode.indexOf('xyskf') > -1) {
                                locInfo.userID = 'KF001';
                            }
                            uni.setStorage({
                                key: 'userData',
                                data: locInfo,
                                success: function () {
                                    let TIMInfo = Cache.get('TIMInfo') || {};
                                    if (TIMInfo.loginStatus !== 'Y') {
                                        messageUtil.loginTim(() => {
                                            that.redirectAfterLogin();
                                        });
                                    }
                                }
                            });
                            that.loginsys(locInfo);
                        } else if (errorCode == '01040164') {
                            if (that.verificationFlag != 'Y') {
                                that.setData({
                                    verificationFlag: 'Y'
                                });
                            }
                            uni.showModal({
                                title: '提示',
                                content: '您输入密码次数过多，请输入手机号获取短信验证码!',
                                showCancel: false
                            });
                        } else {
                            this.setData({
                                loginState: false
                            });
                            uni.showToast({
                                title: res.errorMessage,
                                icon: 'none'
                            });
                        }
                    }
                },
                {
                    error: 'Y'
                }
            );
        },

        queryPermission: function () {
            // #ifdef H5
            return;
            // #endif
            if (typeof uni.getSetting !== 'function' || typeof uni.authorize !== 'function') {
                return;
            }
            uni.getSetting({
                success: (res) => {
                    if (!res.authSetting['scope.camera']) {
                        //获取摄像头权限
                        uni.authorize({
                            scope: 'scope.camera',
                            success() {},
                            fail() {}
                        });
                    }
                    if (!res.authSetting['scope.record']) {
                        //获取录音权限
                        uni.authorize({
                            scope: 'scope.record',
                            success() {},
                            fail() {}
                        });
                    }
                    if (!res.authSetting['scope.userInfo']) {
                        //获取用户信息
                        uni.authorize({
                            scope: 'scope.userInfo',
                            success() {},
                            fail() {}
                        });
                    }
                },
                fail(res) {
                    console.log(res);
                }
            });
        },

        loginsys: function (userData) {
            this.queryPermission();
            let that = this;
            let { userName, passWord, ip } = this;
            // 登录接口
            let data = {
                params: [
                    {
                        IP: ip,
                        deviceID: 'PHONE',
                        loginGroupID: userData.groupID,
                        loginHospID: userData.hospID,
                        loginLocID: userData.locID,
                        mac: '00-00-00-00-00-00',
                        userLogonType: '06',
                        userName: userName,
                        passWord: Aes.Encrypt(passWord),
                        phoneCheck: this.verificationCheck ? 'Y' : 'N'
                    }
                ]
            };
            $http.post('urlDeault', this, {
                code: '1011',
                data: data,
                success: function (res) {
                    let errorCode = res.errorCode;
                    if (errorCode == '0') {
                        let locInfo = res.result[0];
                        uni.setStorage({
                            key: 'userData',
                            data: locInfo,
                            success: function () {
                                that.setData(
                                    {
                                        locInfo: locInfo.locDesc + ' | ' + locInfo.groupDesc + ' | ' + locInfo.hospDesc,
                                        loginStaus: 'Y'
                                    },
                                    () => {
                                        setTimeout(() => {
                                            that.redirectAfterLogin();
                                        }, 1000);
                                    }
                                );
                            }
                        });
                        that.saveLoginInfo();
                    } else {
                        uni.showToast({
                            title: res.errorMessage,
                            icon: 'none'
                        });
                    }
                }
            });
        },

        /**
         * 保存登录信息
         */
        saveLoginInfo: function () {
            var accountInfo = typeof uni.getAccountInfoSync === 'function' ? uni.getAccountInfoSync() : { miniProgram: { appId: '' } };
            const wechatCode = Cache.get('wechatCode');
            if (!wechatCode) {
                return;
            }
            Util.getOpenID(wechatCode, (openid) => {
                var appID = accountInfo.miniProgram.appId;
                // 登录接口
                let data = {
                    params: [
                        {
                            openID: openid,
                            appID: appID,
                            status: 'Y'
                        }
                    ]
                };
                $http.post('urlDeault', this, {
                    code: '03100013',
                    data: data,
                    success: function (res) {}
                });
            });
        },

        changeBar: function () {
            var curPageArr = getCurrentPages(); //获取加载的页面
            var curPage = curPageArr[curPageArr.length - 1]; //获取当前页面的对象
            var pagePath = curPage.route; //当前页面url
            if (pagePath.indexOf('/') != 0) {
                pagePath = '/' + pagePath;
            }
            console.log(this.getTabBar());
            console.log(wx);
            var tabBar = this.globalData.tabBar;
            for (var i = 0; i < tabBar.list.length; i++) {
                tabBar.list[i].active = false;
                if (tabBar.list[i].pagePath == pagePath) {
                    tabBar.list[i].active = true; //根据页面地址设置当前页面状态
                }
            }

            curPage.setData({
                tabBar: tabBar
            });
        },

        getLocList: function (e) {
            let { userName, passWord } = this;
            // 登录接口
            let data = {
                params: [
                    {
                        userCode: userName,
                        currentLocFlag: 'Y',
                        language: 'CN'
                    }
                ]
            };
            let that = this;
            $http.post('urlDeault', this, {
                code: '01040043',
                data: data,
                success: function (res) {
                    let errorCode = res.errorCode;
                    if (errorCode == '0') {
                        this.setData({
                            locDisabled: false,
                            locList: res.result.logonLocAry
                        });
                    }
                }
            });
        },

        getPhoneNumber: function (e) {
            console.log(e.detail.errMsg);
            console.log(e);
            console.log(e.detail.encryptedData);
        },

        /**
         * 登录成功后根据 groupID 跳转
         * 有 groupID 跳工作台(workbench)，其余跳主页(home)
         */
        redirectAfterLogin: function () {
            let userData = Cache.get('userData') || {};
            if (String(userData.groupID) === '352') {
                // workbench 非 tabBar 页面，使用 reLaunch 跳转
                uni.reLaunch({
                    url: '/pages/staticPages/workbench/workbench'
                });
            } else {
                // home 为 tabBar 页面，使用 switchTab 跳转
                uni.switchTab({
                    url: '/pages/tabBar/home/home'
                });
            }
        },

        hidePage: function (e, _dataset) {
            /* ---处理dataset begin--- */
            this.handleDataset(e, _dataset);
            /* ---处理dataset end--- */
            this.setData({
                loginStaus: ''
            });
        },

        faceLogin: function () {
            uni.login({
                success(res) {
                    if (res.code) {
                        //发起网络请求
                        uni.setStorage({
                            key: 'wechatCode',
                            data: res.code,
                            success: function () {
                                uni.navigateTo({
                                    url: '../../../pages/tabBar/faceLogin/faceLogin'
                                });
                            }
                        });
                    } else {
                        uni.showToast({
                            title: '未获取到授权信息',
                            icon: 'none'
                        });
                    }
                }
            });
        },

        /**
         * 帮助和反馈
         */
        help: function () {
            uni.navigateTo({
                //目的页面地址
                url: '../../oneselfCenter/page/help/help',
                success: function (res) {},
                fail: function (res) {
                    console.log(res);
                }
            });
        },

        getPhoneNumber: function (e) {
            console.log(e);
            if (e.detail.errMsg == 'getPhoneNumber:ok') {
                Util.getPhoneNumber(e.detail.encryptedData, e.detail.iv);
            }
        },

        formSubmit() {
            console.log('占位：函数 formSubmit 未声明');
        }
    }
};
</script>
<style>
.topimg {
    width: 100%;
    min-height: 370rpx;
    position: relative;
    flex: 0 0 auto;
    padding: 16rpx 32rpx 0;
    overflow: hidden;
}

.topimg .version {
    position: absolute;
    right: 30rpx;
    top: 18rpx;
    display: flex;
    align-items: center;
    gap: 18rpx;
    z-index: 2;
}

.version-text {
    color: rgba(255, 255, 255, 0.86);
    font-size: 24rpx;
}

.topimg .logo {
    width: 100%;
    height: 100%;
    border-radius: 30rpx;
}

.help {
    width: 44rpx;
    height: 44rpx;
    margin: 0;
    padding: 0;
}

.brand {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 133rpx;
    padding-bottom: 60rpx;
    color: #fff;
}

.logo-wrap {
    position: relative;
    width: 132rpx;
    height: 132rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 34rpx;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18rpx 48rpx rgba(24, 93, 175, 0.24);
    overflow: visible;
    margin-top: 30rpx;
}

.logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.logo-text {
    font-size: 62rpx;
    font-weight: 700;
    color: #287ee8;
    padding: 10rpx;
}

.logo-add-icon {
    position: absolute;
    bottom: -8rpx;
    right: -16rpx;
    width: 36rpx;
    height: 36rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #287ee8;
    color: #fff;
    font-size: 28rpx;
    font-weight: 700;
    border-radius: 50%;
}

.brand-title {
    margin-top: 28rpx;
    font-size: 38rpx;
    font-weight: 700;
    color: #fff;
}

.brand-subtitle {
    margin-top: 10rpx;
    font-size: 22rpx;
    color: rgba(255, 255, 255, 0.78);
    letter-spacing: 0;
}

.login-form {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: auto;
    padding: 0 44rpx;
    position: relative;
    z-index: 2;
    box-sizing: border-box;
}

.logincon {
    width: 100%;
    max-width: 640rpx;
    padding: 46rpx 34rpx 44rpx;
    box-sizing: border-box;
    position: relative;
    display: flex;
    justify-content: center;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(226, 235, 248, 0.9);
    border-radius: 28rpx;
    box-shadow: 0 22rpx 58rpx rgba(25, 82, 150, 0.14);
}

.login-panel {
    width: 100%;
    max-width: 536rpx;
    margin: 0 auto;
    box-sizing: border-box;
}

.useript {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    min-height: 90rpx;
    margin-bottom: 24rpx;
    padding: 0 26rpx;
    box-sizing: border-box;
    border: 1px solid #e7edf6;
    border-radius: 16rpx;
    background: #f7faff;
    line-height: 1.4;
}

.useript image {
    width: 35rpx;
    height: 35rpx;
    margin: 0 20rpx;
}

.useript input {
    flex: 1;
    min-width: 0;
    height: 88rpx;
    padding: 0;
    box-sizing: border-box;
    font-size: 30rpx;
    font-weight: 400;
    color: #17233d;
}

.field-label {
    flex: 0 0 104rpx;
    color: #23364f;
    font-size: 28rpx;
    font-weight: 600;
    text-align: left;
    line-height: 1;
}

.field-label-long {
    flex-basis: 104rpx;
}

.code {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    min-height: 48rpx;
    margin-top: -10rpx;
    margin-bottom: 20rpx;
    padding-right: 10rpx;
    color: rgb(0, 121, 254);
}

.node {
    display: none;
}

.node1 {
    float: left;
    padding-right: 3px;
}

.picker {
    height: 70rpx;
    border-bottom: 1px solid #bfbfbf;
}

.logbtn {
    display: block;
    width: 100% !important;
    height: 88rpx !important;
    text-align: center;
    line-height: 88rpx !important;
    letter-spacing: 0;
    font-size: 31rpx;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #1d8fff 0%, #1677e8 100%);
    margin: 34rpx 0 22rpx !important;
    border-radius: 999rpx;
    box-shadow: 0 14rpx 28rpx rgba(24, 125, 239, 0.28);
}

.logbtn::after {
    border: none;
}

.login-dot {
    display: inline-block;
    width: 26rpx;
    height: 26rpx;
    margin-right: 12rpx;
    vertical-align: -4rpx;
    border: 3rpx solid rgba(255, 255, 255, 0.48);
    border-top-color: #fff;
    border-radius: 50%;
    animation: loginSpin 0.8s linear infinite;
}

@keyframes loginSpin {
    to {
        transform: rotate(360deg);
    }
}

.fhlogbtn {
    display: block;
    width: 100%;
    height: 80rpx;
    border-radius: 5px;
    text-align: center;
    line-height: 80rpx;
    letter-spacing: 4px;
    font-size: 32rpx;
    color: #fff;
    background: #ccc;
    margin: 30rpx 0;
}

.logfoot {
    font-size: 30rpx;
}

.logfoot text {
    width: 50%;
    display: inline-block;
    font-size: 30rpx;
    color: #999;
}

.logfoot text:nth-child(2) {
    text-align: right;
}

.personalcenter {
    width: 100%;
    background: url('https://chis.e24health.com/images/icon/doctor/layer.png') no-repeat;
    background-size: 100% 113rpx;
}

/* --xyh */

.LoginBody {
    position: relative;
    background:
        linear-gradient(180deg, #1f84ff 0%, #3c9bff 34%, #f4f8ff 34%, #f7faff 100%),
        url('https://hlwyy.scsmysgkyy.cn/images/icon/doctor/myhead.png') top center / 100% 360rpx no-repeat;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-sizing: border-box;
    overflow-y: auto;
    padding-bottom: calc(24rpx + env(safe-area-inset-bottom));
}

</style>
