修复通俗重量
This commit is contained in:
@ -1,13 +1,15 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import app from './modules/app'
|
||||
import user from './modules/user'
|
||||
import tagsView from './modules/tagsView'
|
||||
import permission from './modules/permission'
|
||||
import settings from './modules/settings'
|
||||
import getters from './getters'
|
||||
import Vue from "vue";
|
||||
import Vuex from "vuex";
|
||||
import app from "./modules/app";
|
||||
import user from "./modules/user";
|
||||
import tagsView from "./modules/tagsView";
|
||||
import permission from "./modules/permission";
|
||||
import settings from "./modules/settings";
|
||||
import recipes from "./modules/recipes";
|
||||
|
||||
Vue.use(Vuex)
|
||||
import getters from "./getters";
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
const store = new Vuex.Store({
|
||||
modules: {
|
||||
@ -15,9 +17,10 @@ const store = new Vuex.Store({
|
||||
user,
|
||||
tagsView,
|
||||
permission,
|
||||
settings
|
||||
settings,
|
||||
recipes
|
||||
},
|
||||
getters
|
||||
})
|
||||
});
|
||||
|
||||
export default store
|
||||
export default store;
|
||||
|
50
stdiet-ui/src/store/modules/recipes.js
Normal file
50
stdiet-ui/src/store/modules/recipes.js
Normal file
@ -0,0 +1,50 @@
|
||||
import { getOrder } from "@/api/custom/order";
|
||||
import { getCustomerPhysicalSignsByCusId } from "@/api/custom/customer";
|
||||
import { dealHealthy } from "@/utils/healthyData";
|
||||
import { getRecipesPlan } from "@/api/custom/recipesPlan";
|
||||
|
||||
const oriState = {
|
||||
healthyData: {},
|
||||
healthyDataType: 0
|
||||
};
|
||||
|
||||
const mutations = {
|
||||
setHealtyData(state, payload) {
|
||||
state.healthyDataType = payload.healthyDataType;
|
||||
state.healthyData = payload.healthyData;
|
||||
},
|
||||
clean(state) {
|
||||
console.log("clean");
|
||||
Object.keys(oriState).forEach(key => {
|
||||
state[key] = oriState[key];
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const actions = {
|
||||
async init({ commit }, payload) {
|
||||
const orderResult = await getOrder(payload.cusId);
|
||||
if (!orderResult.data.cusId) {
|
||||
throw new Error("未找到用户id");
|
||||
}
|
||||
|
||||
const healthyDataResult = await getCustomerPhysicalSignsByCusId(
|
||||
orderResult.data.cusId
|
||||
);
|
||||
// 设置健康数据
|
||||
commit("setHealtyData", {
|
||||
healthyDataType: healthyDataResult.data.type,
|
||||
healthyData: dealHealthy(healthyDataResult.data.customerHealthy)
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const getters = {};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: Object.assign({}, oriState),
|
||||
mutations,
|
||||
actions,
|
||||
getters
|
||||
};
|
Reference in New Issue
Block a user