...
|
...
|
@@ -12,7 +12,7 @@ Page({ |
12
|
12
|
comlist: [],
|
13
|
13
|
com_id: "",
|
14
|
14
|
choosed_index: 0,
|
15
|
|
- chat_idx:"Toview"+0,
|
|
15
|
+ chat_idx: "Toview" + 0,
|
16
|
16
|
chatlist: []
|
17
|
17
|
},
|
18
|
18
|
|
...
|
...
|
@@ -40,7 +40,7 @@ Page({ |
40
|
40
|
* Lifecycle function--Called when page show
|
41
|
41
|
*/
|
42
|
42
|
onShow: function(e) {
|
43
|
|
- console.log("e---",e)
|
|
43
|
+ console.log("e---", e)
|
44
|
44
|
},
|
45
|
45
|
|
46
|
46
|
getComList: function() {
|
...
|
...
|
@@ -107,7 +107,7 @@ Page({ |
107
|
107
|
that.data.chatlist.push(res.data)
|
108
|
108
|
that.setData({
|
109
|
109
|
inputValue: "",
|
110
|
|
- chat_idx: "Toview"+that.data.chatlist.length,
|
|
110
|
+ chat_idx: "Toview" + that.data.chatlist.length,
|
111
|
111
|
chatlist: that.data.chatlist
|
112
|
112
|
})
|
113
|
113
|
console.log("chatlist", that.data.chatlist)
|
...
|
...
|
@@ -116,54 +116,55 @@ Page({ |
116
|
116
|
// duration: 300
|
117
|
117
|
// })
|
118
|
118
|
// that.getChatinfo()
|
119
|
|
- setTimeout(function(){
|
|
119
|
+ setTimeout(function() {
|
120
|
120
|
that.bottom()
|
121
|
|
- },400);
|
122
|
|
-
|
|
121
|
+ }, 400);
|
|
122
|
+
|
123
|
123
|
}
|
124
|
124
|
}
|
125
|
125
|
})
|
126
|
126
|
},
|
127
|
127
|
|
128
|
|
- // refreshToken: function() {
|
129
|
|
- // var that = this;
|
130
|
|
- // wx.request({
|
131
|
|
- // url: baseUrl + 'uaa/v1/auth/tokens',
|
132
|
|
- // data: {
|
133
|
|
- // "grant_type": "refresh_token",
|
134
|
|
- // "refresh_token": app.globalData.refresh_token,
|
135
|
|
- // "scope": "global_access:end_user,tenant:" + that.data.com_id
|
136
|
|
- // },
|
137
|
|
- // method: "POST",
|
138
|
|
- // header: {
|
139
|
|
- // 'content-type': 'application/json'
|
140
|
|
- // },
|
141
|
|
- // success: function(res) {
|
142
|
|
- // console.log("refreshToken", res.data)
|
|
128
|
+ refreshToken: function() {
|
|
129
|
+ var that = this;
|
|
130
|
+ wx.request({
|
|
131
|
+ url: baseUrl + 'uaa/v1/auth/tokens',
|
|
132
|
+ data: {
|
|
133
|
+ "grant_type": "refresh_token",
|
|
134
|
+ "refresh_token": app.globalData.refresh_token,
|
|
135
|
+ "scope": "global_access:end_user,tenant:" + that.data.com_id
|
|
136
|
+ },
|
|
137
|
+ method: "POST",
|
|
138
|
+ header: {
|
|
139
|
+ 'content-type': 'application/json'
|
|
140
|
+ },
|
|
141
|
+ success: function(res) {
|
|
142
|
+ console.log("refreshToken", res.data)
|
143
|
143
|
|
144
|
|
- // var user = res.data.user;
|
145
|
|
- // var tenant = res.data.tenant;
|
146
|
|
- // if (tenant) {
|
147
|
|
- // app.globalData.tenant_id = tenant.id;
|
148
|
|
- // }
|
149
|
|
- // app.globalData.userInfo = res.data.user;
|
150
|
|
- // app.globalData.wx_open_id = user.wx_open_id;
|
151
|
|
- // app.globalData.Authorization = "Bearer " + res.data.access_token;
|
152
|
|
- // app.globalData.refresh_token = res.data.refresh_token;
|
|
144
|
+ var user = res.data.user;
|
|
145
|
+ var tenant = res.data.tenant;
|
|
146
|
+ if (tenant) {
|
|
147
|
+ app.globalData.tenant_id = tenant.id;
|
|
148
|
+ }
|
|
149
|
+ app.globalData.userInfo = res.data.user;
|
|
150
|
+ app.globalData.wx_open_id = user.wx_open_id;
|
|
151
|
+ app.globalData.Authorization = "Bearer " + res.data.access_token;
|
|
152
|
+ app.globalData.refresh_token = res.data.refresh_token;
|
153
|
153
|
|
154
|
|
- // app.configOssUrl();
|
155
|
|
- // that.getChatinfo();
|
156
|
|
- // },
|
157
|
|
- // complete:function(res){
|
158
|
|
- // wx.showLoading({
|
159
|
|
- // title: '',
|
160
|
|
- // })
|
161
|
|
- // }
|
162
|
|
- // })
|
163
|
|
- // },
|
|
154
|
+ app.configOssUrl();
|
|
155
|
+ that.getChatinfo();
|
|
156
|
+ },
|
|
157
|
+ complete:function(res){
|
|
158
|
+ wx.showLoading({
|
|
159
|
+ title: '',
|
|
160
|
+ })
|
|
161
|
+ }
|
|
162
|
+ })
|
|
163
|
+ },
|
164
|
164
|
|
165
|
165
|
getChatinfo: function() {
|
166
|
166
|
var that = this;
|
|
167
|
+ console.log("refresh_complete", app.globalData.refresh_complete)
|
167
|
168
|
var Authorization = app.globalData.Authorization;
|
168
|
169
|
wx.request({
|
169
|
170
|
url: baseUrl + 'chatbot/v1/chats',
|
...
|
...
|
@@ -177,7 +178,7 @@ Page({ |
177
|
178
|
if (res && res.data) {
|
178
|
179
|
console.log("getChatinfo", res)
|
179
|
180
|
that.setData({
|
180
|
|
- chat_idx: "Toview"+res.data.items.length,
|
|
181
|
+ chat_idx: "Toview" + res.data.items.length,
|
181
|
182
|
chatlist: res.data.items.reverse()
|
182
|
183
|
})
|
183
|
184
|
that.bottom()
|
...
|
...
|
@@ -202,15 +203,13 @@ Page({ |
202
|
203
|
this.setData({
|
203
|
204
|
showModal: false,
|
204
|
205
|
})
|
205
|
|
- var requestdata = {
|
206
|
|
- "grant_type": "refresh_token",
|
207
|
|
- "refresh_token": app.globalData.refresh_token,
|
208
|
|
- "scope": "global_access:end_user,tenant:" + this.data.com_id
|
209
|
|
- };
|
210
|
|
- setTimeout(() => {
|
211
|
|
- app.getTokenByCode(requestdata, false);
|
212
|
|
- }, 2000);
|
213
|
|
- this.getChatinfo();
|
|
206
|
+ // var requestdata = {
|
|
207
|
+ // "grant_type": "refresh_token",
|
|
208
|
+ // "refresh_token": app.globalData.refresh_token,
|
|
209
|
+ // "scope": "global_access:end_user,tenant:" + this.data.com_id
|
|
210
|
+ // };
|
|
211
|
+ this.refreshToken()
|
|
212
|
+ // this.getChatinfo();
|
214
|
213
|
},
|
215
|
214
|
|
216
|
215
|
bindChange: function(e) {
|
...
|
...
|
@@ -225,7 +224,7 @@ Page({ |
225
|
224
|
},
|
226
|
225
|
|
227
|
226
|
//聊天消息始终显示最底端
|
228
|
|
- bottom: function () {
|
|
227
|
+ bottom: function() {
|
229
|
228
|
// var query = wx.createSelectorQuery()
|
230
|
229
|
// query.select('#flag').boundingClientRect()
|
231
|
230
|
// query.selectViewport().scrollOffset()
|
...
|
...
|
@@ -235,11 +234,11 @@ Page({ |
235
|
234
|
// })
|
236
|
235
|
// res[1].scrollTop // 显示区域的竖直滚动位置
|
237
|
236
|
// })
|
238
|
|
- wx.createSelectorQuery().select('#flag').boundingClientRect(function (rect) {
|
|
237
|
+ wx.createSelectorQuery().select('#flag').boundingClientRect(function(rect) {
|
239
|
238
|
// 使页面滚动到底部
|
240
|
239
|
wx.pageScrollTo({
|
241
|
|
- scrollTop: rect.height+99999,
|
242
|
|
- duration:100
|
|
240
|
+ scrollTop: rect.height + 99999,
|
|
241
|
+ duration: 100
|
243
|
242
|
})
|
244
|
243
|
}).exec()
|
245
|
244
|
},
|
...
|
...
|
|