From 0982a2b53ba511bc41a5ee9226388e034e2810e2 Mon Sep 17 00:00:00 2001 From: Anne_LXM <54163582+anne-lxm@users.noreply.github.com> Date: Mon, 29 Jan 2024 19:28:14 +0800 Subject: [PATCH] Element-->UniElement --- .../uni-id-pages-x-input.uvue | 2 +- .../uni-id-pages-x-popup-dialog.uvue | 2 +- .../fab-sms-code-input.uvue | 23 +++++++++---------- .../uni-id-pages-x-smsCode.uvue | 12 +++++----- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/uni_modules/uni-id-pages-x/components/uni-id-pages-x-input/uni-id-pages-x-input.uvue b/uni_modules/uni-id-pages-x/components/uni-id-pages-x-input/uni-id-pages-x-input.uvue index 8e1cc69..61dbb2d 100644 --- a/uni_modules/uni-id-pages-x/components/uni-id-pages-x-input/uni-id-pages-x-input.uvue +++ b/uni_modules/uni-id-pages-x/components/uni-id-pages-x-input/uni-id-pages-x-input.uvue @@ -103,7 +103,7 @@ // this.$emit('update:focus', true); }, setFocus(state : boolean) { - const inputEl = this.$refs['input'] as Element + const inputEl = this.$refs['input'] as UniElement if (state) { inputEl.focus(); } else { diff --git a/uni_modules/uni-id-pages-x/components/uni-id-pages-x-popup-dialog/uni-id-pages-x-popup-dialog.uvue b/uni_modules/uni-id-pages-x/components/uni-id-pages-x-popup-dialog/uni-id-pages-x-popup-dialog.uvue index c691f54..a1a7d18 100644 --- a/uni_modules/uni-id-pages-x/components/uni-id-pages-x-popup-dialog/uni-id-pages-x-popup-dialog.uvue +++ b/uni_modules/uni-id-pages-x/components/uni-id-pages-x-popup-dialog/uni-id-pages-x-popup-dialog.uvue @@ -32,7 +32,7 @@ confirmCallBack = callback; (this.$refs['popup'] as UniPopupComponentPublicInstance).open(); this.$nextTick(() => { - (this.$refs['input'] as Element).focus() + (this.$refs['input'] as UniElement).focus() }) }, cancel() { diff --git a/uni_modules/uni-id-pages-x/components/uni-id-pages-x-smsCode/fab-sms-code-input.uvue b/uni_modules/uni-id-pages-x/components/uni-id-pages-x-smsCode/fab-sms-code-input.uvue index 9ba0d18..786e509 100644 --- a/uni_modules/uni-id-pages-x/components/uni-id-pages-x-smsCode/fab-sms-code-input.uvue +++ b/uni_modules/uni-id-pages-x/components/uni-id-pages-x-smsCode/fab-sms-code-input.uvue @@ -5,8 +5,9 @@ {{title}} 短信验证码已发送至{{mobile}} - @@ -23,7 +24,7 @@ emits: ["update:modelValue","reGetSmsCode","blur", "focus" ], data() { return { - smsCodeList: ["\u200b", "\u200b", "\u200b", "\u200b", "\u200b", "\u200b"], + smsCodeList: ["\u200b", "\u200b", "\u200b", "\u200b", "\u200b", "\u200b"], isOpen: false } }, @@ -63,7 +64,7 @@ show() { (this.$refs['popup'] as UniPopupComponentPublicInstance).open(); this.$nextTick(() => { - (this.$refs["code-input"] as Element[])[0].focus(); + (this.$refs["code-input"] as UniElement[])[0].focus(); }) this.isOpen = true }, @@ -75,28 +76,26 @@ clear() { this.smsCodeList = ["\u200b", "\u200b", "\u200b", "\u200b", "\u200b", "\u200b"]; if (this.isOpen) { - (this.$refs["code-input"] as Element[])[0].focus(); + (this.$refs["code-input"] as UniElement[])[0].focus(); // console.log('clear success'); } else { // console.log('已经关了,不能清空'); } }, setSmsCode(i : number, e : InputEvent) { + // console.log('setSmsCode--',e); const { value } = e.detail - // console.log('~~',value,value.length); - + console.log('~~',value,value.length); // 已满6位数就直接调登录 let $value = value.replace(/\u200b/g, '') if ($value.length == 6) { // (this.$refs["code-input"] as Element[])[0].focus(); // console.log('~~~~~', $value, $value.split('')); $value.split('').forEach((item : string, index : number) => { - // console.log('index', index, item); this.smsCodeList[index] = "\u200b" + item }) return } - // 限制每个空格内的文字不超过2位 if (value.length > 2) { this.$nextTick(() => { @@ -105,7 +104,6 @@ this.smsCodeList[i] = newValue }) } - // 被删除完就直接后退一格 if (value.length == 0) { this.smsCodeList[i] = "" @@ -113,19 +111,20 @@ this.smsCodeList[i] = '\u200b' }) if (i != 0) { - (this.$refs["code-input"] as Element[])[i - 1].focus(); + (this.$refs["code-input"] as UniElement[])[i - 1].focus(); this.smsCodeList[i - 1] = "" } } else if (value != "\u200b") { this.smsCodeList[i] = value; if (i != (this.smsCodeList.length - 1)) { - (this.$refs["code-input"] as Element[])[i + 1].focus(); + (this.$refs["code-input"] as UniElement[])[i + 1].focus(); } else { // console.log(i, (this.smsCodeList.length - 1)); } } }, onFocus(i : number) { + // console.log("onFocus",i); if (this.smsCodeList[i].length == 0) { this.smsCodeList[i] = '\u200b' } diff --git a/uni_modules/uni-id-pages-x/components/uni-id-pages-x-smsCode/uni-id-pages-x-smsCode.uvue b/uni_modules/uni-id-pages-x/components/uni-id-pages-x-smsCode/uni-id-pages-x-smsCode.uvue index f457a83..24d20c5 100644 --- a/uni_modules/uni-id-pages-x/components/uni-id-pages-x-smsCode/uni-id-pages-x-smsCode.uvue +++ b/uni_modules/uni-id-pages-x/components/uni-id-pages-x-smsCode/uni-id-pages-x-smsCode.uvue @@ -137,12 +137,12 @@ if (state.pendingAgreements) { // uni.hideKeyboard(); this.sendSmsCaptchaCP!.setFocus(false); - // web端尚未完全支持 - // (this.$parent as ComponentPublicInstance).$callMethod("showPopupCaptcha", () => { - // if (!state.pendingAgreements) { - // this.sendSmsCode() - // } - // }); + // web端有问题 + // (this.$parent as ComponentPublicInstance).$callMethod("showPopupCaptcha", () => { + // if (!state.pendingAgreements) { + // this.sendSmsCode() + // } + // }); // 临时方案 uni.$emit('uni-id-pages-x-loginBySmsCode-showPopupCaptcha',()=>{ if (!state.pendingAgreements) { -- GitLab