init.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. onFail : function(err) {
  52. console.log('onFail')
  53. }
  54. })
  55. },
  56. //重新登录
  57. openLogin() {
  58. var num = 10;
  59. var that = this;
  60. this.disabled = true;
  61. this.showBtnCunt = this.showBtnCunt + 1;
  62. var intterval = setInterval(function() {
  63. num--;
  64. if (num == 0) {
  65. that.text = '重试';
  66. that.disabled = false;
  67. if (that.showBtnCunt >= 2) {
  68. that.$alert('数据加载过慢,请联系客服', '温馨提示', {
  69. confirmButtonText: '确定',
  70. callback: action => {}
  71. });
  72. }
  73. clearInterval(intterval);
  74. return;
  75. }
  76. that.text = num;
  77. }, 1000);
  78. this.login(this.corpId);
  79. },
  80. login(corpId) {
  81. var that = this;
  82. this.loading = true;
  83. localStorage.setItem('corpId',corpId)
  84. this.$dd.runtime.permission.requestAuthCode({
  85. corpId: corpId, // 企业id
  86. onSuccess: function(info) {
  87. that.$axios('post', '/api/ding/login', { authCode: info.code, corpId: corpId }).then(res => {
  88. var is = false;
  89. if (res.data.code == 1) {
  90. var { token, user } = res.data.data;
  91. if (user.is_official==1) {
  92. that.$setUserData(user);
  93. that.$router.replace({ path: '/index' });
  94. }else{
  95. that.$router.replace({ path: '/noAccess' });
  96. }
  97. }else if(res.data.code==2001){
  98. that.dialogFormVisible=true;
  99. }
  100. }).finally(() => {
  101. that.loading = false;
  102. });
  103. }
  104. });
  105. },
  106. GetRequest(urlStr) {
  107. if (typeof urlStr == 'undefined') {
  108. var url = decodeURI(location.search); //获取url中"?"符后的字符串
  109. } else {
  110. var url = '?' + urlStr.split('?')[1];
  111. }
  112. var theRequest = new Object();
  113. var strs;
  114. if (url.indexOf('?') != -1) {
  115. var str = url.substr(1);
  116. strs = str.split('&');
  117. for (var i = 0; i < strs.length; i++) {
  118. theRequest[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1]);
  119. }
  120. }
  121. return theRequest;
  122. }
  123. }
  124. };
  125. </script>
  126. <style scoped="scoped">
  127. .refresh {
  128. margin-top: 100px;
  129. width: 100px;
  130. }
  131. .appImg {
  132. width: 200px;
  133. height: 200px;
  134. }
  135. .noData {
  136. text-align: center;
  137. position: fixed;
  138. left: 0;
  139. top: 0;
  140. right: 0;
  141. bottom: 0;
  142. }
  143. .data-all {
  144. margin-bottom: 10%;
  145. color: #595959;
  146. }
  147. </style>