| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- // const base_url = 'https://api.xyyxt.net' //release
- // const base_url = 'http://42.192.164.187:19005' //test
- export const base_url = 'http://api.xyyxt.net:19009' //预发布
- // const base_url = 'http://192.168.1.222:5055' //dev
- // export const BASE_IMG_URL = 'https://file.xyyxt.net/' //release
- export const BASE_IMG_URL = 'https://file-dev.xyyxt.net/' //test
- const tenantId = '867735392558919680'
- export const http = (option) => {
- if(option.loading) {
- uni.showLoading({
- mask:true,
- title: '拼命加载中...'
- })
- }
-
- return new Promise((resolve,reject) => {
- let token = uni.getStorageSync('token')
- uni.request({
- url:base_url + option.url,
- data:option.data,
- method:option.method || 'get',
- header: {
- TenantId:tenantId,
- // 'Content-Type': 'application/json',
- AuthorizationToken: token ? 'WX '+ token : '',
- },
- success: (res) => {
- if (res.data.code == 401) {
- uni.removeStorageSync('user_account')
- }
- resolve(res)
- },
- fail: (err) => {
- uni.showToast({
- title: "请求接口失败",
- icon: 'none'
- })
- reject(JSON.stringify(err))
- },
- complete: () => {
- uni.hideLoading()
- }
- })
- })
- }
|