1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import { playAudio } from '@/libs/tools.js'
- module.exports = (vm) => {
-
- uni.$u.http.setConfig((config) => {
-
-
- config.baseURL = 'https://p.iscm.360arrow.com/qpls-md';
- config.custom.auth = true
- return config
- })
-
-
- uni.$u.http.interceptors.request.use((config) => {
-
- config.data = config.data || {}
-
- if(config?.custom?.auth) {
-
- config.header['access-token'] = vm.$store.state.vuex_token
- }
-
- return config
- }, config => {
- return Promise.reject(config)
- })
-
-
- uni.$u.http.interceptors.response.use((response) => {
- const data = response.data
- console.log(data)
-
- const custom = response.config?.custom
- if (data.status != 200) {
-
- if (custom.toast !== false) {
- uni.$u.toast(data.message)
- playAudio("warn")
- }
-
- if (custom?.catch) {
- return Promise.reject(data)
- } else {
-
- return data
- }
- }
- return data === undefined ? {} : data
- }, (response) => {
-
- return Promise.reject(response)
- })
- }
|