<template>
    <div :class="curClassName" :style="curStyle">
        <div class="app-login-third__title">{{ $t("components.login.other") }}</div>
        <div class="app-login-third__content">
            <div class="app-login-third__btn" @click="handleThirdLogin('DINGDING')">
                <img class="third-svg-container" src="@/assets/img/dingding.svg" />
            </div>
            <div class="app-login-third__btn" @click="handleThirdLogin('WXWORK')">
                <img class="third-svg-container" src="@/assets/img/qiyeweixin.svg" />
            </div>
        </div>
    </div>
</template>

<script lang="ts">
import { Component, Prop, Vue } from "vue-property-decorator";
@Component({})
export default class AppThirdLogin extends Vue {

    /**
     * 模型
     *
     * @type {any}
     * @memberof AppThirdLogin
     */
    @Prop() public layoutModelDetails: any;

    /**
     * 值
     *
     * @type {string}
     * @memberof AppThirdLogin
     */
    @Prop() public value!: string;

    /**
     * 名称
     *
     * @type {string}
     * @memberof AppThirdLogin
     */
    @Prop() public name!: string;

    /**
     * 下标
     *
     * @type {number}
     * @memberof AppThirdLogin
     */
    @Prop() public index?: number;

    /**
     * 项名称
     *
     * @type {*}
     * @memberof AppThirdLogin
     */
    get itemName() {
        return (this.index || this.index === 0) ? `${this.name}_${this.index}` : this.name;
    }

    /**
     * 当前容器样式
     * 
     * @memberof AppThirdLogin
     */
    get curStyle() {
        const layoutModel = this.layoutModelDetails[this.itemName];
        if (layoutModel) {
            return layoutModel.getElementStyle();
        }
    }

    /**
     * 类名
     *
     * @memberof AppThirdLogin
     */
    get curClassName() {
        const layoutModel = this.layoutModelDetails[this.itemName];
        if (layoutModel) {
            return `app-login-third ${this.itemName} ${layoutModel.sysCss}`;
        }
    }

    /**
     * 处理第三方登录
     *
     * @param type 登录类型
     * @memberof AppThirdLogin
     */
    handleThirdLogin(type: string) {
        switch (type) {
            case "DINGDING":
                this.dingTalkHandleClick();
                break;
            case "WXWORK":
                this.wxWorkHandleClick();
                break;
            default:
                console.warn(`暂不支持${type}登录`);
                break;
        }
    }

    /**
     * 钉钉登录
     *
     * @memberof AppThirdLogin
     */
    async dingTalkHandleClick() {
        this.$message({ message: '暂未支持钉钉登录',type: 'warning'});
    }

    /**
     * 微信登录
     *
     * @memberof AppThirdLogin
     */
    async wxWorkHandleClick() {
        this.$message({ message: '暂未支持微信登录',type: 'warning'});
    }
}
</script>

<style lang="less">
@import "./app-login-third.less";
</style>
