import request from './request.js' class agriknow { constructor() { this._baseUrl = 'http://XXXX.XXXX.com/XXX/XX' this._defaultHeader = { 'Content-Type': 'application/json' } this._request = new request this._request.setErrorHandler(this.errorHander) } /** * 统一的异常处理方法 */ errorHander(res) { console.error(res) } /** * 查询测试选项答案 */ getAnswer(id) { let data = {id: id}; return this._request.getRequest(this._baseUrl + 'XXXX/XXX', data).then(res => res.data) } /** * 查询所有的测试列表 */ getNews() { return this._request.getRequest(this._baseUrl +'XXX/XXX').then(res => res.data) } /** * 查询测试问题 */ getNewsDetails(id, url = 'program/details') { let data = {id:id}; return this._request.getRequest(this._baseUrl + url, data).then(res =>res.data) } /** * 保存图片 */ getCreateimg(url) { let data = {url: url} return this._request.getRequest(this._baseUrl + 'XXX/XXX', data).then(res => res.data) } } export default agriknow