auto.vue 3.9 KB

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