// 表单相关的工具函数 export const formUtils = { hideKeyboard(): void { uni.hideKeyboard(); }, selectPlace(): Promise { return new Promise((resolve, reject) => { uni.chooseLocation({ success: (res) => { resolve(res); }, fail: (error) => { console.log(error); reject(error); } }); }); }, formatter(type: string, value: number): string { if (type === 'year') { return `${value}年`; } if (type === 'month') { return `${value}月`; } if (type === 'day') { return `${value}日`; } return value.toString(); }, showOptions(itemList: string[]): Promise { return new Promise((resolve, reject) => { uni.showActionSheet({ itemList, success(res) { resolve(res.tapIndex); }, fail(error) { reject(error); } }); }); }, setCipByNum(val: string, startNum: number, num: number, isCip: boolean = false): string { if (isCip) { return val; } if (!val) return '-'; const a = val.slice(0, startNum); const b = val.substring(startNum + num); return a + '*'.repeat(num) + b; } }; // 向后兼容的导出 export const formMixins = { components: {}, data() { return {}; }, methods: formUtils };