|
|
@@ -127,16 +127,12 @@ export struct MainView {
|
|
|
}
|
|
|
.width('100%')
|
|
|
.loop(false)
|
|
|
- // .index($$this.currentIndex) // 状态变量
|
|
|
.indicator(false)
|
|
|
.loop(true)
|
|
|
.duration(1000)
|
|
|
.itemSpace(12)
|
|
|
.nextMargin(15)
|
|
|
.prevMargin(15)
|
|
|
- // .onChange(() => {
|
|
|
- // this.loopSwitch = true;
|
|
|
- // })
|
|
|
}
|
|
|
.width('100%')
|
|
|
.padding({top: 8, bottom: 16 })
|
|
|
@@ -276,7 +272,10 @@ struct RecipeWidget{
|
|
|
|
|
|
// 当前选中的菜品
|
|
|
@Local selectCuisine: number = -1
|
|
|
+ // 当天的食谱
|
|
|
@Local toDayPlan?: DayPlan
|
|
|
+ // 展开菜单时选择的是哪一餐 0 - 早餐 1 - 午餐 2 - 晚餐
|
|
|
+ @Local selectMeal: number = -1
|
|
|
|
|
|
threeMeals: Array<BasicType<Cuisine>> = [
|
|
|
{
|
|
|
@@ -349,23 +348,31 @@ struct RecipeWidget{
|
|
|
// 展开菜单
|
|
|
openMenu(text: string){
|
|
|
let cuisine: Cuisine | undefined = this.getCuisine(text)
|
|
|
+ this.selectMeal = this.threeMeals.findIndex(item => item.text === text)
|
|
|
if(cuisine) {
|
|
|
this.selectCuisine = cuisine.id ?? -1
|
|
|
+ } else {
|
|
|
+ this.selectCuisine = -1
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 选中修改菜品
|
|
|
updateCuisine(id: number){
|
|
|
+ if(!this.toDayPlan) this.toDayPlan = new DayPlan()
|
|
|
+
|
|
|
let origin = this.getToDayPlan(false)
|
|
|
let cuisine: Cuisine | undefined = this.vm.getCuisineInfo(id)
|
|
|
- if(this.toDayPlan?.breakfast?.id == this.selectCuisine) {
|
|
|
+ if(this.selectMeal == 0) {
|
|
|
this.toDayPlan.breakfast = cuisine
|
|
|
+ if(!origin?.breakfast) origin!.breakfast = new Cuisine()
|
|
|
origin!.breakfast = this.toDayPlan?.breakfast
|
|
|
- } else if (this.toDayPlan?.lunch?.id == this.selectCuisine) {
|
|
|
+ } else if (this.selectMeal == 1) {
|
|
|
this.toDayPlan.lunch = cuisine
|
|
|
+ if(!origin?.lunch) origin!.lunch = new Cuisine()
|
|
|
origin!.lunch = this.toDayPlan?.lunch
|
|
|
- } else if (this.toDayPlan?.dinner?.id == this.selectCuisine) {
|
|
|
+ } else if (this.selectMeal == 2) {
|
|
|
this.toDayPlan.dinner = cuisine
|
|
|
+ if(!origin?.dinner) origin!.dinner = new Cuisine()
|
|
|
origin!.dinner = this.toDayPlan?.dinner
|
|
|
}
|
|
|
|