소스 검색

feat: 新增 :地址管理页面和地址添加页面
新增 地址选择弹窗

YuJing 1 개월 전
부모
커밋
85ccb100f7

+ 4 - 0
commons/basic/Index.ets

@@ -1,3 +1,5 @@
+import { getStringFromRecord } from 'anythink_sdk'
+
 export { RouterPage } from './src/main/ets/utils/ts/decorators/RouterPage'
 
 export { YtProgressComp } from './src/main/ets/components/generalComp/YtProgressComp'
@@ -121,6 +123,8 @@ export * from './src/main/ets/models/NavDiaLogModel'
 
 export * from './src/main/ets/components/generalComp/YtDatePicker'
 
+export  * from '@ibestservices/area-data'
+
 
 
 

+ 9 - 8
commons/basic/oh-package.json5

@@ -14,14 +14,15 @@
     "lunar": "^1.0.0",
     "@mumu/crop": "^1.0.3",
     "ksadsdk": "file:../../libs/KSAdSDK-3.0.5.har",
-    '@csj/openadsdk': "file:../../libs/openadsdk.har",
-    '@gdt/gdt-union-sdk': "file:../../libs/GDTUnionSDK-default-release.har",
-    'anythink_sdk': "file:../../libs/anythink_sdk.har",
-    'anythink_network_ks': "file:../../libs/anythink_network_ks.har",
-    'anythink_network_csj': "file:../../libs/anythink_network_csj.har",
-    'anythink_network_gdt': "file:../../libs/anythink_network_gdt.har",
-    'anythink_network_huawei': "file:../../libs/anythink_network_huawei.har"
+    "@csj/openadsdk": "file:../../libs/openadsdk.har",
+    "@gdt/gdt-union-sdk": "file:../../libs/GDTUnionSDK-default-release.har",
+    "anythink_sdk": "file:../../libs/anythink_sdk.har",
+    "anythink_network_ks": "file:../../libs/anythink_network_ks.har",
+    "anythink_network_csj": "file:../../libs/anythink_network_csj.har",
+    "anythink_network_gdt": "file:../../libs/anythink_network_gdt.har",
+    "anythink_network_huawei": "file:../../libs/anythink_network_huawei.har",
+    "@ibestservices/area-data": "^0.0.6"
   },
   "devDependencies": {},
-  "dynamicDependencies": {},
+  "dynamicDependencies": {}
 }

+ 1 - 1
commons/basic/src/main/ets/models/index.ets

@@ -20,7 +20,7 @@ export interface BasicType<T = undefined> {
   confirmMessage?: string
   cancelMessage?: string
   isShowClose?: boolean
-
+  type?: string
 }
 
 export type ReqString = Record<string, string>

+ 10 - 0
commons/basic/src/main/ets/utils/arkts/utils/YTRouter.ets

@@ -126,6 +126,16 @@ class YTRouter extends NavPathStack {
   router2ChangePhonePage(){
     this.pushPathByName('ChangePhonePage', null)
   }
+
+  // 地址管理页面
+  router2AddressManagementPage(){
+    this.pushPathByName('AddressManagementPage', null)
+  }
+
+  // 添加地址页面
+  router2IncreaseAddressPage(){
+    this.pushPathByName('IncreaseAddressPage', null)
+  }
 }
 
 export const yTRouter = YTRouter.getInstance()

+ 1 - 0
commons/basic/src/main/resources/base/media/icon_edit.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1762305820637" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4682" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M390.884 743.171l560.554-633.535L909.8 64.863 348.797 697.95l42.087 45.221z m515.782-346.989h53.28v440.116c0 33.132-12.09 64.025-34.028 87.306-21.939 23.283-51.04 35.818-81.934 35.818H180.452c-30.894 0-59.996-12.536-81.934-35.818S64.49 869.43 64.49 836.298V187.093c0-33.131 12.088-64.025 34.027-87.306s51.04-35.818 81.934-35.818h484.441v57.31H180.451c-34.475 0-62.682 29.101-62.682 65.815V836.3c0 36.714 28.207 65.816 62.682 65.816h663.532c34.475 0 62.682-29.102 62.682-65.816V396.182z" p-id="4683"></path></svg>

