|
|
@@ -3,19 +3,23 @@ import { DiaLogPageEnum, DiaLogParam, YTDiaLogModel } from "basic/src/main/ets/m
|
|
|
import { BabyFoodApi } from "../Apis/BabyFoodApi"
|
|
|
import { Recipe } from "../model/Index"
|
|
|
import { routerUtils } from "../utils/RouterUtils"
|
|
|
-import { AppStorageV2 } from "@kit.ArkUI"
|
|
|
+import { AppStorageV2, curves } from "@kit.ArkUI"
|
|
|
|
|
|
@ObservedV2
|
|
|
export class SecondViewModel{
|
|
|
safeTop: number = 0
|
|
|
// 选择的年龄段
|
|
|
- @Trace monthRange: string = ''
|
|
|
+ @Trace monthRange: number = 3
|
|
|
// 搜索关键字
|
|
|
@Trace keyword: string = ''
|
|
|
@Trace recipe: Recipe[] = []
|
|
|
// 用户信息
|
|
|
@Trace userInfo: UserInfo = AppStorageV2.connect<UserInfo>(UserInfo, 'UserInfo', () => userInfo)!
|
|
|
|
|
|
+ // 年龄分段
|
|
|
+ ageRange: string[] = ['6个月', '8个月', '12个月', '全部年龄']
|
|
|
+ valueRange: string[] = ['6', '8', '12', '']
|
|
|
+
|
|
|
constructor() {
|
|
|
this.safeTop = AppStorage.get(YTAvoid.SAFE_TOP_KEY) as number
|
|
|
this.getRecipeList()
|
|
|
@@ -26,10 +30,16 @@ export class SecondViewModel{
|
|
|
routerUtils.router2RecipeSearchPage()
|
|
|
}
|
|
|
|
|
|
+ // 修改年龄段
|
|
|
+ updateMonthRange(index: number){
|
|
|
+ this.monthRange = index
|
|
|
+ this.getRecipeList()
|
|
|
+ }
|
|
|
+
|
|
|
// 获取食谱列表
|
|
|
async getRecipeList(){
|
|
|
if(this.userInfo.checkLogin())
|
|
|
- this.recipe = await BabyFoodApi.getAllRecipes(this.keyword, this.monthRange)
|
|
|
+ this.recipe = await BabyFoodApi.getAllRecipes(this.keyword, this.valueRange[this.monthRange])
|
|
|
}
|
|
|
|
|
|
|