Commit f26863ff7b50ff736f20e9571b597c2bf9f8090c
1 parent
06e74a82
remote server
Showing
8 changed files
with
119 additions
and
3 deletions
trash-framework/src/main/java/com/trash/framework/web/service/SysLoginService.java
| ... | ... | @@ -116,7 +116,7 @@ public class SysLoginService |
| 116 | 116 | |
| 117 | 117 | OkRestClient okCline; |
| 118 | 118 | |
| 119 | - public final String LOGIN_URL = "http://183.66.242.6:6001/api/authservice/cs/thirdpart/user"; | |
| 119 | + public final String LOGIN_URL = "http://183.66.242.6:6001/api/authservice/cs/thirdpart/user"; //登录地址 待配置 | |
| 120 | 120 | |
| 121 | 121 | public LoginUser loginByRemote(String token) |
| 122 | 122 | { | ... | ... |
trash-ui/.env.development
trash-ui/src/api/dict.js
0 → 100644
trash-ui/src/settings.js
trash-ui/src/utils/request.js
| ... | ... | @@ -5,6 +5,9 @@ import { getToken } from '@/utils/auth' |
| 5 | 5 | import errorCode from '@/utils/errorCode' |
| 6 | 6 | |
| 7 | 7 | axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' |
| 8 | + | |
| 9 | +// REMOTE_SERVER = http://183.66.242.6:4301/mock/2561/api/siteservice/cs/constructionsites/search | |
| 10 | + | |
| 8 | 11 | // 创建axios实例 |
| 9 | 12 | const service = axios.create({ |
| 10 | 13 | // axios中请求配置有baseURL选项,表示请求URL公共部分 | ... | ... |
trash-ui/src/utils/requestRemote.js
0 → 100644
| 1 | +import axios from 'axios' | |
| 2 | +import { Notification, MessageBox, Message } from 'element-ui' | |
| 3 | +import store from '@/store' | |
| 4 | +import { getToken } from '@/utils/auth' | |
| 5 | +import errorCode from '@/utils/errorCode' | |
| 6 | + | |
| 7 | +axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' | |
| 8 | + | |
| 9 | +// REMOTE_SERVER = http://183.66.242.6:4301/mock/2561/api/siteservice/cs/constructionsites/search | |
| 10 | + | |
| 11 | +// 创建axios实例 | |
| 12 | +const service = axios.create({ | |
| 13 | + // 超时 | |
| 14 | + timeout: 10000 | |
| 15 | +}) | |
| 16 | +// request拦截器 | |
| 17 | +service.interceptors.request.use(config => { | |
| 18 | + // 是否需要设置 token | |
| 19 | + const isToken = (config.headers || {}).isToken === false | |
| 20 | + if (getToken() && !isToken) { | |
| 21 | + config.headers['Authorization'] = 'Bearer auth:token:' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改 | |
| 22 | + } | |
| 23 | + return config | |
| 24 | +}, error => { | |
| 25 | + console.log(error) | |
| 26 | + Promise.reject(error) | |
| 27 | +}) | |
| 28 | + | |
| 29 | +// 响应拦截器 | |
| 30 | +service.interceptors.response.use(res => { | |
| 31 | + // 未设置状态码则默认成功状态 | |
| 32 | + const code = res.data.code || 200; | |
| 33 | + // 获取错误信息 | |
| 34 | + const msg = errorCode[code] || res.data.msg || errorCode['default'] | |
| 35 | + if (code === 401) { | |
| 36 | + MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { | |
| 37 | + confirmButtonText: '重新登录', | |
| 38 | + cancelButtonText: '取消', | |
| 39 | + type: 'warning' | |
| 40 | + } | |
| 41 | + ).then(() => { | |
| 42 | + store.dispatch('LogOut').then(() => { | |
| 43 | + location.href = '/index'; | |
| 44 | + }) | |
| 45 | + }) | |
| 46 | + } else if (code === 500) { | |
| 47 | + Message({ | |
| 48 | + message: msg, | |
| 49 | + type: 'error' | |
| 50 | + }) | |
| 51 | + return Promise.reject(new Error(msg)) | |
| 52 | + } else if (code !== 200) { | |
| 53 | + Notification.error({ | |
| 54 | + title: msg | |
| 55 | + }) | |
| 56 | + return Promise.reject('error') | |
| 57 | + } else { | |
| 58 | + return res.data | |
| 59 | + } | |
| 60 | + }, | |
| 61 | + error => { | |
| 62 | + console.log('err' + error) | |
| 63 | + let { message } = error; | |
| 64 | + if (message == "Network Error") { | |
| 65 | + message = "后端接口连接异常"; | |
| 66 | + } | |
| 67 | + else if (message.includes("timeout")) { | |
| 68 | + message = "系统接口请求超时"; | |
| 69 | + } | |
| 70 | + else if (message.includes("Request failed with status code")) { | |
| 71 | + message = "系统接口" + message.substr(message.length - 3) + "异常"; | |
| 72 | + } | |
| 73 | + Message({ | |
| 74 | + message: message, | |
| 75 | + type: 'error', | |
| 76 | + duration: 5 * 1000 | |
| 77 | + }) | |
| 78 | + return Promise.reject(error) | |
| 79 | + } | |
| 80 | +) | |
| 81 | + | |
| 82 | +export default service | ... | ... |
trash-ui/src/views/business/ConstructionCredit/index.vue
| ... | ... | @@ -198,6 +198,10 @@ |
| 198 | 198 | historyCredit |
| 199 | 199 | } from "@/api/business/credit"; |
| 200 | 200 | |
| 201 | + import { | |
| 202 | + constructionsitesList | |
| 203 | + } from "@/api/dict"; | |
| 204 | + | |
| 201 | 205 | export default { |
| 202 | 206 | name: "ConstructionCredit", |
| 203 | 207 | data() { |
| ... | ... | @@ -273,6 +277,16 @@ |
| 273 | 277 | created() { |
| 274 | 278 | this.getList(); |
| 275 | 279 | this.getNamesData(); |
| 280 | + | |
| 281 | + let query = { | |
| 282 | + 'page':1, | |
| 283 | + 'size':9999, | |
| 284 | + 'creditStatus':0 | |
| 285 | + } | |
| 286 | + | |
| 287 | + constructionsitesList(query).then(response => { | |
| 288 | + console.log(response); | |
| 289 | + }); | |
| 276 | 290 | }, |
| 277 | 291 | methods: { |
| 278 | 292 | getDataInfo(row){ | ... | ... |
trash-ui/vue.config.js