+ 2 - 37
features/feature/src/main/ets/components/AddressComp.ets

@@ -1,5 +1,6 @@
 import { DiaLogSheetControl, YTAvoid } from 'basic';
 import { CustomTextStyle } from '../style/CustomTextStyle';
+import { AddressItemComp } from './AddressItemComp';
 import { buttonComp } from './BuilderIndex';
 
 
@@ -55,43 +56,7 @@ export struct AddressComp{
   @Builder
   addressItem(index: number){
     RelativeContainer(){
-      Row(){
-        Image($r('[basic].media.icon_location')).width(24).aspectRatio(1)
-
-        Column({space: 2}){
-          Text('福建省厦门市火炬园高新区火炬园路321号韩菲诗.诚享大厦304室内')
-            .fontSize(14)
-            .fontWeight(400)
-            .fontColor('#FF000000')
-
-          Row(){
-            Text('占三峰')
-              .fontSize(14)
-              .fontWeight(500)
-              .fontColor('#FF000000')
-            Text('13598728343')
-              .fontSize(14)
-              .fontWeight(500)
-              .fontColor('#FF000000')
-          }
-        }
-        .layoutWeight(1)
-        .margin({left: 11, right: 19})
-        .alignItems(HorizontalAlign.Start)
-
-        if(this.selectIndex == index) {
-          Image($r('[basic].media.icon_select'))
-            .width(15).aspectRatio(1)
-        } else {
-          Row()
-            .borderRadius(15)
-            .border({width: 1})
-            .width(15).aspectRatio(1)
-        }
-      }.width('100%').height('100%')
-      .borderRadius(16)
-      .alignItems(VerticalAlign.Center)
-      .padding({left: 16, right: 16, top: 18, bottom: 18})
+      AddressItemComp({ selectIndex: this.selectIndex, index: index, type: 2, needBorder: false })
       .alignRules({
         left: {anchor: '__container__', align: HorizontalAlign.Start},
         top: {anchor: '__container__', align: VerticalAlign.Top}

+ 54 - 0
features/feature/src/main/ets/components/AddressItemComp.ets

@@ -0,0 +1,54 @@
+import { CustomTextStyle } from "../style/CustomTextStyle"
+
+@ComponentV2
+export struct AddressItemComp {
+  @Param index: number = 0
+  @Param selectIndex: number = 0
+  // 0 - 查看  1 - 编辑  2 - 选择 ( icon 不同 )
+  @Param type: 0 | 1 | 2 = 0
+  @Param needBorder: boolean = true
+
+  @Event click: () => void
+
+  build() {
+    Row(){
+      Image($r('[basic].media.icon_location')).width(24).aspectRatio(1)
+
+      Column({space: 5}){
+        Text('福建省厦门市火炬园高新区火炬园路321号韩菲诗.诚享大厦304室内')
+          .attributeModifier(new CustomTextStyle({ size: 14, weight: 400, color: '#FF000000' }))
+
+        Row({space: 8}){
+          Text('占三峰').attributeModifier(new CustomTextStyle({ size: 14, weight: 500, color: '#FF000000' }))
+          Text('13598728343').attributeModifier(new CustomTextStyle({ size: 14, weight: 500, color: '#FF000000' }))
+        }
+      }
+      .layoutWeight(1)
+      .margin({left: 11, right: 19})
+      .alignItems(HorizontalAlign.Start)
+
+      if(this.type == 0) {
+        Image($r('[basic].media.ic_public_arrow_left'))
+          .rotate({angle: 180})
+          .width(24).aspectRatio(1)
+      } else if (this.type == 1) {
+        Image($r('[basic].media.icon_edit'))
+          .width(24).aspectRatio(1)
+      } else  {
+        if(this.selectIndex == this.index) {
+          Image($r('[basic].media.icon_select'))
+            .width(15).aspectRatio(1)
+        } else {
+          Row()
+            .borderRadius(15)
+            .border({width: 1})
+            .width(15).aspectRatio(1)
+        }
+      }
+    }.width('100%')
+    .alignItems(VerticalAlign.Center)
+    .border(this.needBorder ? {width: 2, color: '#FF000000'} : null)
+    .borderRadius(this.needBorder ? 8 : 0)
+    .padding({left: 16, right: 16, top: 18, bottom: 18})
+  }
+}

+ 2 - 1
features/feature/src/main/ets/components/BuilderIndex.ets

@@ -15,7 +15,6 @@ export function tagItemComp(text: string, fontColor: ResourceColor, bgColor: Res
 
 
 
-
 // 书单Item
 @Builder
 export function bookListItemComp(title: string){
@@ -117,3 +116,5 @@ export function buttonComp(text: string, width: Length, padding: number, font: C
   .padding({top: padding, bottom: padding})
   .onClick(onClick)
 }
+
+

+ 62 - 0
features/feature/src/main/ets/components/chooseAddress.ets

@@ -0,0 +1,62 @@
+import { DiaLogSheetControl, IBestPicker, regionData, setIBestUIBaseStyle } from 'basic';
+
+@Component
+export struct ChooseAddress {
+  control?: DiaLogSheetControl = undefined
+  address?: string
+
+  @State value: string[] = []
+  @State visible: boolean = false
+
+
+  // 逆解析
+  parse(){
+    if(!this.address) return
+
+    let arr = regionData
+    let index = 0
+
+    index = arr.findIndex(item => this.address!.includes(item.text))
+    this.value.push(arr[index].value)
+
+    arr = arr[index].children!
+    if(!arr) return
+    index = arr.findIndex(item => this.address!.includes(item.text))
+    this.value.push(arr[index].value)
+
+    arr = arr[index].children!
+    if(!arr) return
+    index = arr.findIndex(item => this.address!.includes(item.text))
+    this.value.push(arr[index].value)
+  }
+
+  aboutToAppear(): void {
+    setIBestUIBaseStyle({
+      fontSizeMd: '16',
+      primary: Color.Black
+    })
+    this.parse()
+  }
+
+  aboutToDisappear(): void {
+    setIBestUIBaseStyle({
+      fontSizeMd: '14',
+      primary:'#49A2FB'
+    })
+  }
+
+  build() {
+    Column({ space: 20 }) {
+      IBestPicker({
+        options: regionData,
+        value: this.value,
+        onConfirm: (selectedValues: Array<string>, selectTexts: Array<string>) => {
+          this.control?._onBackPress(selectTexts)
+        },
+        onCancel: () => {
+          this.control?._onBackPress()
+        }
+      })
+    }.width('100%')
+  }
+}

+ 54 - 0
features/feature/src/main/ets/pages/Address/AddressManagementPage.ets

@@ -0,0 +1,54 @@
+import { RouterPage, YTAvoid, YTHeader, yTRouter } from 'basic'
+import { AddressItemComp } from '../../components/AddressItemComp'
+import { buttonComp } from '../../components/BuilderIndex'
+import { CustomTextStyle } from '../../style/CustomTextStyle'
+
+@ComponentV2
+@RouterPage
+struct AddressManagementPage {
+  @Local safeBottom: number = AppStorage.get(YTAvoid.SAFE_BOTTOM_KEY) as number
+
+  editAddress(index?: number){
+    yTRouter.router2IncreaseAddressPage()
+  }
+
+  build() {
+    NavDestination() {
+      Column() {
+        YTHeader({ defaultStyle: { title: '我的地址' }, bgc: Color.White })
+
+        Column({space: 10}){
+          Column(){
+            List({space: 16}){
+              ForEach(new Array(10).fill(''), (item: string, index) => {
+                AddressItemComp({type: 1, click: () =>{
+                  this.editAddress(index)
+                }})
+              })
+            }
+            .width('100%')
+            .height('100%')
+            .scrollBar(BarState.Off)
+          }.width('100%')
+          .layoutWeight(1)
+
+          buttonComp('添加收件地址', '100%', 10, new CustomTextStyle({size: 18, weight: 500}), () => {
+            this.editAddress()
+          })
+        }.width('100%')
+        .layoutWeight(1)
+        .padding({left: 16, right: 16})
+      }.width('100%')
+      .height('100%')
+      .backgroundColor('#F7F9FA')
+      .padding({ bottom: this.safeBottom })
+    }
+    .hideTitleBar(true)
+  }
+}
+
+
+@Builder
+function AddressManagementBuilder() {
+  AddressManagementPage()
+}

+ 141 - 0
features/feature/src/main/ets/pages/Address/IncreaseAddressPage.ets

@@ -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})
+}

+ 2 - 24
features/feature/src/main/ets/pages/Order/OrderDetailPage.ets

@@ -1,5 +1,6 @@
 import { DiaLogSheetControl, RouterPage, YTAvoid, YTHeader, yTRouter } from 'basic'
 import { AddressComp } from '../../components/AddressComp'
+import { AddressItemComp } from '../../components/AddressItemComp'
 import { buttonComp } from '../../components/BuilderIndex'
 import { CustomTextStyle } from '../../style/CustomTextStyle'
 
@@ -28,31 +29,8 @@ struct OrderDetailPage {
 
             // 地址栏
             ListItem(){
-              Row(){
-                Image($r('[basic].media.icon_location')).width(24).aspectRatio(1)
-
-                Column({space: 2}){
-                  Text('福建省厦门市火炬园高新区火炬园路321号韩菲诗.诚享大厦304室内')
-                    .attributeModifier(new CustomTextStyle({ size: 14, weight: 400, color: '#FF000000' }))
-
-                  Row(){
-                    Text('占三峰').attributeModifier(new CustomTextStyle({ size: 14, weight: 500, color: '#FF000000' }))
-                    Text('13598728343').attributeModifier(new CustomTextStyle({ size: 14, weight: 500, color: '#FF000000' }))
-                  }
-                }
-                .layoutWeight(1)
-                .margin({left: 11, right: 19})
-                .alignItems(HorizontalAlign.Start)
-
-                Image($r('[basic].media.ic_public_arrow_left'))
-                  .rotate({angle: 180})
-                  .width(12).aspectRatio(1)
-              }.width('100%')
-              .alignItems(VerticalAlign.Center)
-              .padding({left: 16, right: 16, top: 18, bottom: 18})
+              AddressItemComp({type: 0})
             }
-            .borderRadius(8)
-            .border({width: 2})
             .backgroundColor(Color.White)
             .onClick(() => { this.openAddressDialog() })
 

+ 10 - 0
features/feature/src/main/resources/base/profile/router_map.json

@@ -44,6 +44,16 @@
       "name": "BorrowAnsPage",
       "pageSourceFile": "src/main/ets/pages/Order/BorrowAnsPage.ets",
       "buildFunction": "BorrowAnsBuilder"
+    },
+    {
+      "name": "AddressManagementPage",
+      "pageSourceFile": "src/main/ets/pages/Address/AddressManagementPage.ets",
+      "buildFunction": "AddressManagementBuilder"
+    },
+    {
+      "name": "IncreaseAddressPage",
+      "pageSourceFile": "src/main/ets/pages/Address/IncreaseAddressPage.ets",
+      "buildFunction": "IncreaseAddressBuilder"
     }
   ]
 }

+ 0 - 1
features/user/src/main/ets/pages/SettingPage.ets

@@ -109,7 +109,6 @@ struct SettingPage {
   openReviseNameBuilder() {
     let control = new DiaLogCompControl(this.getUIContext())
     yTRouter.router2CenterDialog({
-      param: { text: this.userInfo.getName() ?? this.userInfo.getPhoneNumber() ?? this.userInfo.getId()?.toString() },
       control: control,
       builder: () => {
         this.ReviseName({ text: this.userInfo.getName() ?? this.userInfo.getPhoneNumber() ?? this.userInfo.getId()?.toString() }, control)

+ 1 - 1
features/user/src/main/ets/views/Mine.ets

@@ -21,7 +21,7 @@ export struct Mine {
     {
       text: '地址管理',
       click: () => {
-
+        yTRouter.router2AddressManagementPage()
       },
       src: $r('app.media.mine_right_arrow')
     },