/*
* @Description: file content
* @Version: 2.0
* @Author: ljl
* @Date: 2022-06-22 17:25:55
 * @LastEditors: ljl
 * @LastEditTime: 2022-07-15 21:35:09
 * @FilePath: \zyypt-ssb-vue_app\src\mixins\eye.js
*/
import { getCookies, setCookies } from "@/utils/auth";
//控制名称显隐
function eye() {
    return {
        data() {
            return {
                eyeLock: true,
                info: {
                    idcard: "",
                    name: ''
                },

            }
        },
        methods: {
            eye(handleStyle) {
                if (handleStyle == 'refresh') {
                    let eyeLock = getCookies('eyeLock')
                    if (eyeLock) {
                        this.eyeLock = JSON.parse(eyeLock)
                    } else {
                        this.eyeLock = true
                    }
                } else {
                    setCookies('eyeLock', this.eyeLock)
                }
                if (this.eyeLock) {
                    this.info.name = new Array(this.info.name.length).join('*') + this.info.name.substr(-1)
                    this.info.idcard = new Array(this.info.idcard.length-3).join('*') + this.info.idcard.substr(-4)
                    this.eyeLock = !this.eyeLock;
                } else {
                    if (getCookies('relativeInfo')) {
                        this.info = JSON.parse(getCookies('relativeInfo'))
                    } else {
                        this.info = JSON.parse(getCookies('myInfo'))
                    }
                    this.eyeLock = !this.eyeLock;
                }
            },
        },
    }
}

export { eye }