正在显示
4 个修改的文件
包含
105 行增加
和
75 行删除
| 1 | //app.js | 1 | //app.js |
| 2 | const appId = 'wxe91c67adba6ac02d'; | 2 | const appId = 'wxe91c67adba6ac02d'; |
| 3 | App({ | 3 | App({ |
| 4 | - onLaunch: function () { | 4 | + onLaunch: function() { |
| 5 | var that = this; | 5 | var that = this; |
| 6 | console.log("onlaunch---", "onlaunch"); | 6 | console.log("onlaunch---", "onlaunch"); |
| 7 | //调用API从本地缓存中获取数据 | 7 | //调用API从本地缓存中获取数据 |
| @@ -9,44 +9,59 @@ App({ | @@ -9,44 +9,59 @@ App({ | ||
| 9 | logs.unshift(Date.now()) | 9 | logs.unshift(Date.now()) |
| 10 | wx.setStorageSync('logs', logs) | 10 | wx.setStorageSync('logs', logs) |
| 11 | wx.login({ | 11 | wx.login({ |
| 12 | - success: function (res) { | 12 | + success: function(res) { |
| 13 | if (res.code) { | 13 | if (res.code) { |
| 14 | - that.getTokenByCode(res.code, true) | 14 | + var requestdata = { |
| 15 | + "grant_type": "wx_app_code", | ||
| 16 | + "code": res.code, | ||
| 17 | + "scope": "global_access:end_user,tenant:" + appId | ||
| 18 | + }; | ||
| 19 | + that.getTokenByCode(requestdata, true) | ||
| 15 | } | 20 | } |
| 16 | } | 21 | } |
| 17 | }) | 22 | }) |
| 18 | }, | 23 | }, |
| 19 | 24 | ||
| 20 | - onShow: function (res) { | 25 | + onShow: function(res) { |
| 21 | console.log("onShow----", res); | 26 | console.log("onShow----", res); |
| 22 | var that = this; | 27 | var that = this; |
| 23 | that.globalData.onshow_count++; | 28 | that.globalData.onshow_count++; |
| 24 | - if (that.globalData.onshow_count > 1) {//除第一次进入小程序之外的打开时 | ||
| 25 | - wx.login({ | ||
| 26 | - success: function (res) { | ||
| 27 | - if (res.code) { | ||
| 28 | - that.getTokenByCode(res.code, false) | 29 | + if (that.globalData.onshow_count > 1) { //除第一次进入小程序之外的打开时 |
| 30 | + if (res.path =="pages/main/smartchat/chat") {//聊天页面锁屏再打开,走该逻辑 | ||
| 31 | + var requestdata = { | ||
| 32 | + "grant_type": "refresh_token", | ||
| 33 | + "refresh_token": that.globalData.refresh_token, | ||
| 34 | + "scope": "global_access:end_user,tenant:" + that.globalData.com_id | ||
| 35 | + }; | ||
| 36 | + that.getTokenByCode(requestdata, false) | ||
| 37 | + } else { | ||
| 38 | + wx.login({ | ||
| 39 | + success: function(res) { | ||
| 40 | + if (res.code) { | ||
| 41 | + var requestdata = { | ||
| 42 | + "grant_type": "wx_app_code", | ||
| 43 | + "code": res.code, | ||
| 44 | + "scope": "global_access:end_user,tenant:" + appId | ||
| 45 | + }; | ||
| 46 | + that.getTokenByCode(requestdata, false) | ||
| 47 | + } | ||
| 29 | } | 48 | } |
| 30 | - } | ||
| 31 | - }) | 49 | + }) |
| 50 | + } | ||
| 32 | } | 51 | } |
| 33 | }, | 52 | }, |
| 34 | 53 | ||
| 35 | - getTokenByCode: function (code, relaunch) { | 54 | + getTokenByCode: function(requestdata, relaunch) { |
| 36 | var that = this; | 55 | var that = this; |
| 37 | var baseUrl = that.globalData.baseUrl; | 56 | var baseUrl = that.globalData.baseUrl; |
| 38 | wx.request({ | 57 | wx.request({ |
| 39 | url: baseUrl + 'uaa/v1/auth/tokens', | 58 | url: baseUrl + 'uaa/v1/auth/tokens', |
| 40 | - data: { | ||
| 41 | - "grant_type": "wx_app_code", | ||
| 42 | - "code": code, | ||
| 43 | - "scope": "global_access:end_user,tenant:" + appId | ||
| 44 | - }, | 59 | + data: requestdata, |
| 45 | method: "POST", | 60 | method: "POST", |
| 46 | header: { | 61 | header: { |
| 47 | 'content-type': 'application/json' | 62 | 'content-type': 'application/json' |
| 48 | }, | 63 | }, |
| 49 | - success: function (res) { | 64 | + success: function(res) { |
| 50 | console.log("getTokenByCode", res.data) | 65 | console.log("getTokenByCode", res.data) |
| 51 | var user = res.data.user; | 66 | var user = res.data.user; |
| 52 | var tenant = res.data.tenant; | 67 | var tenant = res.data.tenant; |
| @@ -57,11 +72,11 @@ App({ | @@ -57,11 +72,11 @@ App({ | ||
| 57 | that.globalData.wx_open_id = user.wx_open_id; | 72 | that.globalData.wx_open_id = user.wx_open_id; |
| 58 | that.globalData.Authorization = "Bearer " + res.data.access_token; | 73 | that.globalData.Authorization = "Bearer " + res.data.access_token; |
| 59 | that.globalData.refresh_token = res.data.refresh_token; | 74 | that.globalData.refresh_token = res.data.refresh_token; |
| 60 | - if (user && user.type == "0") {//匿名用户 | 75 | + if (user && user.type == "0") { //匿名用户 |
| 61 | wx.redirectTo({ | 76 | wx.redirectTo({ |
| 62 | url: '../../getPhone/getPhone' | 77 | url: '../../getPhone/getPhone' |
| 63 | }) | 78 | }) |
| 64 | - } else if (user && user.type == "1") {//注册用户 | 79 | + } else if (user && user.type == "1") { //注册用户 |
| 65 | that.configOssUrl() | 80 | that.configOssUrl() |
| 66 | if (relaunch) { | 81 | if (relaunch) { |
| 67 | wx.reLaunch({ | 82 | wx.reLaunch({ |
| @@ -70,12 +85,12 @@ App({ | @@ -70,12 +85,12 @@ App({ | ||
| 70 | } | 85 | } |
| 71 | } | 86 | } |
| 72 | }, | 87 | }, |
| 73 | - fail: function (res) { | 88 | + fail: function(res) { |
| 74 | console.log("login-res-fail", res); | 89 | console.log("login-res-fail", res); |
| 75 | }, | 90 | }, |
| 76 | }) | 91 | }) |
| 77 | }, | 92 | }, |
| 78 | - getUserInfo: function (cb) { | 93 | + getUserInfo: function(cb) { |
| 79 | var that = this | 94 | var that = this |
| 80 | if (this.globalData.userInfo) { | 95 | if (this.globalData.userInfo) { |
| 81 | typeof cb == "function" && cb(this.globalData.userInfo) | 96 | typeof cb == "function" && cb(this.globalData.userInfo) |
| @@ -83,7 +98,7 @@ App({ | @@ -83,7 +98,7 @@ App({ | ||
| 83 | //调用登录接口 | 98 | //调用登录接口 |
| 84 | wx.getUserInfo({ | 99 | wx.getUserInfo({ |
| 85 | withCredentials: false, | 100 | withCredentials: false, |
| 86 | - success: function (res) { | 101 | + success: function(res) { |
| 87 | console.log("userInfo---", res) | 102 | console.log("userInfo---", res) |
| 88 | that.globalData.userInfo = res.userInfo | 103 | that.globalData.userInfo = res.userInfo |
| 89 | typeof cb == "function" && cb(that.globalData.userInfo) | 104 | typeof cb == "function" && cb(that.globalData.userInfo) |
| @@ -92,7 +107,7 @@ App({ | @@ -92,7 +107,7 @@ App({ | ||
| 92 | } | 107 | } |
| 93 | }, | 108 | }, |
| 94 | 109 | ||
| 95 | - configOssUrl: function () { | 110 | + configOssUrl: function() { |
| 96 | wx.showLoading() | 111 | wx.showLoading() |
| 97 | var that = this | 112 | var that = this |
| 98 | wx.request({ | 113 | wx.request({ |
| @@ -101,18 +116,18 @@ App({ | @@ -101,18 +116,18 @@ App({ | ||
| 101 | 'Authorization': this.globalData.Authorization | 116 | 'Authorization': this.globalData.Authorization |
| 102 | }, | 117 | }, |
| 103 | method: 'GET', | 118 | method: 'GET', |
| 104 | - success: function (result) { | 119 | + success: function(result) { |
| 105 | console.log('获取OSSURL 成功', result.data) | 120 | console.log('获取OSSURL 成功', result.data) |
| 106 | that.globalData.OSSUrl = result.data.app_url; | 121 | that.globalData.OSSUrl = result.data.app_url; |
| 107 | }, | 122 | }, |
| 108 | - fail: function (res) { | 123 | + fail: function(res) { |
| 109 | console.log('获取OSSURL 失败', res) | 124 | console.log('获取OSSURL 失败', res) |
| 110 | wx.showToast({ | 125 | wx.showToast({ |
| 111 | icon: "none", | 126 | icon: "none", |
| 112 | title: "云存储功能失效,请联系开发人员", | 127 | title: "云存储功能失效,请联系开发人员", |
| 113 | }) | 128 | }) |
| 114 | }, | 129 | }, |
| 115 | - complete: function () { | 130 | + complete: function() { |
| 116 | wx.hideLoading() | 131 | wx.hideLoading() |
| 117 | } | 132 | } |
| 118 | }) | 133 | }) |
| @@ -120,6 +135,7 @@ App({ | @@ -120,6 +135,7 @@ App({ | ||
| 120 | 135 | ||
| 121 | globalData: { | 136 | globalData: { |
| 122 | appId: appId, | 137 | appId: appId, |
| 138 | + com_id: "", | ||
| 123 | onshow_count: 0, | 139 | onshow_count: 0, |
| 124 | // baseUrl: "http://47.99.47.16:20000/", | 140 | // baseUrl: "http://47.99.47.16:20000/", |
| 125 | // baseUrl: "http://47.96.75.229:20000/", | 141 | // baseUrl: "http://47.96.75.229:20000/", |
| @@ -128,7 +144,7 @@ App({ | @@ -128,7 +144,7 @@ App({ | ||
| 128 | // baseUrl: "http://47.110.250.177:20000/", | 144 | // baseUrl: "http://47.110.250.177:20000/", |
| 129 | baseUrl: "http://47.110.158.110:20000/", | 145 | baseUrl: "http://47.110.158.110:20000/", |
| 130 | // baseUrl: "https://api.workai.com.cn/", | 146 | // baseUrl: "https://api.workai.com.cn/", |
| 131 | - OSSUrl: "",//"https://oss.workai.com.cn/", | 147 | + OSSUrl: "", //"https://oss.workai.com.cn/", |
| 132 | userInfo: null, | 148 | userInfo: null, |
| 133 | hasLogin: false, | 149 | hasLogin: false, |
| 134 | openid: null, | 150 | openid: null, |
| @@ -205,6 +205,12 @@ Page({ | @@ -205,6 +205,12 @@ Page({ | ||
| 205 | shareMethod_Data.selected = data.share_method ? data.share_method : ""; | 205 | shareMethod_Data.selected = data.share_method ? data.share_method : ""; |
| 206 | 206 | ||
| 207 | for (var i = 0; i < newdata.length; i++) { | 207 | for (var i = 0; i < newdata.length; i++) { |
| 208 | + if (newdata[i].education_start) { | ||
| 209 | + newdata[i].education_start = this.formatDate(newdata[i].education_start) | ||
| 210 | + } | ||
| 211 | + if (newdata[i].education_end) { | ||
| 212 | + newdata[i].education_end = this.formatDate(newdata[i].education_end) | ||
| 213 | + } | ||
| 208 | if (newdata[i].patient_birthday) { | 214 | if (newdata[i].patient_birthday) { |
| 209 | newdata[i].patient_birthday = this.formatDate(newdata[i].patient_birthday) | 215 | newdata[i].patient_birthday = this.formatDate(newdata[i].patient_birthday) |
| 210 | } | 216 | } |
| @@ -12,7 +12,6 @@ Page({ | @@ -12,7 +12,6 @@ Page({ | ||
| 12 | comlist: [], | 12 | comlist: [], |
| 13 | com_id: "", | 13 | com_id: "", |
| 14 | choosed_index: 0, | 14 | choosed_index: 0, |
| 15 | - scrollview_h:0, | ||
| 16 | chat_idx:"Toview"+0, | 15 | chat_idx:"Toview"+0, |
| 17 | chatlist: [] | 16 | chatlist: [] |
| 18 | }, | 17 | }, |
| @@ -22,15 +21,12 @@ Page({ | @@ -22,15 +21,12 @@ Page({ | ||
| 22 | */ | 21 | */ |
| 23 | onLoad: function(options) { | 22 | onLoad: function(options) { |
| 24 | this.getComList() | 23 | this.getComList() |
| 25 | - var that = this | ||
| 26 | - wx.getSystemInfo({ | ||
| 27 | - success: function (res) { | ||
| 28 | - that.setData({ | ||
| 29 | - scrollview_h: res.windowHeight-66 | ||
| 30 | - }) | ||
| 31 | - console.log("windowHeight",res.windowHeight) | ||
| 32 | - } | ||
| 33 | - }) | 24 | + // var that = this |
| 25 | + // wx.getSystemInfo({ | ||
| 26 | + // success: function (res) { | ||
| 27 | + // console.log("windowHeight",res.windowHeight) | ||
| 28 | + // } | ||
| 29 | + // }) | ||
| 34 | }, | 30 | }, |
| 35 | 31 | ||
| 36 | /** | 32 | /** |
| @@ -43,8 +39,8 @@ Page({ | @@ -43,8 +39,8 @@ Page({ | ||
| 43 | /** | 39 | /** |
| 44 | * Lifecycle function--Called when page show | 40 | * Lifecycle function--Called when page show |
| 45 | */ | 41 | */ |
| 46 | - onShow: function() { | ||
| 47 | - | 42 | + onShow: function(e) { |
| 43 | + console.log("e---",e) | ||
| 48 | }, | 44 | }, |
| 49 | 45 | ||
| 50 | getComList: function() { | 46 | getComList: function() { |
| @@ -128,37 +124,42 @@ Page({ | @@ -128,37 +124,42 @@ Page({ | ||
| 128 | }) | 124 | }) |
| 129 | }, | 125 | }, |
| 130 | 126 | ||
| 131 | - refreshToken: function() { | ||
| 132 | - var that = this; | ||
| 133 | - wx.request({ | ||
| 134 | - url: baseUrl + 'uaa/v1/auth/tokens', | ||
| 135 | - data: { | ||
| 136 | - "grant_type": "refresh_token", | ||
| 137 | - "refresh_token": app.globalData.refresh_token, | ||
| 138 | - "scope": "global_access:end_user,tenant:" + that.data.com_id | ||
| 139 | - }, | ||
| 140 | - method: "POST", | ||
| 141 | - header: { | ||
| 142 | - 'content-type': 'application/json' | ||
| 143 | - }, | ||
| 144 | - success: function(res) { | ||
| 145 | - console.log("refreshToken", res.data) | 127 | + // refreshToken: function() { |
| 128 | + // var that = this; | ||
| 129 | + // wx.request({ | ||
| 130 | + // url: baseUrl + 'uaa/v1/auth/tokens', | ||
| 131 | + // data: { | ||
| 132 | + // "grant_type": "refresh_token", | ||
| 133 | + // "refresh_token": app.globalData.refresh_token, | ||
| 134 | + // "scope": "global_access:end_user,tenant:" + that.data.com_id | ||
| 135 | + // }, | ||
| 136 | + // method: "POST", | ||
| 137 | + // header: { | ||
| 138 | + // 'content-type': 'application/json' | ||
| 139 | + // }, | ||
| 140 | + // success: function(res) { | ||
| 141 | + // console.log("refreshToken", res.data) | ||
| 146 | 142 | ||
| 147 | - var user = res.data.user; | ||
| 148 | - var tenant = res.data.tenant; | ||
| 149 | - if (tenant) { | ||
| 150 | - app.globalData.tenant_id = tenant.id; | ||
| 151 | - } | ||
| 152 | - app.globalData.userInfo = res.data.user; | ||
| 153 | - app.globalData.wx_open_id = user.wx_open_id; | ||
| 154 | - app.globalData.Authorization = "Bearer " + res.data.access_token; | ||
| 155 | - app.globalData.refresh_token = res.data.refresh_token; | 143 | + // var user = res.data.user; |
| 144 | + // var tenant = res.data.tenant; | ||
| 145 | + // if (tenant) { | ||
| 146 | + // app.globalData.tenant_id = tenant.id; | ||
| 147 | + // } | ||
| 148 | + // app.globalData.userInfo = res.data.user; | ||
| 149 | + // app.globalData.wx_open_id = user.wx_open_id; | ||
| 150 | + // app.globalData.Authorization = "Bearer " + res.data.access_token; | ||
| 151 | + // app.globalData.refresh_token = res.data.refresh_token; | ||
| 156 | 152 | ||
| 157 | - app.configOssUrl(); | ||
| 158 | - that.getChatinfo(); | ||
| 159 | - } | ||
| 160 | - }) | ||
| 161 | - }, | 153 | + // app.configOssUrl(); |
| 154 | + // that.getChatinfo(); | ||
| 155 | + // }, | ||
| 156 | + // complete:function(res){ | ||
| 157 | + // wx.showLoading({ | ||
| 158 | + // title: '', | ||
| 159 | + // }) | ||
| 160 | + // } | ||
| 161 | + // }) | ||
| 162 | + // }, | ||
| 162 | 163 | ||
| 163 | getChatinfo: function() { | 164 | getChatinfo: function() { |
| 164 | var that = this; | 165 | var that = this; |
| @@ -180,7 +181,7 @@ Page({ | @@ -180,7 +181,7 @@ Page({ | ||
| 180 | }) | 181 | }) |
| 181 | that.bottom() | 182 | that.bottom() |
| 182 | } | 183 | } |
| 183 | - } | 184 | + }, |
| 184 | }) | 185 | }) |
| 185 | }, | 186 | }, |
| 186 | 187 | ||
| @@ -200,7 +201,15 @@ Page({ | @@ -200,7 +201,15 @@ Page({ | ||
| 200 | this.setData({ | 201 | this.setData({ |
| 201 | showModal: false, | 202 | showModal: false, |
| 202 | }) | 203 | }) |
| 203 | - this.refreshToken(); | 204 | + var requestdata = { |
| 205 | + "grant_type": "refresh_token", | ||
| 206 | + "refresh_token": app.globalData.refresh_token, | ||
| 207 | + "scope": "global_access:end_user,tenant:" + this.data.com_id | ||
| 208 | + }; | ||
| 209 | + setTimeout(() => { | ||
| 210 | + app.getTokenByCode(requestdata, false); | ||
| 211 | + }, 2000); | ||
| 212 | + this.getChatinfo(); | ||
| 204 | }, | 213 | }, |
| 205 | 214 | ||
| 206 | bindChange: function(e) { | 215 | bindChange: function(e) { |
| @@ -211,6 +220,7 @@ Page({ | @@ -211,6 +220,7 @@ Page({ | ||
| 211 | com_id: this.data.comlist[s].id, | 220 | com_id: this.data.comlist[s].id, |
| 212 | choosed_index: s | 221 | choosed_index: s |
| 213 | }) | 222 | }) |
| 223 | + app.globalData.com_id = this.data.comlist[s].id; | ||
| 214 | }, | 224 | }, |
| 215 | 225 | ||
| 216 | //聊天消息始终显示最底端 | 226 | //聊天消息始终显示最底端 |
| 1 | <!--pages/main/smartchat/chat.wxml--> | 1 | <!--pages/main/smartchat/chat.wxml--> |
| 2 | -<import src="../../../common/picker_cell" /> | ||
| 3 | - | ||
| 4 | <view> | 2 | <view> |
| 5 | <view style='background:#fff;padding-bottom:65px;'> | 3 | <view style='background:#fff;padding-bottom:65px;'> |
| 6 | <view wx:for="{{chatlist}}" wx:for-item="item" style='display:flex;flex-direction:column'> | 4 | <view wx:for="{{chatlist}}" wx:for-item="item" style='display:flex;flex-direction:column'> |
| @@ -33,7 +31,7 @@ | @@ -33,7 +31,7 @@ | ||
| 33 | <view class='modal_lg' hidden="{{!showModal}}"> | 31 | <view class='modal_lg' hidden="{{!showModal}}"> |
| 34 | <text class="text_title">您在多个单位有任职信息,请选择您要在哪家单位咨询问题。</text> | 32 | <text class="text_title">您在多个单位有任职信息,请选择您要在哪家单位咨询问题。</text> |
| 35 | <view class='divide_line_f5f5f5'></view> | 33 | <view class='divide_line_f5f5f5'></view> |
| 36 | - <view style='width:100%;display:flex;flex-direction:column;max-height:688rpx;'> | 34 | + <scroll-view style='width:100%;display:flex;flex-direction:column;max-height:688rpx;'> |
| 37 | <view wx:for="{{comlist}}" wx:for-index="idx" bindtap='bindChange' id="{{idx}}"> | 35 | <view wx:for="{{comlist}}" wx:for-index="idx" bindtap='bindChange' id="{{idx}}"> |
| 38 | <view wx:if="{{idx==choosed_index}}" style='padding:30rpx;display:flex;flex-direction:row;'> | 36 | <view wx:if="{{idx==choosed_index}}" style='padding:30rpx;display:flex;flex-direction:row;'> |
| 39 | <view class='text_item_blue float_left'>{{item.name}}</view> | 37 | <view class='text_item_blue float_left'>{{item.name}}</view> |
| @@ -44,7 +42,7 @@ | @@ -44,7 +42,7 @@ | ||
| 44 | </view> | 42 | </view> |
| 45 | <view class='divide_line_f5f5f5'></view> | 43 | <view class='divide_line_f5f5f5'></view> |
| 46 | </view> | 44 | </view> |
| 47 | - </view> | 45 | + </scroll-view> |
| 48 | 46 | ||
| 49 | <view class='divide_line_f5f5f5'></view> | 47 | <view class='divide_line_f5f5f5'></view> |
| 50 | <view style='width:100%;display: flex;'> | 48 | <view style='width:100%;display: flex;'> |
请
注册
或
登录
后发表评论