租房小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
684 B

8 months ago
7 months ago
7 months ago
7 months ago
8 months ago
7 months ago
8 months ago
  1. /**
  2. * 响应拦截
  3. * @param {Object} http
  4. */
  5. export const responseInterceptors = (vm) => {
  6. uni.$uv.http.interceptors.response.use((response) => { /* 对响应成功做点什么 可使用async await 做异步操作*/
  7. const data = response.data
  8. if (data.code == 200) {
  9. return Promise.resolve(data);
  10. }else if(data.code === 500){
  11. uni.navigateTo({
  12. url:"/pages/auth/index"
  13. })
  14. return;
  15. }else{
  16. uni.$uv.toast(data.message)
  17. return Promise.reject(data)
  18. }
  19. }, (response) => { /* 对响应错误做点什么 (statusCode !== 200)*/
  20. console.info('interceptors.response---------',data)
  21. return Promise.reject(response)
  22. })
  23. }