init.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. mounted() {
  35. var url = window.location.href;
  36. var str = this.GetRequest(url).corpId || '123';
  37. var corpId = str.split('#')[0];
  38. this.corpId = corpId;
  39. if (corpId) {
  40. this.login(corpId);
  41. }
  42. },
  43. methods: {
  44. bundleOfServices(){
  45. this.$dd.biz.util.openSlidePanel({
  46. url:"https://page.dingtalk.com/wow/dingtalk/act/serviceconversation?wh_biz=tm&showmenu=false&goodsCode=DT_GOODS_881607043109331&corpId="+localStorage.getItem('corpId')+"&token=5784a3e6b5e025ee891517ea814180f4",
  47. title: '客服群',
  48. onSuccess : function(result) {
  49. },
  50. onFail : function(err) {
  51. console.log('onFail')
  52. }
  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. var is = false;
  88. if (res.data.code == 1) {
  89. var { token, user } = res.data.data;
  90. if (user.is_official==1) {
  91. that.$setUserData(user);
  92. that.$router.replace({ path: '/index' });
  93. }else{
  94. that.$router.replace({ path: '/noAccess' });
  95. }
  96. }else if(res.data.code==2001){
  97. that.dialogFormVisible=true;
  98. }
  99. }).finally(() => {
  100. that.loading = false;
  101. });
  102. }
  103. });
  104. },
  105. GetRequest(urlStr) {
  106. if (typeof urlStr == 'undefined') {
  107. var url = decodeURI(location.search); //获取url中"?"符后的字符串
  108. } else {
  109. var url = '?' + urlStr.split('?')[1];
  110. }
  111. var theRequest = new Object();
  112. var strs;
  113. if (url.indexOf('?') != -1) {
  114. var str = url.substr(1);
  115. strs = str.split('&');
  116. for (var i = 0; i < strs.length; i++) {
  117. theRequest[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1]);
  118. }
  119. }
  120. return theRequest;
  121. }
  122. }
  123. };
  124. </script>
  125. <style scoped="scoped">
  126. .refresh {
  127. margin-top: 100px;
  128. width: 100px;
  129. }
  130. .appImg {
  131. width: 200px;
  132. height: 200px;
  133. }
  134. .noData {
  135. text-align: center;
  136. position: fixed;
  137. left: 0;
  138. top: 0;
  139. right: 0;
  140. bottom: 0;
  141. }
  142. .data-all {
  143. margin-bottom: 10%;
  144. color: #595959;
  145. }
  146. </style>