Commit df3b4f8b by liangjianmin

js

parent 29299268
......@@ -8,93 +8,105 @@ var qs = require('qs');
Vue.use(Toast);
const state = {
loading: false,
addressInfo:"",
submitState:false,
ypGoodDetail:{},
ypComInfo:{},
ypBasInfo:{},
ordernum:''
loading: false,
addressInfo: "",
submitState: false,
ypGoodDetail: {},
ypComInfo: {},
ypBasInfo: {},
ordernum: ''
}
const mutations = {
recvlistSample(state, payload) {
if(!payload.data){
state.addressInfo = null
}else{
state.addressInfo=payload.data.filter(function(item){return item['is_default'] == 1;});
state.addressInfo=state.addressInfo[0];
}
},
recvlistSample(state, payload) {
if (!payload.data) {
state.addressInfo = null
} else {
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;
console.log(data.err_code)
if (data.err_code == 0) {
commit({
type: 'recvlistSample',
data: data.data
});
}else{
commit({
type: 'recvlistSample',
data: null
});
}
}).catch(function (err) {
recvlistSample({commit}, payload) {
Services.recvlist().then((res) => {
let data = res.data;
// state.loading = false;
console.log(data.err_code)
if (data.err_code == 0) {
commit({
type: 'recvlistSample',
data: data.data
});
},
selfSampleCreate({commit}, payload) {
state.loading = true;
var params = payload.data;
Services.selfSampleCreate(qs.stringify(params)).then((res) => {
let data = res.data;
state.loading = false;
if (data.err_code == 0) {
state.submitState=true;
state.ordernum = data.data||''
}else if(data.err_code == '40014'){
Toast('样品库存不足');
}else{
Toast(data.err_msg);
}
}).catch(function (err) {
state.loading = false;
});
},
getDetailYp({commit}, payload) {
state.loading = true;
let Params_ = {
id: payload.data.id,
}
let params = Util.getParams(Params_);
Services.getSampleInfo(params).then((res) => {
let data = res.data;
state.loading = false;
if (data.err_code == 0) {
state.ypGoodDetail = data.data.goods_info||{}
state.ypComInfo = data.data.company_info||{}
state.ypBasInfo = data.data.user_info||{}
}
}).catch(function (err) {
state.loading = false;
} else {
commit({
type: 'recvlistSample',
data: null
});
},
}
}).catch(function (err) {
});
},
selfSampleCreate({commit}, payload) {
state.loading = true;
var params = payload.data;
Services.selfSampleCreate(qs.stringify(params)).then((res) => {
let data = res.data;
state.loading = false;
if (data.err_code == 0) {
state.submitState = true;
state.ordernum = data.data || ''
} else if (data.err_code == '40014') {
Toast('样品库存不足');
} else {
Toast(data.err_msg);
}
}).catch(function (err) {
state.loading = false;
});
},
getDetailYp({commit}, payload) {
state.loading = true;
if (payload.data.type) {
let Params_ = {
id: payload.data.id,
type: 2
}
} else {
let Params_ = {
id: payload.data.id,
}
}
let params = Util.getParams(Params_);
Services.getSampleInfo(params).then((res) => {
let data = res.data;
state.loading = false;
if (data.err_code == 0) {
state.ypGoodDetail = data.data.goods_info || {}
state.ypComInfo = data.data.company_info || {}
state.ypBasInfo = data.data.user_info || {}
}
}).catch(function (err) {
state.loading = false;
});
},
}
const getters = {}
export default {
state,
mutations,
actions,
getters
state,
mutations,
actions,
getters
}
......@@ -230,16 +230,30 @@
this.isShowComInfo = true;
}
}
this.$store.dispatch({
type: "getDetailYp",
data: {
type:'spacial',
id: this.goods_id
}
});
}else {
this.$store.dispatch({
type: "getDetailYp",
data: {
id: this.goods_id
}
});
}
this.$store.dispatch({
type: "getDetailYp",
data: {id: this.goods_id},
});
this.$store.dispatch({
type: "recvlistSample",
});
//这里把项目需求的描述放到缓存里面,切换页面的时候缓存起来
let sampledesccookie = localStorage.getItem("sampledesc") || "";
if (sampledesccookie) {
......
......@@ -4530,7 +4530,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var core
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ \"./node_modules/_vue@2.6.11@vue/dist/vue.runtime.esm.js\");\n/* harmony import */ var vant__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! vant */ \"./node_modules/_vant@2.9.3@vant/es/index.js\");\n/* harmony import */ var _api_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../api/index */ \"./src/api/index.js\");\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../util */ \"./src/util/index.js\");\n\n\n\n\n\nvar qs = __webpack_require__(/*! qs */ \"./node_modules/_qs@6.9.4@qs/lib/index.js\");\n\nvue__WEBPACK_IMPORTED_MODULE_0__[\"default\"].use(vant__WEBPACK_IMPORTED_MODULE_1__[\"Toast\"]);\nvar state = {\n loading: false,\n addressInfo: \"\",\n submitState: false,\n ypGoodDetail: {},\n ypComInfo: {},\n ypBasInfo: {},\n ordernum: ''\n};\nvar mutations = {\n recvlistSample: function recvlistSample(state, payload) {\n if (!payload.data) {\n state.addressInfo = null;\n } else {\n state.addressInfo = payload.data.filter(function (item) {\n return item['is_default'] == 1;\n });\n state.addressInfo = state.addressInfo[0];\n }\n }\n};\nvar actions = {\n recvlistSample: function recvlistSample(_ref, payload) {\n var commit = _ref.commit;\n _api_index__WEBPACK_IMPORTED_MODULE_2__[\"services\"].recvlist().then(function (res) {\n var data = res.data; // state.loading = false;\n\n console.log(data.err_code);\n\n if (data.err_code == 0) {\n commit({\n type: 'recvlistSample',\n data: data.data\n });\n } else {\n commit({\n type: 'recvlistSample',\n data: null\n });\n }\n }).catch(function (err) {});\n },\n selfSampleCreate: function selfSampleCreate(_ref2, payload) {\n var commit = _ref2.commit;\n state.loading = true;\n var params = payload.data;\n _api_index__WEBPACK_IMPORTED_MODULE_2__[\"services\"].selfSampleCreate(qs.stringify(params)).then(function (res) {\n var data = res.data;\n state.loading = false;\n\n if (data.err_code == 0) {\n state.submitState = true;\n state.ordernum = data.data || '';\n } else if (data.err_code == '40014') {\n Object(vant__WEBPACK_IMPORTED_MODULE_1__[\"Toast\"])('样品库存不足');\n } else {\n Object(vant__WEBPACK_IMPORTED_MODULE_1__[\"Toast\"])(data.err_msg);\n }\n }).catch(function (err) {\n state.loading = false;\n });\n },\n getDetailYp: function getDetailYp(_ref3, payload) {\n var commit = _ref3.commit;\n state.loading = true;\n var Params_ = {\n id: payload.data.id\n };\n var params = _util__WEBPACK_IMPORTED_MODULE_3__[\"default\"].getParams(Params_);\n _api_index__WEBPACK_IMPORTED_MODULE_2__[\"services\"].getSampleInfo(params).then(function (res) {\n var data = res.data;\n state.loading = false;\n\n if (data.err_code == 0) {\n state.ypGoodDetail = data.data.goods_info || {};\n state.ypComInfo = data.data.company_info || {};\n state.ypBasInfo = data.data.user_info || {};\n }\n }).catch(function (err) {\n state.loading = false;\n });\n }\n};\nvar getters = {};\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n state: state,\n mutations: mutations,\n actions: actions,\n getters: getters\n});\n\n//# sourceURL=webpack:///./src/store/modules/sample/sampleapply.js?");
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ \"./node_modules/_vue@2.6.11@vue/dist/vue.runtime.esm.js\");\n/* harmony import */ var vant__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! vant */ \"./node_modules/_vant@2.9.3@vant/es/index.js\");\n/* harmony import */ var _api_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../api/index */ \"./src/api/index.js\");\n/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../util */ \"./src/util/index.js\");\n\n\n\n\n\nvar qs = __webpack_require__(/*! qs */ \"./node_modules/_qs@6.9.4@qs/lib/index.js\");\n\nvue__WEBPACK_IMPORTED_MODULE_0__[\"default\"].use(vant__WEBPACK_IMPORTED_MODULE_1__[\"Toast\"]);\nvar state = {\n loading: false,\n addressInfo: \"\",\n submitState: false,\n ypGoodDetail: {},\n ypComInfo: {},\n ypBasInfo: {},\n ordernum: ''\n};\nvar mutations = {\n recvlistSample: function recvlistSample(state, payload) {\n if (!payload.data) {\n state.addressInfo = null;\n } else {\n state.addressInfo = payload.data.filter(function (item) {\n return item['is_default'] == 1;\n });\n state.addressInfo = state.addressInfo[0];\n }\n }\n};\nvar actions = {\n recvlistSample: function recvlistSample(_ref, payload) {\n var commit = _ref.commit;\n _api_index__WEBPACK_IMPORTED_MODULE_2__[\"services\"].recvlist().then(function (res) {\n var data = res.data; // state.loading = false;\n\n console.log(data.err_code);\n\n if (data.err_code == 0) {\n commit({\n type: 'recvlistSample',\n data: data.data\n });\n } else {\n commit({\n type: 'recvlistSample',\n data: null\n });\n }\n }).catch(function (err) {});\n },\n selfSampleCreate: function selfSampleCreate(_ref2, payload) {\n var commit = _ref2.commit;\n state.loading = true;\n var params = payload.data;\n _api_index__WEBPACK_IMPORTED_MODULE_2__[\"services\"].selfSampleCreate(qs.stringify(params)).then(function (res) {\n var data = res.data;\n state.loading = false;\n\n if (data.err_code == 0) {\n state.submitState = true;\n state.ordernum = data.data || '';\n } else if (data.err_code == '40014') {\n Object(vant__WEBPACK_IMPORTED_MODULE_1__[\"Toast\"])('样品库存不足');\n } else {\n Object(vant__WEBPACK_IMPORTED_MODULE_1__[\"Toast\"])(data.err_msg);\n }\n }).catch(function (err) {\n state.loading = false;\n });\n },\n getDetailYp: function getDetailYp(_ref3, payload) {\n var commit = _ref3.commit;\n state.loading = true;\n\n if (payload.data.type) {\n var _Params_ = {\n id: payload.data.id,\n type: 2\n };\n } else {\n var _Params_2 = {\n id: payload.data.id\n };\n }\n\n var params = _util__WEBPACK_IMPORTED_MODULE_3__[\"default\"].getParams(Params_);\n _api_index__WEBPACK_IMPORTED_MODULE_2__[\"services\"].getSampleInfo(params).then(function (res) {\n var data = res.data;\n state.loading = false;\n\n if (data.err_code == 0) {\n state.ypGoodDetail = data.data.goods_info || {};\n state.ypComInfo = data.data.company_info || {};\n state.ypBasInfo = data.data.user_info || {};\n }\n }).catch(function (err) {\n state.loading = false;\n });\n }\n};\nvar getters = {};\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n state: state,\n mutations: mutations,\n actions: actions,\n getters: getters\n});\n\n//# sourceURL=webpack:///./src/store/modules/sample/sampleapply.js?");
/***/ }),
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment