auto2.vue 4.3 KB

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