c1
This commit is contained in:
229
www/first.loc/store/ApiClass.js
Normal file
229
www/first.loc/store/ApiClass.js
Normal file
@@ -0,0 +1,229 @@
|
||||
import axios from "axios";
|
||||
|
||||
export const ApiClass ={
|
||||
state: {
|
||||
auth:false,
|
||||
kag:null,
|
||||
kagArr:[
|
||||
{firma:0,name:'Беру Яндекс (ТД БММ)','kag': 217445,'barcode_length':8},
|
||||
{firma:1,name:'Озон_1 (ТД БММ)','kag': 219807,'barcode_length':15 },
|
||||
{firma:2,name:'Озон_2 (bmm.ru,ОК-Книга)','kag': 225202,'barcode_length':15},
|
||||
{firma:3,name:'Озон_3 (Терминал-книга)','kag': 225645,'barcode_length':15},
|
||||
{firma:4,name:'Озон_4 (МногоКниг)','kag': 226683,'barcode_length':15},
|
||||
{firma:5,name:'Озон_5 (Книгариум)','kag': 228681,'barcode_length':15},
|
||||
{firma:6,name:'Озон_6 (СмартБук)','kag': 229077,'barcode_length':15},
|
||||
{firma:7,name:'Озон_7 (Дом Историй)','kag': 236185,'barcode_length':15},
|
||||
{firma:8,name:'Озон_8_FBS (Руграм)','kag': 238376,'barcode_length':15},
|
||||
],
|
||||
|
||||
|
||||
data:null,
|
||||
url_api:'https://tsd.book-online.ru',
|
||||
},
|
||||
getters: {
|
||||
},
|
||||
mutations: {
|
||||
setAuth(state,result){
|
||||
state.auth=result
|
||||
},
|
||||
setUser(state,result){
|
||||
state.user=result
|
||||
},
|
||||
dataSet(state,result){
|
||||
state.data=result;
|
||||
},
|
||||
kagSet(state,result){
|
||||
state.kag=result;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
|
||||
|
||||
async loadData({state, commit}, param) {
|
||||
try {
|
||||
|
||||
//let json='';
|
||||
// if(param.json){
|
||||
let json=JSON.stringify(param.json);
|
||||
//}
|
||||
|
||||
let response=null;
|
||||
let headers= {};
|
||||
|
||||
// if(typeof localStorage.token!=='undefined'){
|
||||
// headers.Authorization='token '+localStorage.token;
|
||||
// }
|
||||
if(param.method==='post'){
|
||||
headers['Content-Type']='application/json';
|
||||
}
|
||||
|
||||
if(param.method==='put'){
|
||||
headers['Content-Type']='application/json';
|
||||
}
|
||||
if(param.method==='get'){
|
||||
json={};
|
||||
}
|
||||
|
||||
|
||||
response = await axios[param.method](param.url,json,{headers:headers});
|
||||
|
||||
//console.log(response.data);
|
||||
return response.data;
|
||||
} catch (e) {
|
||||
|
||||
//console.log(e);
|
||||
return e;
|
||||
} finally {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
async queryApi({state, commit}, param) {
|
||||
try {
|
||||
|
||||
|
||||
const json = JSON.stringify({
|
||||
data: JSON.stringify(param),
|
||||
});
|
||||
|
||||
|
||||
const response = await axios.post(state.url_api+'/api/queryMainPost.php',json,{
|
||||
headers: {'Content-Type': 'application/json'}
|
||||
});
|
||||
|
||||
console.log(response.data);
|
||||
//commit('dataSet',response.data );
|
||||
|
||||
return response.data;
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
async postingStatus({state, commit}, param) {
|
||||
try {
|
||||
|
||||
|
||||
const json = JSON.stringify({
|
||||
data: JSON.stringify(param),
|
||||
});
|
||||
|
||||
|
||||
const response = await axios.post(state.url_api+'/api/posting_status.php',json,{
|
||||
headers: {'Content-Type': 'application/json'}
|
||||
});
|
||||
|
||||
console.log(response.data);
|
||||
//commit('dataSet',response.data );
|
||||
|
||||
return response.data;
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
async getCollect({state, commit}, param) {
|
||||
try {
|
||||
|
||||
|
||||
const json = JSON.stringify({
|
||||
data: JSON.stringify(param),
|
||||
});
|
||||
|
||||
|
||||
const response = await axios.post(state.url_api+'/api/getCollect.php',json,{
|
||||
headers: {'Content-Type': 'application/json'}
|
||||
});
|
||||
|
||||
//console.log(response.data);
|
||||
commit('dataSet',response.data );
|
||||
return response.data;
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
async queryHistory({state, commit}, param) {
|
||||
//let error=new Event('error');
|
||||
|
||||
try {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// console.log(param);
|
||||
const json = JSON.stringify({
|
||||
data: JSON.stringify(param),
|
||||
});
|
||||
|
||||
|
||||
const response = await axios.post(state.url_api+'/api/queryHistory.php',json,{
|
||||
headers: {'Content-Type': 'application/json'}
|
||||
});
|
||||
|
||||
// console.log(response.data);
|
||||
commit('dataSet',response.data.data );
|
||||
return response.data;
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
async pushCollect({state, commit}, param) {
|
||||
try {//добавить в сборку баркод
|
||||
|
||||
|
||||
const json = JSON.stringify({
|
||||
data: JSON.stringify(param),
|
||||
});
|
||||
|
||||
|
||||
const response = await axios.post(state.url_api+'/api/pushCollect.php',json,{
|
||||
headers: {'Content-Type': 'application/json'}
|
||||
});
|
||||
|
||||
// console.log(response.data);
|
||||
|
||||
return response.data;
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
} finally {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
modules: {
|
||||
},
|
||||
|
||||
namespaced: true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user