提交 1edc4ef0d037c68acdce5ed5ca213801cdd2bf23

作者 wangyu
1 个父辈 cb30ed8a

优化

@@ -16,7 +16,7 @@ App({ @@ -16,7 +16,7 @@ App({
16 "code": res.code, 16 "code": res.code,
17 "scope": "global_access:end_user,tenant:" + appId 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,7 +33,7 @@ App({
33 "refresh_token": that.globalData.refresh_token, 33 "refresh_token": that.globalData.refresh_token,
34 "scope": "global_access:end_user,tenant:" + that.globalData.com_id 34 "scope": "global_access:end_user,tenant:" + that.globalData.com_id
35 }; 35 };
36 - that.getTokenByCode(requestdata, false) 36 + that.getTokenByCode(requestdata, false,"")
37 } else { 37 } else {
38 wx.login({ 38 wx.login({
39 success: function(res) { 39 success: function(res) {
@@ -43,7 +43,7 @@ App({ @@ -43,7 +43,7 @@ App({
43 "code": res.code, 43 "code": res.code,
44 "scope": "global_access:end_user,tenant:" + appId 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,7 +51,7 @@ App({
51 } 51 }
52 }, 52 },
53 53
54 - getTokenByCode: function(requestdata, relaunch) { 54 + getTokenByCode: function(requestdata, relaunch,str) {
55 var that = this; 55 var that = this;
56 var baseUrl = that.globalData.baseUrl; 56 var baseUrl = that.globalData.baseUrl;
57 wx.request({ 57 wx.request({
@@ -88,8 +88,14 @@ App({ @@ -88,8 +88,14 @@ App({
88 fail: function(res) { 88 fail: function(res) {
89 console.log("login-res-fail", res); 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 getUserInfo: function(cb) { 99 getUserInfo: function(cb) {
94 var that = this 100 var that = this
95 if (this.globalData.userInfo) { 101 if (this.globalData.userInfo) {
@@ -137,6 +143,7 @@ App({ @@ -137,6 +143,7 @@ App({
137 appId: appId, 143 appId: appId,
138 com_id: "", 144 com_id: "",
139 onshow_count: 0, 145 onshow_count: 0,
  146 + refresh_complete:false,
140 // baseUrl: "http://47.99.47.16:20000/", 147 // baseUrl: "http://47.99.47.16:20000/",
141 // baseUrl: "http://47.96.75.229:20000/", 148 // baseUrl: "http://47.96.75.229:20000/",
142 // baseUrl: "http://192.144.144.220:20000/", 149 // baseUrl: "http://192.144.144.220:20000/",
@@ -231,6 +231,8 @@ Page({ @@ -231,6 +231,8 @@ Page({
231 inputdisable = false 231 inputdisable = false
232 issinglechild_Data.disabled = false; 232 issinglechild_Data.disabled = false;
233 shareMethod_Data.disabled = false; 233 shareMethod_Data.disabled = false;
  234 + issinglechild_Data.selected = '' ;
  235 + shareMethod_Data.selected = '';
234 }else{ 236 }else{
235 btn_show = false 237 btn_show = false
236 inputdisable = true 238 inputdisable = true
@@ -324,7 +326,7 @@ Page({ @@ -324,7 +326,7 @@ Page({
324 }) 326 })
325 } 327 }
326 this.setData({ 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 input_disable: inputdisable, 330 input_disable: inputdisable,
329 331
330 btn_show: btn_show, 332 btn_show: btn_show,
@@ -12,7 +12,7 @@ Page({ @@ -12,7 +12,7 @@ Page({
12 comlist: [], 12 comlist: [],
13 com_id: "", 13 com_id: "",
14 choosed_index: 0, 14 choosed_index: 0,
15 - chat_idx:"Toview"+0, 15 + chat_idx: "Toview" + 0,
16 chatlist: [] 16 chatlist: []
17 }, 17 },
18 18
@@ -40,7 +40,7 @@ Page({ @@ -40,7 +40,7 @@ Page({
40 * Lifecycle function--Called when page show 40 * Lifecycle function--Called when page show
41 */ 41 */
42 onShow: function(e) { 42 onShow: function(e) {
43 - console.log("e---",e) 43 + console.log("e---", e)
44 }, 44 },
45 45
46 getComList: function() { 46 getComList: function() {
@@ -107,7 +107,7 @@ Page({ @@ -107,7 +107,7 @@ Page({
107 that.data.chatlist.push(res.data) 107 that.data.chatlist.push(res.data)
108 that.setData({ 108 that.setData({
109 inputValue: "", 109 inputValue: "",
110 - chat_idx: "Toview"+that.data.chatlist.length, 110 + chat_idx: "Toview" + that.data.chatlist.length,
111 chatlist: that.data.chatlist 111 chatlist: that.data.chatlist
112 }) 112 })
113 console.log("chatlist", that.data.chatlist) 113 console.log("chatlist", that.data.chatlist)
@@ -116,54 +116,55 @@ Page({ @@ -116,54 +116,55 @@ Page({
116 // duration: 300 116 // duration: 300
117 // }) 117 // })
118 // that.getChatinfo() 118 // that.getChatinfo()
119 - setTimeout(function(){ 119 + setTimeout(function() {
120 that.bottom() 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 getChatinfo: function() { 165 getChatinfo: function() {
166 var that = this; 166 var that = this;
  167 + console.log("refresh_complete", app.globalData.refresh_complete)
167 var Authorization = app.globalData.Authorization; 168 var Authorization = app.globalData.Authorization;
168 wx.request({ 169 wx.request({
169 url: baseUrl + 'chatbot/v1/chats', 170 url: baseUrl + 'chatbot/v1/chats',
@@ -177,7 +178,7 @@ Page({ @@ -177,7 +178,7 @@ Page({
177 if (res && res.data) { 178 if (res && res.data) {
178 console.log("getChatinfo", res) 179 console.log("getChatinfo", res)
179 that.setData({ 180 that.setData({
180 - chat_idx: "Toview"+res.data.items.length, 181 + chat_idx: "Toview" + res.data.items.length,
181 chatlist: res.data.items.reverse() 182 chatlist: res.data.items.reverse()
182 }) 183 })
183 that.bottom() 184 that.bottom()
@@ -202,15 +203,13 @@ Page({ @@ -202,15 +203,13 @@ Page({
202 this.setData({ 203 this.setData({
203 showModal: false, 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 bindChange: function(e) { 215 bindChange: function(e) {
@@ -225,7 +224,7 @@ Page({ @@ -225,7 +224,7 @@ Page({
225 }, 224 },
226 225
227 //聊天消息始终显示最底端 226 //聊天消息始终显示最底端
228 - bottom: function () { 227 + bottom: function() {
229 // var query = wx.createSelectorQuery() 228 // var query = wx.createSelectorQuery()
230 // query.select('#flag').boundingClientRect() 229 // query.select('#flag').boundingClientRect()
231 // query.selectViewport().scrollOffset() 230 // query.selectViewport().scrollOffset()
@@ -235,11 +234,11 @@ Page({ @@ -235,11 +234,11 @@ Page({
235 // }) 234 // })
236 // res[1].scrollTop // 显示区域的竖直滚动位置 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 wx.pageScrollTo({ 239 wx.pageScrollTo({
241 - scrollTop: rect.height+99999,  
242 - duration:100 240 + scrollTop: rect.height + 99999,
  241 + duration: 100
243 }) 242 })
244 }).exec() 243 }).exec()
245 }, 244 },
注册登录 后发表评论