中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
选择发票抬头Button的实现
微信扫码分享
// ChooseInvoiceTitle.ets import { FunctionalButton, functionalButtonComponentManager } from '@kit.ScenarioFusionKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; @Entry @Component struct Index { build() { Row() { Column() { // 声明FunctionalButton FunctionalButton({ params: { // OpenType.CHOOSE_INVOICE_TITLE表示Button为选择发票抬头类型 openType: functionalButtonComponentManager.OpenType.CHOOSE_INVOICE_TITLE, label: '选择发票抬头', // 调整Button样式 styleOption: { bgColor: functionalButtonComponentManager.ColorType.DEFAULT, size: functionalButtonComponentManager.SizeType.DEFAULT, plain: false, disabled: false, loading: false, hoverClass: functionalButtonComponentManager.HoverClassType.HOVER_CLASS, hoverStartTime: 0, hoverStayTime: 0, styleConfig: new functionalButtonComponentManager.ButtonConfig() .fontSize(20) .fontColor(Color.Black) } }, // OpenType为“CHOOSE_INVOICE_TITLE”时,回调必须选择“onChooseInvoiceTitle” controller: new functionalButtonComponentManager.FunctionalButtonController() .onChooseInvoiceTitle((err, data) => { if (err) { // 错误日志处理 hilog.error(0x0000, "testTag", "error: %{public}d %{public}s", err.code, err.message); return; } // 成功日志处理 hilog.info(0x0000, "testTag", "succeeded in obtaining invoice title"); // 获取发票信息 let type: string = data.type; let title: string = data.title; let taxNumber: string = data.taxNumber; let companyAddress: string | undefined = data.companyAddress; let telephone: string | undefined = data.telephone; let bankName: string | undefined = data.bankName; let bankAccount: string | undefined = data.bankAccount; }) }) } .width('100%') } .height('100%') } }