init.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <div>
  3. <div class="noData flex-box-v flex-center-center">
  4. <div class="data-all" v-if="isPCa">
  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 class="data-all" v-else>
  10. <img src="./assets/image/init.gif" class="appImg" />
  11. <div>此页面暂不支持在手机端访问,<br/>请前往电脑端“工作通知”查看</div>
  12. </div>
  13. </div>
  14. <el-dialog title="通知" :visible.sync="dialogFormVisible" width="480px" :show-close="false" :close-on-click-modal="false">
  15. <div>
  16. <div style="font-size: 18px;">尊敬的用户:</div>
  17. <div style="margin: 10px 0;">您当前的套餐已到期,如需继续使用,请<span @click="bundleOfServices" style="color:#409eff;cursor:pointer;">联系客服</span>或扫描下方二维码进行续费。</div>
  18. </div>
  19. <div style="border-radius: 15px;border: 1px solid #f1f1f1;padding: 10px; width: 276px;box-sizing: border-box;margin: 0 auto;">
  20. <img src="./assets/image/code.png"/>
  21. </div>
  22. <div class="fontColorC" style="text-align: center;margin-top: 15px;font-size: 18px;">手机钉钉扫码,付费升级</div>
  23. </el-dialog>
  24. </div>
  25. </template>
  26. <script>
  27. export default {
  28. data() {
  29. return {
  30. text: '重试',
  31. corpId: '',
  32. isRefresh: false,
  33. disabled: false,
  34. showBtnCunt: 0,
  35. dialogFormVisible:false,
  36. isPCa:true,
  37. };
  38. },
  39. created() {
  40. this.isPCa=this.IsPC();
  41. this.getTypes();
  42. },
  43. mounted() {
  44. var url = window.location.href;
  45. var str = this.GetRequest(url).corpId || '123';
  46. var corpId = str.split('#')[0];
  47. this.corpId = corpId;
  48. if (corpId&&this.isPCa) {
  49. this.login(corpId);
  50. }
  51. },
  52. methods: {
  53. IsPC() {
  54. var userAgentInfo = navigator.userAgent;
  55. var Agents = ["Android", "iPhone","SymbianOS", "Windows Phone","iPad", "iPod"];
  56. var flag = true;
  57. for (var v = 0; v < Agents.length; v++) {
  58. if (userAgentInfo.indexOf(Agents[v]) > 0) {
  59. flag = false;
  60. break;
  61. }
  62. }
  63. return flag;
  64. },
  65. getTypes() {
  66. var that = this;
  67. this.$axios('get', '/api/integral/types').then(res => {
  68. that.$setTyps(res.data.data.list);
  69. });
  70. },
  71. bundleOfServices(){
  72. this.$dd.biz.util.openSlidePanel({
  73. url:"https://page.dingtalk.com/wow/dingtalk/act/serviceconversation?wh_biz=tm&showmenu=false&goodsCode=DT_GOODS_881607043109331&corpId="+this.$getCache('corpId')+"&token=5784a3e6b5e025ee891517ea814180f4",
  74. title: '客服群',
  75. onSuccess : function(result) {},
  76. onFail : function(err) {
  77. console.log('onFail')
  78. }
  79. })
  80. },
  81. //重新登录
  82. openLogin() {
  83. var num = 10;
  84. var that = this;
  85. this.disabled = true;
  86. this.showBtnCunt = this.showBtnCunt + 1;
  87. var intterval = setInterval(function() {
  88. num--;
  89. if (num == 0) {
  90. that.text = '重试';
  91. that.disabled = false;
  92. if (that.showBtnCunt >= 2) {
  93. that.$alert('数据加载过慢,请联系客服', '温馨提示', {
  94. confirmButtonText: '确定',
  95. callback: action => {}
  96. });
  97. }
  98. clearInterval(intterval);
  99. return;
  100. }
  101. that.text = num;
  102. }, 1000);
  103. this.login(this.corpId);
  104. },
  105. login(corpId) {
  106. var that = this;
  107. this.loading = true;
  108. this.$setCache('corpId',corpId)
  109. this.$dd.runtime.permission.requestAuthCode({
  110. corpId: corpId, // 企业id
  111. onSuccess: function(info) {
  112. that.$axios('post', '/api/ding/login', { authCode: info.code, corpId: corpId }).then(res => {
  113. if (res.data.code == 1) {
  114. var { token, user } = res.data.data;
  115. if (user.is_official==1) {
  116. that.$setUserData(user);
  117. that.$router.replace({ path: '/index' });
  118. }else{
  119. that.$router.replace({ path: '/noAccess' });
  120. }
  121. }else if(res.data.code==2001){
  122. that.dialogFormVisible=true;
  123. }
  124. }).finally(() => {
  125. that.loading = false;
  126. });
  127. }
  128. });
  129. },
  130. GetRequest(urlStr) {
  131. if (typeof urlStr == 'undefined') {
  132. var url = decodeURI(location.search); //获取url中"?"符后的字符串
  133. } else {
  134. var url = '?' + urlStr.split('?')[1];
  135. }
  136. var theRequest = new Object();
  137. var strs;
  138. if (url.indexOf('?') != -1) {
  139. var str = url.substr(1);
  140. strs = str.split('&');
  141. for (var i = 0; i < strs.length; i++) {
  142. theRequest[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1]);
  143. }
  144. }
  145. return theRequest;
  146. },
  147. }
  148. };
  149. </script>
  150. <style scoped="scoped">
  151. .refresh {
  152. margin-top: 100px;
  153. width: 100px;
  154. }
  155. .appImg {
  156. width: 200px;
  157. height: 200px;
  158. }
  159. .noData {
  160. text-align: center;
  161. position: fixed;
  162. left: 0;
  163. top: 0;
  164. right: 0;
  165. bottom: 0;
  166. }
  167. .data-all {
  168. margin-bottom: 10%;
  169. color: #595959;
  170. }
  171. </style>