init.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <div class="noData flex-box-v flex-center-center">
  3. <div class="data-all">
  4. <img src="./assets/image/init.gif" class="appImg" />
  5. <div>管理执行难,就用功道云</div>
  6. <el-button class="refresh" type="primary" :loading="disabled" :disabled="disabled" v-if="isRefresh" @click="openLogin()">{{ text }}</el-button>
  7. </div>
  8. </div>
  9. </template>
  10. <script>
  11. export default {
  12. data() {
  13. return {
  14. text: '重试',
  15. corpId: '',
  16. isRefresh: false,
  17. disabled: false,
  18. showBtnCunt: 0
  19. };
  20. },
  21. watch: {},
  22. mounted() {
  23. var url = window.location.href;
  24. var str = this.GetRequest(url).corpId || '123';
  25. var corpId = str.split('#')[0];
  26. this.corpId = corpId;
  27. if (corpId) {
  28. this.login(corpId);
  29. }
  30. },
  31. methods: {
  32. //重新登录
  33. openLogin() {
  34. var num = 10;
  35. var that = this;
  36. this.disabled = true;
  37. this.showBtnCunt = this.showBtnCunt + 1;
  38. var intterval = setInterval(function() {
  39. num--;
  40. if (num == 0) {
  41. that.text = '重试';
  42. that.disabled = false;
  43. if (that.showBtnCunt >= 2) {
  44. that.$alert('数据加载过慢,请联系客服', '温馨提示', {
  45. confirmButtonText: '确定',
  46. callback: action => {}
  47. });
  48. }
  49. clearInterval(intterval);
  50. return;
  51. }
  52. that.text = num;
  53. }, 1000);
  54. this.login(this.corpId);
  55. },
  56. login(corpId) {
  57. var that = this;
  58. this.loading = true;
  59. this.$dd.runtime.permission.requestAuthCode({
  60. corpId: corpId, // 企业id
  61. onSuccess: function(info) {
  62. that.$axios('post', '/api/ding/login', { authCode: info.code, corpId: corpId })
  63. .then(res => {
  64. var is = false;
  65. if (res.data.code == 1) {
  66. var { token, user } = res.data.data;
  67. user.employee_detail.role_list.forEach(item => {
  68. // if (user.is_official == 1) {
  69. if (item.name == 'admin' || item.name == 'creator' || item.name == 'point_manager') {
  70. is = true;
  71. }
  72. // }
  73. });
  74. if (is) {
  75. that.$setUserData(user);
  76. that.$router.replace({ path: '/index' });
  77. } else {
  78. that.$router.replace({ path: '/noAccess' });
  79. }
  80. }
  81. })
  82. .catch(() => {
  83. // if(!that.showBtn){
  84. that.isRefresh = true;
  85. // }
  86. })
  87. .finally(() => {
  88. that.loading = false;
  89. });
  90. }
  91. });
  92. },
  93. GetRequest(urlStr) {
  94. if (typeof urlStr == 'undefined') {
  95. var url = decodeURI(location.search); //获取url中"?"符后的字符串
  96. } else {
  97. var url = '?' + urlStr.split('?')[1];
  98. }
  99. var theRequest = new Object();
  100. var strs;
  101. if (url.indexOf('?') != -1) {
  102. var str = url.substr(1);
  103. strs = str.split('&');
  104. for (var i = 0; i < strs.length; i++) {
  105. theRequest[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1]);
  106. }
  107. }
  108. return theRequest;
  109. }
  110. }
  111. };
  112. </script>
  113. <style scoped="scoped">
  114. .refresh {
  115. margin-top: 100px;
  116. width: 100px;
  117. }
  118. .appImg {
  119. width: 200px;
  120. height: 200px;
  121. }
  122. .noData {
  123. text-align: center;
  124. position: fixed;
  125. left: 0;
  126. top: 0;
  127. right: 0;
  128. bottom: 0;
  129. }
  130. .data-all {
  131. margin-bottom: 10%;
  132. color: #595959;
  133. }
  134. </style>