提交 101cf0c0 编写于 作者: RedPig97's avatar RedPig97

update: 登录按钮更新

上级 d996f3fa
.app-user-button { .app-login-button {
width: 100%;
.ivu-btn { .ivu-btn {
width: 100%; width: 100%;
height: 100%;
} }
} }
\ No newline at end of file
<template> <template>
<div class="app-user-button"> <div :class="[model.sysCss, 'app-login-button']" :style="containerStyle">
<i-button @click="handleSubmit" :type="type">{{ caption }} </i-button> <i-button @click="handleClick" :type="curStyle">
<span v-show="model.isShowCaption">{{ model.caption }}</span>
</i-button>
</div> </div>
</template> </template>
<script lang="ts"> <script lang="ts">
import { Vue, Component, Watch, Prop, Model } from "vue-property-decorator"; import { PanelButtonModel } from "@/model/panel-detail";
import { Vue, Component, Prop } from "vue-property-decorator";
@Component({}) @Component({})
export default class AppUserId extends Vue { export default class AppLoginButton extends Vue {
@Prop() public predefinedType!: string; /**
* 模型
*
* @type {PanelButtonModel}
* @memberof AppLoginButton
*/
@Prop() public model!: PanelButtonModel;
@Prop() public type?: string; /**
* 类型
*
* @type {string}
* @memberof AppLoginButton
*/
@Prop() public defaultStyle?: string;
@Prop() public caption!: string; /**
* 当前按钮类型
*
* @type {string}
* @memberof AppLoginButton
*/
get curStyle(): string {
if (this.model.buttonStyle != "DEFAULT" && this.defaultStyle) {
return this.defaultStyle;
} else {
return this.model.buttonStyle.toLowerCase();
}
}
/**
* 按钮样式
*
* @type {string}
* @memberof AppLoginButton
*/
public containerStyle: any = null;
/**
* 处理点击
*
* @type {string}
* @memberof AppLoginButton
*/
public handleClick() {
switch (this.model.predefinedType) {
case "APP_LOGOUT":
this.logout();
break;
case "APP_REGISTER":
this.register();
break;
default:
this.$emit("itemClick", this.model.predefinedType);
}
}
public mounted() {
if (this.model) {
this.containerStyle = this.model.getElementStyle();
}
}
/**
* 登出
*
* @type {string}
* @memberof AppLoginButton
*/
public logout() {
this.$http
.get("/v7/logout")
.then((response: any) => {
if (response && response.status === 200) {
localStorage.removeItem("user");
localStorage.removeItem("token");
let leftTime = new Date();
leftTime.setTime(leftTime.getSeconds() - 1);
document.cookie = "ibzuaa-token=;expires=" + leftTime.toUTCString();
this.$router.push({ name: "login" });
}
})
.catch((error: any) => {
console.error(error);
});
}
public handleSubmit() { /**
this.$emit('itemClick', this.predefinedType); * 注册
*
* @type {string}
* @memberof AppLoginButton
*/
public register() {
// todo
} }
} }
</script> </script>
<style lang="less"> <style lang="less">
@import './app-login-button.less'; @import "./app-login-button.less";
</style> </style>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册