auto.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view class="content">
  3. <view>11{{code}}</view>
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. components: {
  9. },
  10. data() {
  11. return {
  12. code:'',
  13. }
  14. },
  15. onLoad(opt) {
  16. console.log(opt)
  17. //const token = uni.getStorageSync('token');
  18. // this.init()
  19. // this.code= this.$common.getHashQuery('code')
  20. // this.code=uni.getStorageSync('code')
  21. if(opt.code){
  22. this.code=opt.code
  23. uni.setStorage({
  24. key: 'code',
  25. data: opt.code,
  26. success: function () {
  27. uni.navigateTo({
  28. url:'index'
  29. })
  30. }
  31. });
  32. }else{
  33. this.$http('enterpriseWechat/auth/oAuth2', {
  34. corpID:'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g',
  35. redirectUri:'http://qw.66km.com.cn/pages/index/auto',
  36. agentId:'1000040'
  37. }, 'GET').then(res => {
  38. //console.log(res.data)
  39. location.href= res.data
  40. }).catch(err=>{
  41. })
  42. }
  43. },
  44. methods: {
  45. init(){
  46. this.code=uni.getStorageSync('code')
  47. uni.showLoading({
  48. title: '加载中'
  49. });
  50. /* this.$http('enterpriseWechat/auth/oAuth2', {
  51. corpID:'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g',
  52. redirectUri:'http://qw.66km.com.cn/#/',
  53. agentId:'1000036'
  54. }, 'GET').then(res => {
  55. uni.hideLoading();
  56. console.log(res.data)
  57. }).catch(err=>{
  58. uni.hideLoading();
  59. }) */
  60. this.$http('enterpriseWechat/auth/getAgentConfig', {
  61. corpID:'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g',
  62. url:'http://qw.66km.com.cn/'
  63. }, 'GET').then(res => {
  64. uni.hideLoading();
  65. //console.log(this.$wx.agentConfig)
  66. this.$wx.agentConfig({
  67. corpid: 'wpMGjbBgAA_zIu6wbKy48zFSbGiGeP8g', // 必填,企业微信的corpid,必须与当前登录的企业一致
  68. agentid: '1000040', // 必填,企业微信的应用id (e.g. 1000247)
  69. timestamp: res.data.timestamp, // 必填,生成签名的时间戳
  70. nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
  71. signature: res.data.signature,// 必填,签名,见附录-JS-SDK使用权限签名算法
  72. jsApiList: ['getCurExternalContact'], //必填,传入需要使用的接口名称
  73. success: function(res) {
  74. console.log(res)
  75. uni.showToast({
  76. title: 'agentConfig成功',
  77. icon: 'none',
  78. duration: 3000
  79. });
  80. // 回调
  81. },
  82. fail: function(res) {
  83. console.log(res)
  84. uni.showToast({
  85. title: 'agentConfig失败',
  86. icon: 'none',
  87. duration: 3000
  88. });
  89. if(res.errMsg.indexOf('function not exist') > -1){
  90. alert('版本过低请升级')
  91. }
  92. }
  93. });
  94. }).catch(err=>{
  95. uni.hideLoading();
  96. })
  97. },
  98. tabFn(num){
  99. this.tabIndex=num
  100. }
  101. }
  102. }
  103. </script>
  104. <style scoped>
  105. .top{
  106. background: #fff;
  107. }
  108. .top{
  109. display: flex;
  110. padding: 30rpx 24rpx;
  111. }
  112. .logo{
  113. width: 98rpx;height: 98rpx;
  114. }
  115. .topRight{
  116. padding-left: 20rpx;
  117. }
  118. .wxName{
  119. font-weight: 500;
  120. font-size: 32rpx;
  121. color: #333333;
  122. line-height: 45rpx;
  123. }
  124. .titleBox{
  125. display: flex;
  126. padding-top: 10rpx;
  127. }
  128. .title{
  129. height: 36rpx;
  130. border-radius: 4rpx;
  131. border: 1px solid #FF8113;
  132. line-height: 34rpx;
  133. font-size: 24rpx;
  134. color: #FF8113;
  135. padding: 0 8rpx;
  136. margin-right: 10rpx;
  137. }
  138. .tabBox{
  139. display: flex;justify-content: space-between;
  140. background: #fff;
  141. margin-top: 16rpx;
  142. padding: 30rpx 24rpx;
  143. font-size: 30rpx;
  144. color: #333333;
  145. line-height: 42rpx;
  146. }
  147. .tabActive{
  148. color: #FF8113;font-weight: 500;
  149. border-bottom: 2px solid #FF8113;
  150. }
  151. .tabline{
  152. padding-bottom: 8rpx;
  153. }
  154. </style>