import Http from './http' import Apis from './api' import ProvinceJson from '../constants/provinceCity' //存session export const storageSave = (key, value) => { sessionStorage.setItem(key, JSON.stringify(value)) } //取session export const storageGet = (key) => { // return new Promise((resolve) => { // resolve(JSON.parse(sessionStorage.getItem(key))) // }) return JSON.parse(sessionStorage.getItem(key)) } //获取用户id export const getUserIdentity = () => { return Http.get(Apis.USER.GET_USER_IDENTITY) } //获取所有测评能力 export const getAllAbilities = () => { return ['接口测试', '兼容性测试', '可靠性测试', '稳定性测试', '功能测试', '性能测试', '安全测试','易用性测试', '应用故障诊断', '应用漏洞扫描', '代码安全审计', '风险评估', '等保测评', '评估评价', '定制测试'] //return Http.get(Apis.GENERAL.GET_ALL_ABILITIES) } //获取所有测评资源种类 export const getAllAgencyResourceTypes = () => { return ['人力资源', '服务器资源', '专用设备'] //return Http.get(Apis.GENERAL.GET_ALL_ABILITIES) } //获取所有服务类型 export const getAllServiceTypes = () => { const data = ['接口测试', '兼容性测试', '可靠性测试', '稳定性测试', '功能测试', '性能测试', '安全测试','易用性测试', '应用故障诊断', '应用漏洞扫描', '代码安全审计', '风险评估', '等保测评', '评估评价', '定制测试'] return new Promise((resolve) => { resolve(data) }) //return Http.get(Apis.GENERAL.GET_ALL_ABILITIES) } //获取所有报告类型 export const getAllReportTypes = () => { const data = ['可行性报告', '测试方案', '测试报告', '缺陷报告', '用例报告', '其他'] return new Promise((resolve) => { resolve(data) }) //return Http.get(Apis.GENERAL.GET_ALL_ABILITIES) } //获取所有平台类型 export const getAllPlatformTypes = () => { return ['Android APP', 'IOS APP', 'Web应用', 'C/S应用软件', '嵌入式软件', '工业控制软件', '信息技术产品', '其他'] // return Http.get(Apis.GENERAL.GET_ALL_ApplicationType) } export const getAllFields = () => { return ['科技服务', '互联网服务', '集成电路', '工业控制', '北斗应用', '其他'] } //获取所有定向发布的目标 export const getAllInstitutions = () => { return Http.get(Apis.GENERAL.GET_ALL_INSTITUTIONS) } //获取所有测评机构 export const getAllAgencies = () => { // const data = [{ // id: 1, // name: '慕测' // }, { // id: 2, // name: '南大' // }] // // return new Promise((resolve) => { // resolve(data) // }) return Http.get(Apis.GENERAL.GET_ALL_AGENCIES) } //通过代码获取省、市名称 export const getProvinceNameByProvinceCode = (provinceCode, cityCode) => { for (var i = 0; i < ProvinceJson.provinces.length; i++) { if (ProvinceJson.provinces[i].code == provinceCode) { for (var j = 0; j < ProvinceJson.provinces[i].cities.length; j++) { if (ProvinceJson.provinces[i].cities[j].code == cityCode) { return { 'provinceCode': ProvinceJson.provinces[i].name, 'cityCode': ProvinceJson.provinces[i].cities[j].name } } } } } // return { // 'provinceCode': '江苏省', // 'cityCode': '南京市' // } } //通过名称获取省、市代码 export const getProvinceCodeByProvinceName = (provinceName, cityName) => { for (var i = 0; i < ProvinceJson.provinces.length; i++) { if (ProvinceJson.provinces[i].name == provinceName) { for (var j = 0; j < ProvinceJson.provinces[i].cities.length; j++) { if (ProvinceJson.provinces[i].cities[j].name == cityName) { return { 'provinceCode': ProvinceJson.provinces[i].code, 'cityCode': ProvinceJson.provinces[i].cities[j].code } } } } } // return { // 'provinceCode': '3200', // 'cityCode': '3201' // } } //获取批量上传项目模板文件 export const getGreenChannelAddProjectExcelTemplateFile = (getTemplateExcelSuccess, getTemplateExcelFail) => { const data = { fileUrl: 'http://mooctest-crowd-service.oss-cn-hangzhou.aliyuncs.com/Others/%E9%A1%B9%E7%9B%AE%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx' } new Promise((resolve) => { resolve(data) }).then((res) => { getTemplateExcelSuccess(res) }).catch((error) => { getTemplateExcelFail(error) }) // Http.get(Apis.FILE.GET_TEMPLATE_EXCEL_FILE).then((res) => { // getTemplateExcelSuccess(res) // }).catch((error) => { // getTemplateExcelFail(error) // }) } Date.prototype.Format = function (fmt) { var o = { 'M+': this.getMonth() + 1, //月份 'd+': this.getDate(), //日 'h+': this.getHours(), //小时 'm+': this.getMinutes(), //分 's+': this.getSeconds(), //秒 'q+': Math.floor((this.getMonth() + 3) / 3), //季度 'S': this.getMilliseconds() //毫秒 } if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length)) for (var k in o) { if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length))) } return fmt } export const getFormalTimeFromDate = (date) => { return date.Format('yyyy-MM-dd hh:mm:ss') } // export const getIndexStatisticsInfo = () => { const data = { userNum: 100, agencyNum: 200, deviceNum: 345, projectNum: 23, taskNum: 123 } return new Promise((resolve) => { resolve(data) }) }