import Api from "../../api/index.js" import { requestFnc } from "../../utils/request.js" Component({ properties: { province: { type: String, value: "京津沪冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤川青藏琼宁渝", }, natural: { type: String, value: "1234567890", }, baseBorder: { type: String, value: "#cccccc", }, activeBorder: { type: String, value: "#ff7149", }, extraKey: { type: String, value: "完成", }, plateNum: { type: String, value: "", }, plateColor: { type: Number, value: 0, }, disabled: { type: Boolean, value: false } }, data: { isNum: false, // 显示数字字母键盘 是否可选数字 isAlph: false, // 显示数字字母键盘 textArr: [""], tapVal: "", }, lifetimes: { ready: function () { let plateNum = this.properties.plateNum if (plateNum) { this.setData({ textArr: plateNum.split('') }) } } }, methods: { showKeyboard() { if (!this.properties.disabled) return this.setData({ show: true, }) }, closeKeyboard() { this.setData({ show: false, }) }, tapKeyboard(e) { this.setData({ tapVal: e.currentTarget.dataset.val, }) if (this.data.tapVal === "-") { if (this.data.textArr.length == 1) { this.setData({ isAlph: false, textArr: [], }) } else { this.setData({ textArr: this.data.textArr.slice( 0, this.data.textArr.length - 2 ), }) } } else { this.data.textArr[this.data.textArr.length - 1] = this.data.tapVal this.setData({ textArr: this.data.textArr, }) } if (this.data.textArr.length === 1) { this.setData({ isAlph: true, isNum:false }) } else if (this.data.textArr.length === 0) { this.setData({ isAlph: false, isNum:false }) } else { this.setData({ isNum:true }) } this.setData({ textArr:[...this.data.textArr, ""] }) this.triggerEvent("updatePlateNum", this.data.textArr.join("")) }, tapFinished(e) { let textValue = this.data.textArr.join("") this.triggerEvent("keyboard", textValue) this.closeKeyboard() }, }, })