123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- import axios from 'axios'
- var serverPath = process.env.SERVER_PATH
- axios.defaults.headers = {
- 'Content-Type': 'application/x-www-form-urlencoded',
- 'Accept': 'application/json'
- }
- axios.defaults.withCredentials = true
- axios.defaults.transformRequest = [
- function(data) {
- var params = ''
- var isFirstParam = true
- for (var k in data) {
- var val = data[k]
- if (typeof val === 'object') {
- val = JSON.stringify(val)
- }
- if (isFirstParam) {
- params += k + '=' + encodeURIComponent(val)
- isFirstParam = false
- } else {
- params += '&' + k + '=' + encodeURIComponent(val)
- }
- }
- return params
- }
- ]
- var post = function(url, params, vue) {
- return axios.post(url, params).catch(error => {
- vue.$message({
- showClose: true,
- message: '网络异常,请坚持网络链接',
- type: 'error'
- })
- }).then(function(res) {
- if (!res || !res.data) {
- throw new Error('error')
- return;
- }
- if (res.data.code !== 0 && vue) {
- if (res.data.code === 103) { //需要登录
- vue.$alert('请重新登陆', '登录失效', {
- confirmButtonText: '确定',
- callback: action => {
- window.location = res.data.msg
- }
- })
- } else {
- vue.$message({
- showClose: true,
- message: res.data.msg,
- type: 'error'
- })
- }
- throw new Error('error')
- } else {
- return res.data
- }
- });
- }
- export default {
- getGoods: (params, vue) => post(`${serverPath}manage/goods`, params, vue),
- getOneGood: (params, vue) => post(`${serverPath}manage/getOneGood`, params, vue),
- editGoodsBase: (params, vue) => post(`${serverPath}manage/editbase`, params, vue),
- setGoodStatus: (params, vue) => post(`${serverPath}manage/setGoodStatus`, params, vue),
- getGoodDescribe: (params, vue) => post(`${serverPath}manage/getGoodDescribe`, params, vue),
- saveGoodDescribe: (params, vue) => post(`${serverPath}manage/saveGoodDescribe`, params, vue),
- getSysLabels: (params, vue) => post(`${serverPath}manage/label/labels`, params, vue),
- getLabel: (params, vue) => post(`${serverPath}manage/label/get`, params, vue),
- saveLabel: (params, vue) => post(`${serverPath}manage/label/save`, params, vue),
- queryAllMUsers: (params, vue) => post(`${serverPath}manage/muser/queryAll`, params, vue),
- setMUserStatus: (params, vue) => post(`${serverPath}manage/muser/setStatus`, params, vue),
- sarchUsers: (params, vue) => post(`${serverPath}manage/muser/sarch`, params, vue),
- addMUser: (params, vue) => post(`${serverPath}manage/muser/add`, params, vue),
- getGoodLabels: (params, vue) => post(`${serverPath}manage/getGoodLabels`, params, vue),
- okLabels: (params, vue) => post(`${serverPath}manage/label/okLabels`, params, vue),
- getPackages: (params, vue) => post(`${serverPath}manage/getPackages`, params, vue),
- bindPackage: (params, vue) => post(`${serverPath}manage/bindPackage`, params, vue),
- setGoodLabels: (params, vue) => post(`${serverPath}manage/setGoodLabels`, params, vue),
- setRecommand: (params, vue) => post(`${serverPath}manage/setRecommand`, params, vue),
- getuser: (params, vue) => post(`${serverPath}manage/muser/getuser`, params, vue),
- getAllFaq: (params, vue) => post(`${serverPath}manage/faq/all`, params, vue),
- geFaq: (params, vue) => post(`${serverPath}manage/faq/get`, params, vue),
- saveFaq: (params, vue) => post(`${serverPath}manage/faq/save`, params, vue),
- getSysConfig: (params, vue) => post(`${serverPath}manage/config/get`, params, vue),
- saveSysConfig: (params, vue) => post(`${serverPath}manage/config/save`, params, vue),
- getAllSysConfig: (params, vue) => post(`${serverPath}manage/config/getAll`, params, vue),
- releaseSysConfig: (params, vue) => post(`${serverPath}manage/config/release`, params, vue),
- bannerList: (params, vue) => post(`${serverPath}manage/banner/list`, params, vue),
- bannerGet: (params, vue) => post(`${serverPath}manage/banner/get`, params, vue),
- bannerSave: (params, vue) => post(`${serverPath}manage/banner/save`, params, vue),
- bannerSetStatus: (params, vue) => post(`${serverPath}manage/banner/setstatus`, params, vue),
- loginout: (params, vue) => post(`${serverPath}help/loginout`, params, vue),
- }
|