|
@@ -0,0 +1,141 @@
|
|
|
|
|
+import { BasicType, DiaLogSheetControl, YTAvoid, YTHeader, yTRouter } from 'basic'
|
|
|
|
|
+import { buttonComp } from '../../components/BuilderIndex'
|
|
|
|
|
+import { ChooseAddress } from '../../components/chooseAddress'
|
|
|
|
|
+import { CustomTextStyle } from '../../style/CustomTextStyle'
|
|
|
|
|
+
|
|
|
|
|
+@ComponentV2
|
|
|
|
|
+struct IncreaseAddressPage {
|
|
|
|
|
+ @Param @Require index?: number
|
|
|
|
|
+ @Param originIsUse: boolean = false
|
|
|
|
|
+
|
|
|
|
|
+ @Local safeBottom: number = AppStorage.get(YTAvoid.SAFE_BOTTOM_KEY) as number
|
|
|
|
|
+ // 是否设置为默认地址
|
|
|
|
|
+ @Local isDefaultAddress: boolean = false
|
|
|
|
|
+ // 选择的地址
|
|
|
|
|
+ @Local address: string = ''
|
|
|
|
|
+
|
|
|
|
|
+ forEach: Array<BasicType> = [
|
|
|
|
|
+ { text: '收件人', message: '请输入收件人', type: 'Input' },
|
|
|
|
|
+ { text: '联系电话', message: '请输入联系电话', type: 'InputNumber' },
|
|
|
|
|
+ { text: '所在区域', message: '请选择地区', type: 'Event', click: ()=>{ this.openChooseAddress() } },
|
|
|
|
|
+ { text: '详情地址', message: '请输入详细地址', type: 'Input' },
|
|
|
|
|
+ ]
|
|
|
|
|
+
|
|
|
|
|
+ // 打开选择地址弹窗
|
|
|
|
|
+ openChooseAddress() {
|
|
|
|
|
+ let control: DiaLogSheetControl = new DiaLogSheetControl(this.getUIContext(), false, false)
|
|
|
|
|
+ yTRouter.router2BottomDialog({
|
|
|
|
|
+ control: control,
|
|
|
|
|
+ builder: () => { this.chooseAddress(control, this.address) }
|
|
|
|
|
+ }, (ans) => {
|
|
|
|
|
+ let res = ans.result as Array<string>
|
|
|
|
|
+ this.address = res.join('-')
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 保存地址
|
|
|
|
|
+ saveAddress() {}
|
|
|
|
|
+
|
|
|
|
|
+ // 设置为默认地址
|
|
|
|
|
+ setDefaultAddress() {
|
|
|
|
|
+ this.isDefaultAddress = !this.isDefaultAddress
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ build() {
|
|
|
|
|
+ NavDestination() {
|
|
|
|
|
+ Column() {
|
|
|
|
|
+ YTHeader({ defaultStyle: { title: this.index ? '编辑地址' : '增添地址' }, bgc: Color.White })
|
|
|
|
|
+
|
|
|
|
|
+ Column({space: 16}){
|
|
|
|
|
+ Column(){
|
|
|
|
|
+ ForEach(this.forEach, (item: BasicType, index) => {
|
|
|
|
|
+ Row({space: 32}){
|
|
|
|
|
+ Text(item.text)
|
|
|
|
|
+ .width(60)
|
|
|
|
|
+ .fontSize(14)
|
|
|
|
|
+ .fontWeight(500)
|
|
|
|
|
+ .fontColor('#FF000000')
|
|
|
|
|
+
|
|
|
|
|
+ if(item.type == "Event"){
|
|
|
|
|
+ Text(this.address || item.message)
|
|
|
|
|
+ .fontSize(14)
|
|
|
|
|
+ .fontWeight(500)
|
|
|
|
|
+ .fontColor('#FF000000')
|
|
|
|
|
+ .onClick(item.click)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ TextInput({placeholder: item.message})
|
|
|
|
|
+ .padding(0)
|
|
|
|
|
+ .fontSize(14)
|
|
|
|
|
+ .borderRadius(0)
|
|
|
|
|
+ .layoutWeight(1)
|
|
|
|
|
+ .border({width: 0})
|
|
|
|
|
+ .placeholderFont({size: 14})
|
|
|
|
|
+ .backgroundColor(Color.Transparent)
|
|
|
|
|
+ .type(item.type == "Input" ? undefined : InputType.PhoneNumber)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .width('100%')
|
|
|
|
|
+
|
|
|
|
|
+ if(index != this.forEach.length - 1) {
|
|
|
|
|
+ Divider().width('100%').height(1).backgroundColor('#E0E0E0').margin({top: 15, bottom: 15})
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ .padding(15)
|
|
|
|
|
+ .width('100%')
|
|
|
|
|
+ .borderRadius(8)
|
|
|
|
|
+ .backgroundColor(Color.White)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Row(){
|
|
|
|
|
+ Text('设为默认地址')
|
|
|
|
|
+ .attributeModifier(new CustomTextStyle({size: 14, weight: 500}))
|
|
|
|
|
+
|
|
|
|
|
+ if(this.isDefaultAddress) {
|
|
|
|
|
+ Image($r('[basic].media.icon_select'))
|
|
|
|
|
+ .width(15).aspectRatio(1)
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Row()
|
|
|
|
|
+ .borderRadius(15)
|
|
|
|
|
+ .border({width: 1})
|
|
|
|
|
+ .width(15).aspectRatio(1)
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ .padding(15)
|
|
|
|
|
+ .width('100%')
|
|
|
|
|
+ .borderRadius(8)
|
|
|
|
|
+ .backgroundColor(Color.White)
|
|
|
|
|
+ .justifyContent(FlexAlign.SpaceBetween)
|
|
|
|
|
+ .onClick(() =>{ this.setDefaultAddress() })
|
|
|
|
|
+ }
|
|
|
|
|
+ .width('100%')
|
|
|
|
|
+ .layoutWeight(1)
|
|
|
|
|
+ .padding({left: 16, right: 16, top: 22})
|
|
|
|
|
+
|
|
|
|
|
+ Row(){
|
|
|
|
|
+ buttonComp(this.originIsUse ? '保存并使用' : '保存地址', '100%', 10,
|
|
|
|
|
+ new CustomTextStyle({size: 18, weight: 500}),
|
|
|
|
|
+ () =>{ this.saveAddress() })
|
|
|
|
|
+ }
|
|
|
|
|
+ .width('100%')
|
|
|
|
|
+ .backgroundColor(Color.White)
|
|
|
|
|
+ .padding({left: 16, right: 16, top: 10, bottom: this.safeBottom})
|
|
|
|
|
+ }
|
|
|
|
|
+ .width('100%')
|
|
|
|
|
+ .height('100%')
|
|
|
|
|
+ .backgroundColor('#F7F9FA')
|
|
|
|
|
+ }
|
|
|
|
|
+ .hideTitleBar(true)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 地址选择器
|
|
|
|
|
+ @Builder
|
|
|
|
|
+ chooseAddress(control: DiaLogSheetControl, address: string) {
|
|
|
|
|
+ ChooseAddress({control: control, address: address})
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+@Builder
|
|
|
|
|
+function IncreaseAddressBuilder(_: string, index?: number) {
|
|
|
|
|
+ IncreaseAddressPage({index: index})
|
|
|
|
|
+}
|