auto.vue 3.9 KB

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