|
|
@@ -0,0 +1,130 @@
|
|
|
+import { BasicType } from 'basic'
|
|
|
+import { _YtHeader } from '../components/_YtHeader'
|
|
|
+import { IncreaseBabyInfoViewModel } from '../viewModel/IncreaseBabyInfoViewModel'
|
|
|
+
|
|
|
+/**
|
|
|
+ * 添加宝宝信息页面
|
|
|
+ */
|
|
|
+@ComponentV2
|
|
|
+struct IncreaseBabyInfo {
|
|
|
+ @Local vm: IncreaseBabyInfoViewModel = new IncreaseBabyInfoViewModel()
|
|
|
+
|
|
|
+ build() {
|
|
|
+ NavDestination() {
|
|
|
+ Column(){
|
|
|
+ RelativeContainer() {
|
|
|
+ _YtHeader({title: "宝贝信息", isShowBackComp: false, _onBackPress: () => { this.vm._onBackPressed() }})
|
|
|
+ .width("100%")
|
|
|
+ .height(44)
|
|
|
+ .id('title')
|
|
|
+ .alignRules({
|
|
|
+ middle: { anchor: '__container__', align: HorizontalAlign.Center },
|
|
|
+ top: { anchor: '__container__', align: VerticalAlign.Top }
|
|
|
+ })
|
|
|
+
|
|
|
+ ForEach(this.vm.forEachData, (item: BasicType, index: number) => {
|
|
|
+ Column({space: 16}){
|
|
|
+ Text(item.text)
|
|
|
+ .fontSize(16)
|
|
|
+ .fontWeight(400)
|
|
|
+
|
|
|
+ if (item.date === 'birthDate') {
|
|
|
+ InputItem({item: item, value: this.vm.birthDate})
|
|
|
+ } else if (item.date === 'name') {
|
|
|
+ InputItem({item: item, value: this.vm.name})
|
|
|
+ } else if (item.date === 'gender') {
|
|
|
+ InputItem({item: item, value: this.vm.gender === undefined ? undefined : (this.vm.gender === 1 ? '男' : '女') })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .id(item.id)
|
|
|
+ .width('100%')
|
|
|
+ .padding({bottom: 32})
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ .alignItems(HorizontalAlign.Start)
|
|
|
+ .alignRules({
|
|
|
+ top: { anchor: index == 0 ? 'title' : this.vm.forEachData[index - 1].id, align: VerticalAlign.Bottom },
|
|
|
+ left: { anchor: index == 0 ? 'title' : this.vm.forEachData[index - 1].id, align: HorizontalAlign.Start }
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ // 完成按钮
|
|
|
+ Row(){
|
|
|
+ Text("完成")
|
|
|
+ .fontSize(20)
|
|
|
+ .fontColor(Color.White)
|
|
|
+ .borderRadius(24)
|
|
|
+ .padding({left: 100, right: 100, top: 12, bottom: 12})
|
|
|
+ .backgroundColor('#95C50A')
|
|
|
+ }
|
|
|
+ .id('complete')
|
|
|
+ .width("100%")
|
|
|
+ .padding({ left: 32, right: 32, top: 96, bottom: 16 })
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ .alignItems(VerticalAlign.Center)
|
|
|
+ .alignRules({
|
|
|
+ top: { anchor: this.vm.forEachData.pop()?.id, align: VerticalAlign.Bottom },
|
|
|
+ middle: { anchor: '__container__', align: HorizontalAlign.Center }
|
|
|
+ })
|
|
|
+ .onClick(() => { this.vm.complete() })
|
|
|
+
|
|
|
+ // 暂不填写
|
|
|
+ Text("暂不填写")
|
|
|
+ .fontSize(12)
|
|
|
+ .fontColor('rgba(0, 0, 0, 0.5)')
|
|
|
+ .alignRules({
|
|
|
+ top: { anchor: 'complete', align: VerticalAlign.Bottom },
|
|
|
+ middle: { anchor: '__container__', align: HorizontalAlign.Center }
|
|
|
+ })
|
|
|
+ .onClick(() => { this.vm.notFill() })
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
+ .height('100%')
|
|
|
+ }
|
|
|
+ .width('100%')
|
|
|
+ .height('100%')
|
|
|
+ .alignItems(HorizontalAlign.Center)
|
|
|
+ .justifyContent(FlexAlign.Center)
|
|
|
+ .padding({ top: this.vm.safeTop, left: 16, right: 16, bottom: 24 })
|
|
|
+ }
|
|
|
+ .hideTitleBar(true)
|
|
|
+ .onBackPressed(() => {
|
|
|
+ return this.vm._onBackPressed()
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 单个输入框
|
|
|
+@ComponentV2 struct InputItem{
|
|
|
+ @Require @Param item: BasicType
|
|
|
+ @Require @Param value: string | undefined
|
|
|
+ build(){
|
|
|
+ Row(){
|
|
|
+ if(this.value) {
|
|
|
+ Text(this.value)
|
|
|
+ .fontSize(16)
|
|
|
+ .fontColor(Color.Black)
|
|
|
+ } else {
|
|
|
+ Text(this.item.message)
|
|
|
+ .fontSize(16)
|
|
|
+ .fontColor('rgba(0, 0, 0, 0.6)')
|
|
|
+ }
|
|
|
+ Image($r('app.media.icon_open'))
|
|
|
+ .width(8)
|
|
|
+ .aspectRatio(1)
|
|
|
+ }
|
|
|
+ .height(48)
|
|
|
+ .padding(16)
|
|
|
+ .width("100%")
|
|
|
+ .borderRadius(8)
|
|
|
+ .backgroundColor('#F6F6F6')
|
|
|
+ .alignItems(VerticalAlign.Center)
|
|
|
+ .justifyContent(FlexAlign.SpaceBetween)
|
|
|
+ .border({ width: 0 })
|
|
|
+ .onClick(this.item.click)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+@Builder
|
|
|
+function IncreaseBabyInfoBuilder() {
|
|
|
+ IncreaseBabyInfo()
|
|
|
+}
|