|
@@ -38,14 +38,10 @@ export class MainViewModel{
|
|
|
|
|
|
|
|
if(this.userInfo.checkLogin()){
|
|
if(this.userInfo.checkLogin()){
|
|
|
// 宝宝信息没有的话也没必要加载后续数据了
|
|
// 宝宝信息没有的话也没必要加载后续数据了
|
|
|
- this.getBabyList().then(async () => {
|
|
|
|
|
- await this.getWeeklyPlan()
|
|
|
|
|
- await this.getDishList()
|
|
|
|
|
- await this.getWeeklyPurchaseList()
|
|
|
|
|
- this.eventFunc.forEach(f => f())
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ await this.getBabyList()
|
|
|
|
|
+ await this.getDishList()
|
|
|
} else {
|
|
} else {
|
|
|
- this.babyList = []
|
|
|
|
|
|
|
+ this.clearDataSource(true)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -64,9 +60,15 @@ export class MainViewModel{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 修改选中的宝宝信息
|
|
// 修改选中的宝宝信息
|
|
|
- updateBabyInfo(index: number) {
|
|
|
|
|
|
|
+ async updateBabyInfo(index: number) {
|
|
|
|
|
+ this.clearDataSource()
|
|
|
|
|
+
|
|
|
BabyInfo.override(this.babyInfo, this.babyList[index])
|
|
BabyInfo.override(this.babyInfo, this.babyList[index])
|
|
|
this.selectedBabyIndex = index
|
|
this.selectedBabyIndex = index
|
|
|
|
|
+
|
|
|
|
|
+ await this.getWeeklyPlan()
|
|
|
|
|
+ await this.getWeeklyPurchaseList()
|
|
|
|
|
+ this.eventFunc.forEach(f => f())
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 添加事件
|
|
// 添加事件
|
|
@@ -81,6 +83,18 @@ export class MainViewModel{
|
|
|
return this.dishList[index]
|
|
return this.dishList[index]
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 清空数据源
|
|
|
|
|
+ clearDataSource(isLoginOut: boolean = false) {
|
|
|
|
|
+ this.allPlan = {}
|
|
|
|
|
+ this.planList = {}
|
|
|
|
|
+ this.purchaseList = []
|
|
|
|
|
+
|
|
|
|
|
+ if(isLoginOut){
|
|
|
|
|
+ BabyInfo.override(this.babyInfo)
|
|
|
|
|
+ this.babyList = []
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 获取本周食谱计划
|
|
// 获取本周食谱计划
|
|
|
async getWeeklyPlan(startDate?: string){
|
|
async getWeeklyPlan(startDate?: string){
|
|
|
try {
|
|
try {
|
|
@@ -96,6 +110,8 @@ export class MainViewModel{
|
|
|
async updateWeeklyPlan(): Promise<boolean>{
|
|
async updateWeeklyPlan(): Promise<boolean>{
|
|
|
try {
|
|
try {
|
|
|
await BabyFoodApi.updateWeeklyPlan(this.planList!)
|
|
await BabyFoodApi.updateWeeklyPlan(this.planList!)
|
|
|
|
|
+ // 修改食谱清单后需刷新采购清单
|
|
|
|
|
+ this.getWeeklyPurchaseList()
|
|
|
return true
|
|
return true
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
return false
|
|
return false
|