import { get, post, CITY_SERVICE, PUBLISH_SERVICE } from '@/services/index';
import qs from 'qs';

/** ***网站配置*** */
// 七参数初始化
export const getSevenParams = () =>
  get(`${CITY_SERVICE}/OMS.svc/M_GetSevenParams`, {
    _version: 9999,
    _dc: new Date().getTime(),
  });
// 根据转换类型获取七参数
export const getSevenParamsByTransType = value =>
  get(`${CITY_SERVICE}/OMS.svc/M_GetSevenParamsByTransType`, {
    _version: 9999,
    _dc: new Date().getTime(),
    transType: value,
  });
// 提交七参数
export const postSevenParams = sevenFormData =>
  post(`${CITY_SERVICE}/OMS.svc/M_SetSevenParams?_version=9999`, qs.stringify(sevenFormData), {
    headers: {
      'content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    },
  });

/** ***菜单管理*** */
// 获取菜单树
export const getTree = () =>
  get(`${CITY_SERVICE}/OMS.svc/MiniAppSiteTree`, {
    _version: 9999,
    _dc: new Date().getTime(),
    node: -2,
    userMode: 'super',
    // subSystemValue: '手持系统',
    // subSystemName: '手持系统',
    select: '',
  });
// 添加菜单
export const addMenuApi = (menuID, menuName, shortName, imageUrl, pageUrl, funParam) =>
  get(`${CITY_SERVICE}/OMS.svc/MiniApp_AddMenu`, {
    _version: 9999,
    _dc: new Date().getTime(),
    parentID: menuID,
    menuName,
    shortName,
    imageUrl,
    pageUrl,
    funParam,
    subSystemValue: 'miniapp',
    relatedRoleList: '',
  });
// 添加菜单组
export const addMenuGroupApi = (menuID, menuName, shortName, imageUrl, offlineImgUrl, funParam) =>
  get(`${CITY_SERVICE}/OMS.svc/MiniApp_AddMenu`, {
    _version: 9999,
    _dc: new Date().getTime(),
    // 根目录添加，parentID 为-1
    parentID: menuID || -1,
    menuName,
    shortName,
    imageUrl,
    offlineImgUrl,
    funParam,
    subSystemValue: 'miniapp',
    relatedRoleList: '',
  });
// 获取角色列表
export const getRoleList = () =>
  get(`${CITY_SERVICE}/OMS.svc/P_GetRoleListPlain`, {
    _version: 9999,
    _dc: new Date().getTime(),
    subSystemValue: 'miniapp',
  });
// 编辑-获取菜单
export const getMenuInfo = id =>
  get(`${PUBLISH_SERVICE}/PlatformCenter/Mini_GetMenuInfo`, {
    menuID: id,
  });
// 编辑-提交菜单
export const submitMenuInfo = params => get(`${CITY_SERVICE}/OMS.svc/MiniApp_EditMenu`, params);
// 删除菜单
export const deleteMenuApi = id =>
  get(`${CITY_SERVICE}/OMS.svc/MiniApp_DeleteMenu`, {
    _version: 9999,
    _dc: new Date().getTime(),
    menuID: id,
    subSystemValue: 'miniapp',
  });
// 获取当前服务器上最新的apk包名和更新时间
export const getApkNameAndDate = params =>
  get(`/Cityinterface/Services/CityServer_MobileBusiness/REST/BaseREST.svc/AppModifyTime`, params);
// 上传apk版本信息以及apk包的接口
export const SaveMobileApk = params => post(`/Publish/OMS/FileCenter/SaveMobileApk`, params);
