loading添加

master
huan.xu 5 years ago
parent c8589b0917
commit b0a08c6f7f
  1. 124
      src/pages/yyyfLogin.vue

@ -1,11 +1,127 @@
<template>
<div style="background-color: white">hello-yyyfLogin</div>
</template>
<script>
export default {
import {getCurrentLanguage} from '@/common/i18n';
import {getExchangeRateCookie, setExchangeRateCookie} from '@/utils/auth';
import {logOut} from '@/api/user';
import Cookie from '@/common/cookie';
import {FILE_URL} from '@/api/app';
import {signIn} from '@/api/yyyf';
import {Loading} from 'element-ui';
export default {
name: 'yyyfLogin',
};
props: {},
data() {
return {
loading: null
};
},
computed: {},
created() {
this.startLoading();
let params = this.parseUrl();
//
if (!$.isEmptyObject(params) &&params.userId != undefined && params.reqType != undefined) {
this.loginFromYyyf(params);
}else{
let self=this;
this.$alert('参数错误', '提示', {
type:'error',
showClose:false,
confirmButtonText: '确定',
confirmButtonClass: 'btn-self-style',
callback: action => {
self.closeWindow()
}
});
}
},
methods: {
startLoading: function () { //使Element loading-start
this.loading = Loading.service({
lock: true,
text: '初始化登录1ing...',
background: 'rgba(204, 0, 0, 0.7)'
})
},
endLoading: function () { //使Element loading-close
loading.close()
},
parseUrl: function () {
let params = {}; //
let url = decodeURIComponent(location.href);
let paramsIndex = url.indexOf('?');
if (paramsIndex != -1) {
paramsIndex = paramsIndex + 1;
let paramsStr = url.substring(paramsIndex);
let paramsAttr = paramsStr.split('&');
for (let x in paramsAttr) {
let y = paramsAttr[x].split('=');
if (y[0] == undefined || y[0] == '') {
continue;
}
if (y[1] != undefined) {
let value = '';
let len = y.length;
for (let j = 1; j < len; j++) {
value +=
y[j] == '' &&
paramsAttr[x].charAt(value.length + y[0].length + 1) != ''
? '='
: y[j];
}
params[y[0]] = value;
}
}
}
return params;
},
loginFromYyyf: function (params) {
signIn(params).then(res => {
// console.log(res);
if (res.data.code === 200) {
debugger;
this.loading = false;
//tokencookie
// Cookie.set('token', res.data.data.token);
localStorage.setItem('yyyfToken', res.data.data.yyyfUserToken);
//cookie
// Cookie.set('userData', res.data.data);
//localStorage.setItem('userData', JSON.stringify(res.data.data));
this.endLoading()
location.href = '/';
} else {
//this.loading = false;
this.$message.warning(res.data.msg);
}
});
},
closeWindow: function () {
if (navigator.userAgent.indexOf("Firefox") != -1 || navigator.userAgent.indexOf("Chrome") != -1) {
window.location.href = "about:blank";
window.close();
} else {
window.opener = null;
window.open("", "_self");
window.close();
}
},
},
};
</script>
<style>
<style scoped></style>
.btn-self-style{
background: #f56c6c !important;
color:#fff !important;
}
</style>

Loading…
Cancel
Save