123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <template>
- <div class="noData flex-box-v flex-center-center">
- <div class="data-all">
- <img src="./assets/image/init.gif" class="appImg" />
- <div>管理执行难,就用功道云</div>
- <el-button class="refresh" type="primary" :loading="disabled" :disabled="disabled" v-if="isRefresh" @click="openLogin()">{{ text }}</el-button>
- </div>
- </div>
- </template>
- <script>
- export default {
- data() {
- return {
- text: '重试',
- corpId: '',
- isRefresh: false,
- disabled: false,
- showBtnCunt: 0
- };
- },
- watch: {},
- mounted() {
- var url = window.location.href;
- var str = this.GetRequest(url).corpId || '123';
- var corpId = str.split('#')[0];
- this.corpId = corpId;
- if (corpId) {
- this.login(corpId);
- }
- },
- methods: {
- //重新登录
- openLogin() {
- var num = 10;
- var that = this;
- this.disabled = true;
- this.showBtnCunt = this.showBtnCunt + 1;
- var intterval = setInterval(function() {
- num--;
- if (num == 0) {
- that.text = '重试';
- that.disabled = false;
- if (that.showBtnCunt >= 2) {
- that.$alert('数据加载过慢,请联系客服', '温馨提示', {
- confirmButtonText: '确定',
- callback: action => {}
- });
- }
- clearInterval(intterval);
- return;
- }
- that.text = num;
- }, 1000);
- this.login(this.corpId);
- },
- login(corpId) {
- var that = this;
- this.loading = true;
- this.$dd.runtime.permission.requestAuthCode({
- corpId: corpId, // 企业id
- onSuccess: function(info) {
- that.$axios('post', '/api/ding/login', { authCode: info.code, corpId: corpId })
- .then(res => {
- var is = false;
- if (res.data.code == 1) {
- var { token, user } = res.data.data;
- user.employee_detail.role_list.forEach(item => {
- // if (user.is_official == 1) {
- if (item.name == 'admin' || item.name == 'creator' || item.name == 'point_manager') {
- is = true;
- }
- // }
- });
- if (is) {
- that.$setUserData(user);
- that.$router.replace({ path: '/index' });
- } else {
- that.$router.replace({ path: '/noAccess' });
- }
- }
- })
- .catch(() => {
- // if(!that.showBtn){
- that.isRefresh = true;
- // }
- })
- .finally(() => {
- that.loading = false;
- });
- }
- });
- },
- GetRequest(urlStr) {
- if (typeof urlStr == 'undefined') {
- var url = decodeURI(location.search); //获取url中"?"符后的字符串
- } else {
- var url = '?' + urlStr.split('?')[1];
- }
- var theRequest = new Object();
- var strs;
- if (url.indexOf('?') != -1) {
- var str = url.substr(1);
- strs = str.split('&');
- for (var i = 0; i < strs.length; i++) {
- theRequest[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1]);
- }
- }
- return theRequest;
- }
- }
- };
- </script>
- <style scoped="scoped">
- .refresh {
- margin-top: 100px;
- width: 100px;
- }
- .appImg {
- width: 200px;
- height: 200px;
- }
- .noData {
- text-align: center;
- position: fixed;
- left: 0;
- top: 0;
- right: 0;
- bottom: 0;
- }
- .data-all {
- margin-bottom: 10%;
- color: #595959;
- }
- </style>
|