init.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <div>
  3. <div class="noData flex-box-v flex-center-center">
  4. <div class="data-all">
  5. <img src="./assets/image/init.gif" class="appImg" />
  6. <div>管理执行难,就用功道云</div>
  7. <el-button class="refresh" type="primary" :loading="disabled" :disabled="disabled" v-if="isRefresh" @click="openLogin()">{{ text }}</el-button>
  8. </div>
  9. </div>
  10. <el-dialog title="通知" :visible.sync="dialogFormVisible" width="480px" :show-close="false" :close-on-click-modal="false">
  11. <div>
  12. <div style="font-size: 18px;">尊敬的用户:</div>
  13. <div style="margin: 10px 0;">您当前的套餐已到期,如需继续使用,请<span @click="bundleOfServices" style="color:#409EFF;cursor:pointer;">联系客服</span>或扫描下方二维码进行续费。</div>
  14. </div>
  15. <div style="border-radius: 15px;border: 1px solid #f1f1f1;padding: 10px; width: 276px;box-sizing: border-box;margin: 0 auto;">
  16. <img src="./assets/image/code.png"/>
  17. </div>
  18. <div class="fontColorF" style="text-align: center;margin-top: 15px;font-size: 18px;">手机钉钉扫码,付费升级</div>
  19. </el-dialog>
  20. </div>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. text: '重试',
  27. corpId: '',
  28. isRefresh: false,
  29. disabled: false,
  30. showBtnCunt: 0,
  31. dialogFormVisible:false
  32. };
  33. },
  34. watch: {},
  35. mounted() {
  36. var url = window.location.href;
  37. var str = this.GetRequest(url).corpId || '123';
  38. var corpId = str.split('#')[0];
  39. this.corpId = corpId;
  40. if (corpId) {
  41. this.login(corpId);
  42. }
  43. },
  44. methods: {
  45. bundleOfServices(){
  46. this.$dd.biz.util.openSlidePanel({
  47. url:"https://page.dingtalk.com/wow/dingtalk/act/serviceconversation?wh_biz=tm&showmenu=false&goodsCode=DT_GOODS_881607043109331&corpId="+localStorage.getItem('corpId')+"&token=5784a3e6b5e025ee891517ea814180f4",
  48. title: '客服群',
  49. onSuccess : function(result) {
  50. /**/
  51. },
  52. onFail : function(err) {}
  53. })
  54. },
  55. //重新登录
  56. openLogin() {
  57. var num = 10;
  58. var that = this;
  59. this.disabled = true;
  60. this.showBtnCunt = this.showBtnCunt + 1;
  61. var intterval = setInterval(function() {
  62. num--;
  63. if (num == 0) {
  64. that.text = '重试';
  65. that.disabled = false;
  66. if (that.showBtnCunt >= 2) {
  67. that.$alert('数据加载过慢,请联系客服', '温馨提示', {
  68. confirmButtonText: '确定',
  69. callback: action => {}
  70. });
  71. }
  72. clearInterval(intterval);
  73. return;
  74. }
  75. that.text = num;
  76. }, 1000);
  77. this.login(this.corpId);
  78. },
  79. login(corpId) {
  80. var that = this;
  81. this.loading = true;
  82. localStorage.setItem('corpId',corpId)
  83. this.$dd.runtime.permission.requestAuthCode({
  84. corpId: corpId, // 企业id
  85. onSuccess: function(info) {
  86. that.$axios('post', '/api/ding/login', { authCode: info.code, corpId: corpId }).then(res => {
  87. // that.$axios('post', '/api/ding/login', { authCode: 'fd5dc75e50c435b58ce6343bf1cb765b', corpId: 'ding011f57ab048cf202ffe93478753d9884' }).then(res => {
  88. var is = false;
  89. if (res.data.code == 1) {
  90. var { token, user } = res.data.data;
  91. // user.employee_detail.role_list.forEach(item => {
  92. // if (user.is_official == 1) {
  93. // if (item.name == 'admin' || item.name == 'creator' || item.name == 'point_manager') {is = true;}
  94. // }
  95. // });
  96. if (user.is_official==1) {
  97. that.$setUserData(user);
  98. that.$router.replace({ path: '/index' });
  99. }else{
  100. that.$router.replace({ path: '/noAccess' });
  101. }
  102. }else if(res.data.code==2001){
  103. that.dialogFormVisible=true;
  104. }
  105. }).finally(() => {
  106. that.loading = false;
  107. });
  108. }
  109. });
  110. },
  111. GetRequest(urlStr) {
  112. if (typeof urlStr == 'undefined') {
  113. var url = decodeURI(location.search); //获取url中"?"符后的字符串
  114. } else {
  115. var url = '?' + urlStr.split('?')[1];
  116. }
  117. var theRequest = new Object();
  118. var strs;
  119. if (url.indexOf('?') != -1) {
  120. var str = url.substr(1);
  121. strs = str.split('&');
  122. for (var i = 0; i < strs.length; i++) {
  123. theRequest[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1]);
  124. }
  125. }
  126. return theRequest;
  127. }
  128. }
  129. };
  130. </script>
  131. <style scoped="scoped">
  132. .refresh {
  133. margin-top: 100px;
  134. width: 100px;
  135. }
  136. .appImg {
  137. width: 200px;
  138. height: 200px;
  139. }
  140. .noData {
  141. text-align: center;
  142. position: fixed;
  143. left: 0;
  144. top: 0;
  145. right: 0;
  146. bottom: 0;
  147. }
  148. .data-all {
  149. margin-bottom: 10%;
  150. color: #595959;
  151. }
  152. </style>