正在显示
3 个修改的文件
包含
67 行增加
和
59 行删除
... | ... | @@ -16,7 +16,7 @@ App({ |
16 | 16 | "code": res.code, |
17 | 17 | "scope": "global_access:end_user,tenant:" + appId |
18 | 18 | }; |
19 | - that.getTokenByCode(requestdata, true) | |
19 | + that.getTokenByCode(requestdata, true,"") | |
20 | 20 | } |
21 | 21 | } |
22 | 22 | }) |
... | ... | @@ -33,7 +33,7 @@ App({ |
33 | 33 | "refresh_token": that.globalData.refresh_token, |
34 | 34 | "scope": "global_access:end_user,tenant:" + that.globalData.com_id |
35 | 35 | }; |
36 | - that.getTokenByCode(requestdata, false) | |
36 | + that.getTokenByCode(requestdata, false,"") | |
37 | 37 | } else { |
38 | 38 | wx.login({ |
39 | 39 | success: function(res) { |
... | ... | @@ -43,7 +43,7 @@ App({ |
43 | 43 | "code": res.code, |
44 | 44 | "scope": "global_access:end_user,tenant:" + appId |
45 | 45 | }; |
46 | - that.getTokenByCode(requestdata, false) | |
46 | + that.getTokenByCode(requestdata, false,"chat") | |
47 | 47 | } |
48 | 48 | } |
49 | 49 | }) |
... | ... | @@ -51,7 +51,7 @@ App({ |
51 | 51 | } |
52 | 52 | }, |
53 | 53 | |
54 | - getTokenByCode: function(requestdata, relaunch) { | |
54 | + getTokenByCode: function(requestdata, relaunch,str) { | |
55 | 55 | var that = this; |
56 | 56 | var baseUrl = that.globalData.baseUrl; |
57 | 57 | wx.request({ |
... | ... | @@ -88,8 +88,14 @@ App({ |
88 | 88 | fail: function(res) { |
89 | 89 | console.log("login-res-fail", res); |
90 | 90 | }, |
91 | + complete:function(res){ | |
92 | + if(str=="chat"){ | |
93 | + that.globalData.refresh_complete = true | |
94 | + } | |
95 | + } | |
91 | 96 | }) |
92 | 97 | }, |
98 | + | |
93 | 99 | getUserInfo: function(cb) { |
94 | 100 | var that = this |
95 | 101 | if (this.globalData.userInfo) { |
... | ... | @@ -137,6 +143,7 @@ App({ |
137 | 143 | appId: appId, |
138 | 144 | com_id: "", |
139 | 145 | onshow_count: 0, |
146 | + refresh_complete:false, | |
140 | 147 | // baseUrl: "http://47.99.47.16:20000/", |
141 | 148 | // baseUrl: "http://47.96.75.229:20000/", |
142 | 149 | // baseUrl: "http://192.144.144.220:20000/", |
... | ... |
... | ... | @@ -231,6 +231,8 @@ Page({ |
231 | 231 | inputdisable = false |
232 | 232 | issinglechild_Data.disabled = false; |
233 | 233 | shareMethod_Data.disabled = false; |
234 | + issinglechild_Data.selected = '' ; | |
235 | + shareMethod_Data.selected = ''; | |
234 | 236 | }else{ |
235 | 237 | btn_show = false |
236 | 238 | inputdisable = true |
... | ... | @@ -324,7 +326,7 @@ Page({ |
324 | 326 | }) |
325 | 327 | } |
326 | 328 | this.setData({ |
327 | - reduce_amount: data.month_deduction_amount ? data.month_deduction_amount : 0, | |
329 | + reduce_amount: data.month_deduction_amount ? data.month_deduction_amount : -1, | |
328 | 330 | input_disable: inputdisable, |
329 | 331 | |
330 | 332 | btn_show: btn_show, |
... | ... |
... | ... | @@ -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 | }, |
... | ... |
请
注册
或
登录
后发表评论