import Vue from 'vue'
import axios from 'axios'
import VueAxios from 'vue-axios'
Vue.use(VueAxios, axios)

export const request = (params, showLoding) => {
  let resp;
  /*是否提示加载*/
  if (showLoding && showLoding.show)
    // Utils.loading(true, showLoding.text);
  /*必须参数*/
  params = Utils.filterNull(params);
  if (!params.userid)
    params.userid = Vue.utils.loadLocal(config.signKey, key.USERID, '') || '';
  if (!params.YYBM)
    params.YYBM = Vue.utils.loadLocal(config.signKey, key.USER, {}).JGBH || '';
  if (!params.usertype)
    params.usertype = Vue.utils.loadLocal(config.signKey, key.USER, {}).Rylx || '';
  /*参数格式化*/
  let xmlstr = '';
  if (params) {
    xmlstr = '{';
    let f = true;
    for (let it in params) {
      if (f) {
        xmlstr += '"' + it + '":"' + params[it] + '"';
        f = false;
      } else {
        xmlstr += ',"' + it + '":"' + params[it] + '"';
      }
    }
    xmlstr += '}';
  }
  /* 开始请求*/
  const p = new Promise((resolve, reject) => {
    Vue.axios.post(API_RESOURCE.site + API_RESOURCE.action, {xmlstr: xmlstr}, {
      emulateJSON: true
      // , credentials: true
    }).then(res => {
      if (res.body.error == 0) {
        resolve(res.body);
      } else {
        // Vue.utils.toast(res.body.msg);
      }
      /*隐藏加载*/
      // Vue.utils.loading(false);
    }, function (err) {
      reject("访问失败");
    });
  }).catch(err => {
    if (err && err.msg) {
      // Vue.utils.toast(err.msg);
    } else {
      // Vue.utils.toast(err);
    }
    return null;
  });
  return p;
}
/*请求配置*/
export const config = {
  // site: 'http://192.168.1.131:8080/',
  // site: 'http://couldserver.chinacloudapp.cn:1882/',
  site: 'http://couldserver.chinacloudapp.cn:1882/',
  // imgHost: 'http://couldserver.chinacloudapp.cn:1882/',
  imgHost: 'http://appjmzserver.chinacloudapp.cn:8080/',
  action: 'Jyz_Data_I/jyz_Action',
  signKey: 'zyt999',
  logintype: 0,
}

export const YWID = {
  /*微信配置*/
  weChat: '5003',
  /*登录*/
  signIn: '1003',
  /*静默登录*/
  autoSignIn: '1003',
  /*注册*/
  signUp: '1002',
  /*找回密码*/
  retrieve: '1032',
  /*注册获取验证码*/
  codeZC: '1001',
  /*找回密码获取验证码*/
  codePSW: '1031',
  /*修改信息*/
  edit: '1023',
  /*概况*/
  introduce: '3001',
  /*概况统计图*/
  introduceChart: '3002',
  /*各科室收入列表*/
  ksIncomeList: '4011',
  /*室收入统计图*/
  ksIncomeChart: '4041',
  /*科室内个医生收入列表*/
  docIncomeList: '4051',
  /*科室内个医生收入列表*/
  docIncomeChart: '4061',
  /*反馈*/
  feedback: '4098',
  /*签到*/
  QD: '9003',
}

export const keys = {
  USER: 'u0',
  USERID: 'u1',
  LOCATION: 'l0',
  LAT: 'l1',
  LNG: 'l2',
  UNREADNUM: 'u3',
  CODE: 'c0',
}


@@ -1566,19 +1566,16 @@
 ig = %7B%0A 
- //
  site: '
@@ -1609,222 +1609,38 @@
 ,%0A  
-// site: 'http://couldserver.chinacloudapp.cn:1882/',%0A  site: 'http://couldserver.chinacloudapp.cn:1882/',%0A  // imgHost: 'http://couldserver.chinacloudapp.cn:1882/',%0A  imgHost: 'http://appjmzserver.chinacloudapp.cn
+imgHost: 'http://192.168.1.131
 :808
@@ -1695,14 +1695,8 @@
 y: '
-zyt999
 ',%0A 
@@ -1739,530 +1739,8 @@
 = %7B%0A
-  /*%E5%BE%AE%E4%BF%A1%E9%85%8D%E7%BD%AE*/%0A  weChat: '5003',%0A  /*%E7%99%BB%E5%BD%95*/%0A  signIn: '1003',%0A  /*%E9%9D%99%E9%BB%98%E7%99%BB%E5%BD%95*/%0A  autoSignIn: '1003',%0A  /*%E6%B3%A8%E5%86%8C*/%0A  signUp: '1002',%0A  /*%E6%89%BE%E5%9B%9E%E5%AF%86%E7%A0%81*/%0A  retrieve: '1032',%0A  /*%E6%B3%A8%E5%86%8C%E8%8E%B7%E5%8F%96%E9%AA%8C%E8%AF%81%E7%A0%81*/%0A  codeZC: '1001',%0A  /*%E6%89%BE%E5%9B%9E%E5%AF%86%E7%A0%81%E8%8E%B7%E5%8F%96%E9%AA%8C%E8%AF%81%E7%A0%81*/%0A  codePSW: '1031',%0A  /*%E4%BF%AE%E6%94%B9%E4%BF%A1%E6%81%AF*/%0A  edit: '1023',%0A  /*%E6%A6%82%E5%86%B5*/%0A  introduce: '3001',%0A  /*%E6%A6%82%E5%86%B5%E7%BB%9F%E8%AE%A1%E5%9B%BE*/%0A  introduceChart: '3002',%0A  /*%E5%90%84%E7%A7%91%E5%AE%A4%E6%94%B6%E5%85%A5%E5%88%97%E8%A1%A8*/%0A  ksIncomeList: '4011',%0A  /*%E5%AE%A4%E6%94%B6%E5%85%A5%E7%BB%9F%E8%AE%A1%E5%9B%BE*/%0A  ksIncomeChart: '4041',%0A  /*%E7%A7%91%E5%AE%A4%E5%86%85%E4%B8%AA%E5%8C%BB%E7%94%9F%E6%94%B6%E5%85%A5%E5%88%97%E8%A1%A8*/%0A  docIncomeList: '4051',%0A  /*%E7%A7%91%E5%AE%A4%E5%86%85%E4%B8%AA%E5%8C%BB%E7%94%9F%E6%94%B6%E5%85%A5%E5%88%97%E8%A1%A8*/%0A  docIncomeChart: '4061',%0A  /*%E5%8F%8D%E9%A6%88*/%0A  feedback: '4098',%0A  /*%E7%AD%BE%E5%88%B0*/%0A  QD: '9003',%0A
 %7D%0A%0Ae

Update index.js