sampleapply.js
1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import Vue from 'vue'
import {Toast} from 'vant';
import {services as Services} from '../../../api/index'
import Util from "../../../util";
var qs = require('qs');
Vue.use(Toast);
const state = {
loading: false,
addressInfo:"",
submitState:false
}
const mutations = {
recvlistSample(state, payload) {
state.addressInfo=payload.data.filter(function(item){return item['is_default'] == 1;});
state.addressInfo=state.addressInfo[0];
},
}
const actions = {
recvlistSample({commit}, payload) {
Services.recvlist().then((res) => {
let data = res.data;
state.loading = false;
if (data.err_code == 0) {
commit({
type: 'recvlistSample',
data: data.data
});
}
}).catch(function (err) {
});
},
selfSampleCreate({commit}, payload) {
state.loading = true;
var params = {
goods_id: payload.goods_id,
apply_num: payload.apply_num,
com_name: payload.com_name,
sample_demand_desc: payload.sample_demand_desc,
address_id: payload.address_id
}
Services.selfSampleCreate(qs.stringify(params)).then((res) => {
let data = res.data;
state.loading = false;
if (data.err_code == 0) {
state.submitState=true;
}else{
Toast(data.err_msg);
}
}).catch(function (err) {
state.loading = false;
});
},
}
const getters = {}
export default {
state,
mutations,
actions,
getters
}