提交 09b77ca07f68b77646ae6199f462f55ad928497e

作者 wangyu
1 个父辈 f32608a1

聊天页面部分修改

@@ -32,7 +32,7 @@ App({ @@ -32,7 +32,7 @@ App({
32 } 32 }
33 }, 33 },
34 34
35 - getTokenByCode: function (code, relaunch) { 35 + getTokenByCode: function (code) {
36 var that = this; 36 var that = this;
37 var baseUrl = that.globalData.baseUrl; 37 var baseUrl = that.globalData.baseUrl;
38 wx.request({ 38 wx.request({
@@ -10,6 +10,7 @@ Page({ @@ -10,6 +10,7 @@ Page({
10 showModal: true, 10 showModal: true,
11 inputValue:"", 11 inputValue:"",
12 comlist:"", 12 comlist:"",
  13 + com_id:"",
13 choosed_index:0, 14 choosed_index:0,
14 datas: ["", "", "", "", ""] 15 datas: ["", "", "", "", ""]
15 }, 16 },
@@ -37,7 +38,7 @@ Page({ @@ -37,7 +38,7 @@ Page({
37 38
38 getComList:function(){ 39 getComList:function(){
39 var that = this; 40 var that = this;
40 - var Authorization = getApp().globalData.Authorization; 41 + var Authorization = app.globalData.Authorization;
41 wx.request({ 42 wx.request({
42 url: baseUrl + 'uaa/v1/tenants', 43 url: baseUrl + 'uaa/v1/tenants',
43 data: { 44 data: {
@@ -99,17 +100,67 @@ Page({ @@ -99,17 +100,67 @@ Page({
99 this.setData({ 100 this.setData({
100 showModal: false, 101 showModal: false,
101 }) 102 })
102 - this.getChatinfo(); 103 + this.refreshToken();
103 }, 104 },
104 105
105 goselect:function(e){ 106 goselect:function(e){
  107 + console.log("goselect",e)
106 this.setData({ 108 this.setData({
  109 + com_id: this.data.comlist[e.currentTarget.id].id,
107 choosed_index: e.currentTarget.id 110 choosed_index: e.currentTarget.id
108 }) 111 })
109 }, 112 },
110 113
  114 + refreshToken:function(){
  115 + var that = this;
  116 + wx.request({
  117 + url: baseUrl + 'uaa/v1/auth/tokens',
  118 + data: {
  119 + "grant_type": "refresh_token",
  120 + "refresh_token": app.globalData.refresh_token,
  121 + "scope": "global_access:end_user,tenant:" + that.data.com_id
  122 + },
  123 + method: "POST",
  124 + header: {
  125 + 'content-type': 'application/json'
  126 + },
  127 + success:function(res){
  128 + console.log("refreshToken", res.data)
  129 +
  130 + var user = res.data.user;
  131 + var tenant = res.data.tenant;
  132 + if (tenant) {
  133 + app.globalData.tenant_id = tenant.id;
  134 + }
  135 + app.globalData.userInfo = res.data.user;
  136 + app.globalData.wx_open_id = user.wx_open_id;
  137 + app.globalData.Authorization = "Bearer " + res.data.access_token;
  138 + app.globalData.refresh_token = res.data.refresh_token;
  139 +
  140 + app.configOssUrl();
  141 + that.getChatinfo();
  142 + }
  143 + })
  144 + },
  145 +
111 getChatinfo:function(){ 146 getChatinfo:function(){
  147 + var that = this;
  148 + var Authorization = app.globalData.Authorization;
  149 + wx.request({
  150 + url: baseUrl + 'callbot/v1/chats',
  151 + data: {},
  152 + method: "GET",
  153 + header: {
  154 + 'content-type': 'application/json',
  155 + "Authorization": Authorization
  156 + },
  157 + success: function (res) {
  158 + if (res && res.data) {
  159 + console.log("res", res)
112 160
  161 + }
  162 + }
  163 + })
113 }, 164 },
114 165
115 /** 166 /**
注册登录 后发表评论