launch.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <view class="content">
  3. </view>
  4. </template>
  5. <script>
  6. import { getConfigSignature } from '@/api/qw.js'
  7. export default {
  8. data() {
  9. return {
  10. loading: null,
  11. outUserId: null,
  12. qwUserId: null,
  13. currentPath: null,
  14. baseUrl:uni.getStorageSync('requestPath')
  15. };
  16. },
  17. onShow() {
  18. // this.getUserId();
  19. this.navigatHandler();
  20. },
  21. methods: {
  22. navigatHandler() {
  23. if (!this.utils.isLogin()) {
  24. uni.reLaunch({
  25. url: '../auth/login',
  26. })
  27. } else {
  28. uni.reLaunch({
  29. url: '../user/index',
  30. })
  31. }
  32. },
  33. getUserId() {
  34. const urlParams = new URLSearchParams(window.location.search);
  35. const currentUrl = window.location.href.split('#')[0];
  36. const companyId = urlParams.get('companyId');
  37. const code = urlParams.get('code');
  38. var data={
  39. companyId: companyId,
  40. url: currentUrl,
  41. code: code
  42. }
  43. getConfigSignature(data).then(
  44. res => {
  45. uni.hideLoading()
  46. if(res.code==200){
  47. const agentConfigSignature = res.config.agentConfigSignature;
  48. const configSignature = res.config.configSignature;
  49. const corpId = res.config.corpId;
  50. const nonceStr = res.config.nonceStr;
  51. const timestamp = res.config.timestamp;
  52. const agentId = res.config.agentId;
  53. this.qwUserId = res.config.userid;
  54. wx.config({
  55. beta: true,
  56. debug: false,
  57. appId: corpId,
  58. timestamp: timestamp,
  59. nonceStr: nonceStr,
  60. signature: configSignature,
  61. jsApiList: ['getCurExternalContact']
  62. });
  63. wx.ready(() => {
  64. wx.agentConfig({
  65. corpid: corpId,
  66. agentid: agentId,
  67. timestamp: timestamp,
  68. nonceStr: nonceStr,
  69. signature: agentConfigSignature,
  70. jsApiList: ['getCurExternalContact'],
  71. success: (res) => {
  72. wx.invoke('getCurExternalContact', {}, async (res) => {
  73. if (res.err_msg === "getCurExternalContact:ok") {
  74. this.outUserId = res.userId;
  75. uni.showToast({
  76. title: res.userId,
  77. icon: 'none'
  78. })
  79. } else {
  80. // 错误处理
  81. }
  82. });
  83. },
  84. fail: (res) => {
  85. console.error('agentConfig fail:', res);
  86. }
  87. });
  88. });
  89. wx.error((res) => {
  90. console.error('wx.error:', res);
  91. });
  92. }
  93. else{
  94. uni.showToast({
  95. title: res.msg,
  96. icon: 'none'
  97. })
  98. }
  99. },
  100. rej => {}
  101. );
  102. }
  103. }
  104. };
  105. </script>
  106. <style>
  107. page{
  108. background-color: #fff;
  109. }
  110. .content {
  111. background-color: #fff;
  112. height: 100%;
  113. width: 100%;
  114. position: relative;
  115. }
  116. </style>