Files
tsd_test/www/first.loc/store/ApiClass.js
adminps_pv 4df494767b
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 6m48s
c4
2026-03-25 14:11:55 +00:00

230 lines
5.7 KiB
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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
}