12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- //测试地址
- const baseUrl = 'http://dms.66km.com.cn/'
- //const baseUrl = 'http://192.168.0.14:20187/'
- //正式地址
- const http = (url = '', date = {}, type = 'POST', header = {
- }) => {
- return new Promise((resolve, reject) => {
- header={};
- var token=uni.getStorageSync('token')
- header['token']=token;
- if(url=='enterprise/wechat/extCustomerMobile'){
- header['Content-Type']='application/x-www-form-urlencoded';
- }else{
- header['Content-Type']='application/json;charset=utf-8';
- }
-
- uni.request({
- method: type,
- url: baseUrl + url,
- data: date,
- header: header,
- dataType: 'json',
- }).then((response) => {
- // console.log(response.data.code)
- //console.log(response.data.data.code)
- //let [error, res] = response;
- // console.log(res)
- /* if(res.data.code==401||res.data.code==403){
-
- uni.clearStorageSync()
-
- }else if(res.data.code==409){
- // getToken(url,date,type,header)
- } */
- /* if(response.data.data.code!=1){
- console.log(res.data.data.msg)
- uni.hideLoading();
- uni.clearStorageSync()
- uni.showToast({
- title: res.data.data.msg,
- icon: 'none',
- duration: 3000
- });
- } */
- /* if(response.data.code!=1){
- //console.log(res.data.msg)
- uni.hideLoading();
- //uni.clearStorageSync()
- uni.showToast({
- title: response.data.msg,
- icon: 'none',
- duration: 3000
- });
- }else{
-
- } */
- resolve(response.data);
-
- }).catch(error => {
- let [err, res] = error;
- reject(err)
- })
- });
- }
- export default {
- http
- }
|