vue2-client 1.2.85 → 1.2.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -93,7 +93,7 @@ export default {
93
93
  }
94
94
  case 'OA' : {
95
95
  loginStart(name, password).then(this.afterLoginOA).finally(() => { this.logging = false })
96
- break
96
+ break
97
97
  }
98
98
  case 'V4' : {
99
99
  V4Login(name, password).then(this.afterLoginV4)
@@ -116,16 +116,27 @@ export default {
116
116
  const password = this.form.getFieldValue('password')
117
117
  this.logging = false
118
118
  const loginRes = res
119
- const V4Token = { token: res.access_token, expire: res.expires_in }
119
+ // 如果这是用户首次打开本系统,localStorage无法初始化,改用code判断
120
+ let pass = false
121
+ let V4Token = {}
122
+ // 判断是否是第一次使用本系统
123
+ if (res.code) {
124
+ if (res.code === 200) {
125
+ pass = true
126
+ // 如果返回值有code,证明是第一次使用系统,localStorage判断compatible失效
127
+ // token需要从.data中获取
128
+ V4Token = { token: res.data.access_token, expire: res.data.expires_in }
129
+ }
130
+ } else {
131
+ V4Token = { token: res.access_token, expire: res.expires_in }
132
+ }
120
133
  this.setV4AccessToken(V4Token)
121
134
  // 向本地缓存中临时存储compatible
122
- localStorage.setItem('compatible', this.compatible)
123
- if (loginRes.access_token) {
135
+ if (loginRes.access_token || pass) {
124
136
  const encrypt = new JSEncrypt()
125
137
  encrypt.setPublicKey('MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCqPvovSfXcwBbW8cKMCgwqNpsYuzF8RPAPFb7LGsnVo44JhM/xxzDyzoYtdfNmtbIuKVi9PzIsyp6rg+09gbuI6UGwBZ5DWBDBMqv5MPdOF5dCQkB2Bbr5yPfURPENypUz+pBFBg41d+BC+rwRiXELwKy7Y9caD/MtJyHydj8OUwIDAQAB')
126
138
  const data = encrypt.encrypt(JSON.stringify({ username: name, password: password }))
127
139
  // 获取路由配置
128
- console.log('开始请求智慧燃气')
129
140
  getRoutesConfig(data).then(result => {
130
141
  this.$login.login(result).then(() => {
131
142
  this.afterGeneral(result)
@@ -205,59 +216,59 @@ export default {
205
216
  </script>
206
217
 
207
218
  <style lang="less" scoped>
208
- .common-layout{
209
- .top {
210
- text-align: center;
211
- .header {
219
+ .common-layout{
220
+ .top {
221
+ text-align: center;
222
+ .header {
223
+ height: 44px;
224
+ line-height: 44px;
225
+ a {
226
+ text-decoration: none;
227
+ }
228
+ .logo {
212
229
  height: 44px;
213
- line-height: 44px;
214
- a {
215
- text-decoration: none;
216
- }
217
- .logo {
218
- height: 44px;
219
- vertical-align: top;
220
- margin-right: 16px;
221
- }
222
- .title {
223
- font-size: 33px;
224
- color: @title-color;
225
- font-family: 'Myriad Pro', 'Helvetica Neue', Arial, Helvetica, sans-serif;
226
- font-weight: 600;
227
- position: relative;
228
- top: 2px;
229
- }
230
+ vertical-align: top;
231
+ margin-right: 16px;
230
232
  }
231
- .desc {
232
- font-size: 14px;
233
- color: @text-color-second;
234
- margin-top: 12px;
235
- margin-bottom: 40px;
233
+ .title {
234
+ font-size: 33px;
235
+ color: @title-color;
236
+ font-family: 'Myriad Pro', 'Helvetica Neue', Arial, Helvetica, sans-serif;
237
+ font-weight: 600;
238
+ position: relative;
239
+ top: 2px;
236
240
  }
237
241
  }
238
- .login{
239
- width: 368px;
240
- margin: 0 auto;
241
- @media screen and (max-width: 576px) {
242
- width: 95%;
243
- }
244
- @media screen and (max-width: 320px) {
245
- .captcha-button{
246
- font-size: 14px;
247
- }
242
+ .desc {
243
+ font-size: 14px;
244
+ color: @text-color-second;
245
+ margin-top: 12px;
246
+ margin-bottom: 40px;
247
+ }
248
+ }
249
+ .login{
250
+ width: 368px;
251
+ margin: 0 auto;
252
+ @media screen and (max-width: 576px) {
253
+ width: 95%;
254
+ }
255
+ @media screen and (max-width: 320px) {
256
+ .captcha-button{
257
+ font-size: 14px;
248
258
  }
249
- .icon {
250
- font-size: 24px;
251
- color: @text-color-second;
252
- margin-left: 16px;
253
- vertical-align: middle;
254
- cursor: pointer;
255
- transition: color 0.3s;
259
+ }
260
+ .icon {
261
+ font-size: 24px;
262
+ color: @text-color-second;
263
+ margin-left: 16px;
264
+ vertical-align: middle;
265
+ cursor: pointer;
266
+ transition: color 0.3s;
256
267
 
257
- &:hover {
258
- color: @primary-color;
259
- }
268
+ &:hover {
269
+ color: @primary-color;
260
270
  }
261
271
  }
262
272
  }
273
+ }
263
274
  </style>
@@ -3,7 +3,7 @@ let Amap
3
3
  async function GetGDMap () {
4
4
  if (!Amap) {
5
5
  window._AMapSecurityConfig = {
6
- securityJsCode:'275e59edb26ab1f917cfe7f05bea7979'
6
+ securityJsCode: '275e59edb26ab1f917cfe7f05bea7979'
7
7
  }
8
8
  Amap = await AMapLoader.load({
9
9
  key: '55a4807a6fc3adca5510f69578b1ae4a', // 申请好的Web端开发者Key,首次调用 load 时必填
@@ -4,7 +4,7 @@ import Vue from 'vue'
4
4
  import { ACCESS_TOKEN } from '@vue2-client/store/mutation-types'
5
5
  import notification from 'ant-design-vue/es/notification'
6
6
 
7
- const setting = require('../config/default/setting.config')
7
+ let compatible
8
8
 
9
9
  // 跨域认证信息 header 名
10
10
  const xsrfHeaderName = 'Authorization'
@@ -151,12 +151,16 @@ function checkAuthorization (authType = AUTH_TYPE.BEARER) {
151
151
  function loadInterceptors () {
152
152
  // 加载请求拦截器
153
153
  axios.interceptors.request.use(config => {
154
- const token = localStorage.getItem(ACCESS_TOKEN)
154
+ const token = localStorage.getItem('ACCESS_TOKEN')
155
155
  // 如果 token 存在
156
156
  // 让每个请求携带自定义 token 请根据实际情况自行修改
157
157
  if (token) {
158
+ // 如果是首次使用系统LocalStorage需要初始化,在登陆之后重新获取一次compatible
159
+ if (compatible === null) {
160
+ compatible = localStorage.getItem('compatible')
161
+ }
158
162
  // 判断是否为V4环境
159
- if (setting.compatible === 'V4') {
163
+ if (compatible === 'V4') {
160
164
  // V4 环境则添加 V4请求头
161
165
  config.headers['ACCESS_TOKEN'] = localStorage.getItem('ACCESS_TOKEN')
162
166
  config.headers['ACCESS_TOKEN_EXPIRES'] = localStorage.getItem('ACCESS_TOKEN_EXPIRES')
@@ -171,8 +175,12 @@ function loadInterceptors () {
171
175
  }, errorHandler)
172
176
  // 加载响应拦截器
173
177
  axios.interceptors.response.use((response) => {
174
- // 判断是否为V4环境
175
- if (setting.compatible === 'V4') {
178
+ // 判断是否为V4环境,不为compatible赋初始值
179
+ // 其有可能是undefined未定义,或第一次使用本系统LocalStorage在初始化,获得的值为null
180
+ if (compatible === null || compatible === undefined) {
181
+ compatible = localStorage.getItem('compatible')
182
+ }
183
+ if (compatible === 'V4') {
176
184
  if (response.data.data) {
177
185
  return response.data.data
178
186
  } else {