launch.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view class="content">
  3. <view class="loadding" v-if="loadding==true">
  4. <image :src="imgPath+'/app/image/logo.png'"></image>
  5. <text class="text">{{name}}</text>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. data() {
  12. return {
  13. loading: null,
  14. outUserId: null,
  15. qwUserId: null,
  16. currentPath: null,
  17. baseUrl:uni.getStorageSync('requestPath')
  18. };
  19. },
  20. computed: {
  21. imgPath() {
  22. return this.$store.state.imgpath
  23. },
  24. name() {
  25. return this.$store.state.logoname
  26. },
  27. },
  28. onShow() {
  29. // this.getUserId();
  30. this.navigatHandler();
  31. },
  32. methods: {
  33. navigatHandler() {
  34. // // #ifdef MP-WEIXIN
  35. // uni.reLaunch({
  36. // url: '/pages/auth/wxlogin',
  37. // })
  38. // // #endif
  39. // #ifdef MP-WEIXIN
  40. console.log('现在')
  41. if(uni.getStorageSync('AppToken')){
  42. uni.reLaunch({
  43. url: '/pages/index/index',
  44. })
  45. }else{
  46. uni.reLaunch({
  47. url: '/pages/enterprise/enterprise',
  48. })
  49. }
  50. // #endif
  51. // #ifdef H5
  52. if (!this.utils.isLogin()) {
  53. // #ifdef H5
  54. uni.reLaunch({
  55. url: '/pages/auth/login',
  56. })
  57. // #endif
  58. } else {
  59. // #ifdef H5
  60. uni.reLaunch({
  61. url: '/pages/index/index',
  62. })
  63. // #endif
  64. }
  65. // #endif
  66. },
  67. getUserId() {
  68. const urlParams = new URLSearchParams(window.location.search);
  69. const currentUrl = window.location.href.split('#')[0];
  70. const companyId = urlParams.get('companyId');
  71. const code = urlParams.get('code');
  72. var data={
  73. companyId: companyId,
  74. url: currentUrl,
  75. code: code
  76. }
  77. getConfigSignature(data).then(
  78. res => {
  79. uni.hideLoading()
  80. if(res.code==200){
  81. const agentConfigSignature = res.config.agentConfigSignature;
  82. const configSignature = res.config.configSignature;
  83. const corpId = res.config.corpId;
  84. const nonceStr = res.config.nonceStr;
  85. const timestamp = res.config.timestamp;
  86. const agentId = res.config.agentId;
  87. this.qwUserId = res.config.userid;
  88. wx.config({
  89. beta: true,
  90. debug: false,
  91. appId: corpId,
  92. timestamp: timestamp,
  93. nonceStr: nonceStr,
  94. signature: configSignature,
  95. jsApiList: ['getCurExternalContact']
  96. });
  97. wx.ready(() => {
  98. wx.agentConfig({
  99. corpid: corpId,
  100. agentid: agentId,
  101. timestamp: timestamp,
  102. nonceStr: nonceStr,
  103. signature: agentConfigSignature,
  104. jsApiList: ['getCurExternalContact'],
  105. success: (res) => {
  106. wx.invoke('getCurExternalContact', {}, async (res) => {
  107. if (res.err_msg === "getCurExternalContact:ok") {
  108. this.outUserId = res.userId;
  109. uni.showToast({
  110. title: res.userId,
  111. icon: 'none'
  112. })
  113. } else {
  114. // 错误处理
  115. }
  116. });
  117. },
  118. fail: (res) => {
  119. console.error('agentConfig fail:', res);
  120. }
  121. });
  122. });
  123. wx.error((res) => {
  124. console.error('wx.error:', res);
  125. });
  126. }
  127. else{
  128. uni.showToast({
  129. title: res.msg,
  130. icon: 'none'
  131. })
  132. }
  133. },
  134. rej => {}
  135. );
  136. }
  137. }
  138. };
  139. </script>
  140. <style lang="scss">
  141. page{
  142. background-color: #fff;
  143. }
  144. .content {
  145. background-color: #fff;
  146. height: 100%;
  147. width: 100%;
  148. position: relative;
  149. }
  150. .loadding{
  151. background-color: #fff;
  152. display: flex;
  153. flex-direction: column;
  154. align-items: center;
  155. justify-content: center;
  156. position: absolute;
  157. top: 0;
  158. left: 0;
  159. width: 100%;
  160. height: 100%;
  161. z-index: 9999;
  162. image{
  163. border-radius: 50%;
  164. animation: load linear 1s infinite;
  165. width: 120rpx;
  166. height:120rpx;
  167. }
  168. .text{
  169. font-size: 28rpx;
  170. margin-top: 20rpx;
  171. }
  172. }
  173. </style>