123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- //测试地址
- //const baseURL2 = 'http://192.168.0.125:20134/'
- //const baseURL='http://wiper.66km.com.cn/'
- const baseURL='https://wiper.66km.com.cn/'
- //66正式
- /* const baseURL = 'https://apidms.66km.com/'
- const burl2='https://apidms.66km.com/' */
- //欧洲维修
- //const baseURL = 'http://oil.66km.com.cn/'
- // const burl2='http://edms.eurorepar.cn/ '
- // import md5 from './MD5.js'
-
- const ajax = (url = '', date = {}, type = 'POST', header = {
- }) => {
- return new Promise((resolve, reject) => {
- header={};
-
- header['Content-Type']='application/x-www-form-urlencoded';
- //console.log(header)
- uni.request({
- method: type,
- url: 'http://api.dms.66km.com.cn/' + url,
- data: date,
- header: header,
- dataType: 'json',
- }).then((response) => {
- console.log(response)
- //let [error, res] = response;
-
- resolve(response.data);
- }).catch(error => {
- let [err, res] = error;
- reject(err)
- })
- });
- }
-
- var that=this;
- const http = (url = '', date = {}, type = 'POST', header = {
- }) => {
- return new Promise((resolve, reject) => {
- header={};
-
- if(uni.getStorageSync("wxdata")){
- //console.log(uni.getStorageSync("wxdata"))
- var openId = uni.getStorageSync("wxdata").openid;
- }else{
- var openId = '';
- }
-
- //console.log(that.$store)
- //header['token']='98A9FED8814B457288166BDF623F33D1';
- header['openId']=openId;
- header['Content-Type']='application/x-www-form-urlencoded';
- console.log(baseURL + url)
- uni.request({
- method: type,
- url: baseURL+'search?action=' + url,
- data: date,
- header: header,
- dataType: 'json',
- }).then((response) => {
- //console.log(response)
- //let [error, res] = response;
- if(response.data.code!=0){
- //console.log('??')
- uni.showToast({
- title: response.data.msg,
- icon:'none',
- duration: 4000,
- });
- }
- resolve(response.data);
- // resolve(res.data);
- }).catch(error => {
- let [err, res] = error;
- reject(err)
- })
- });
- }
- const http3 = (url = '', date = {}, type = 'POST', header = {
- }) => {
- return new Promise((resolve, reject) => {
- header={};
- if(uni.getStorageSync("wxdata")){
- var openId = uni.getStorageSync("wxdata").openid;
- }else{
- var openId = '';
- }
-
- header['openId']=openId;
- header['Content-Type']='application/x-www-form-urlencoded';
- console.log(baseURL + url)
- uni.request({
- method: type,
- //url: baseURL2+'search?action=' + url,
- url: baseURL + url,
- data: date,
- header: header,
- dataType: 'json',
- }).then((response) => {
-
- if(response.data.code!=0){
-
- uni.showToast({
- title: response.data.msg,
- icon:'none',
- duration: 4000,
- });
- }
- resolve(response.data);
-
- }).catch(error => {
- let [err, res] = error;
- reject(err)
- })
- });
- }
- const http2 = (url = '', date = {}, type = 'POST', header = {
- }) => {
- return new Promise((resolve, reject) => {
- header={};
- if(uni.getStorageSync("wxdata")){
- //console.log(uni.getStorageSync("wxdata"))
- var openId = uni.getStorageSync("wxdata").openid;
- }else{
- var openId = '';
- }
- header['openId']=openId;
- header['Content-Type']='application/x-www-form-urlencoded';
- //console.log(baseURL + url)
- uni.request({
- method: type,
- url: baseURL + url,
- data: date,
- header: header,
- dataType: 'json',
- }).then((response) => {
- //console.log(response)
- //let [error, res] = response;
- if(response.data.code!=0){
- //console.log('??')
- uni.showToast({
- title: response.data.msg,
- icon:'none',
- duration: 4000,
- });
- }
- resolve(response.data);
- // resolve(res.data);
- }).catch(error => {
- let [err, res] = error;
- reject(err)
- })
- });
- }
- function refresh(url,date,type,header){
- uni.request({
- method: type,
- url: baseURL + url,
- data: date,
- header: header,
- dataType: 'json',
- }).then((response) => {
- setTimeout(function() {
- uni.hideLoading();
- }, 200);
- let [error, res] = response;
-
- if(res.data.code==403){
- uni.showToast({
- title: res.data.msg,
- icon:'none',
- duration: 3000,
- });
-
- }
- resolve(res.data);
- }).catch(error => {
- let [err, res] = error;
- reject(err)
- })
- }
- export default {
- http,baseURL,ajax,http2,http3
- }
|