Browse Source

Merge pull request #498 from Drjingfubo/next

feat: taro shortpassword dom获取优化
love_forever 4 years ago
parent
commit
f7fc247fe9

+ 0 - 8
src/packages/__VUE/shortpassword/index.scss

@@ -35,14 +35,6 @@
     padding: 0 12px;
     padding: 0 12px;
     opacity: 0;
     opacity: 0;
   }
   }
-  .nut-inputWx-real {
-    width: 247px;
-    height: 41px;
-    padding: 0 12px;
-    opacity: 0;
-    position: relative;
-    z-index: 2;
-  }
 }
 }
 
 
 .nut-popup {
 .nut-popup {

+ 12 - 4
src/packages/__VUE/shortpassword/index.taro.vue

@@ -17,13 +17,13 @@
       <view class="nut-input-w">
       <view class="nut-input-w">
         <input
         <input
           ref="realpwd"
           ref="realpwd"
-          class="nut-inputWx-real"
+          class="nut-input-real"
           type="number"
           type="number"
           :maxlength="length"
           :maxlength="length"
           v-model="realInput"
           v-model="realInput"
           @input="changeValue"
           @input="changeValue"
         />
         />
-        <view class="nut-shortpsd-fake">
+        <view class="nut-shortpsd-fake" @click="focus">
           <view
           <view
             class="nut-shortpsd-li"
             class="nut-shortpsd-li"
             v-for="(sublen, index) in new Array(comLen)"
             v-for="(sublen, index) in new Array(comLen)"
@@ -51,10 +51,10 @@
   </view>
   </view>
 </template>
 </template>
 <script lang="ts">
 <script lang="ts">
-import { ref, computed, watch } from 'vue';
+import { ref, computed, watch, onMounted } from 'vue';
 import { createComponent } from '@/packages/utils/create';
 import { createComponent } from '@/packages/utils/create';
 const { create } = createComponent('shortpassword');
 const { create } = createComponent('shortpassword');
-import Taro from '@tarojs/taro';
+import Taro, { eventCenter, getCurrentInstance } from '@tarojs/taro';
 export default create({
 export default create({
   props: {
   props: {
     title: {
     title: {
@@ -113,6 +113,10 @@ export default create({
     function sureClick() {
     function sureClick() {
       emit('ok', realInput.value);
       emit('ok', realInput.value);
     }
     }
+    function focus() {
+      let a = document.getElementsByClassName('nut-input-real')[0] as any;
+      a.focus();
+    }
     watch(
     watch(
       () => props.visible,
       () => props.visible,
       (value) => {
       (value) => {
@@ -146,6 +150,9 @@ export default create({
     function onTips() {
     function onTips() {
       emit('tips');
       emit('tips');
     }
     }
+    onMounted(() => {
+      eventCenter.once((getCurrentInstance() as any).router.onReady, () => {});
+    });
     return {
     return {
       comLen,
       comLen,
       sureClick,
       sureClick,
@@ -155,6 +162,7 @@ export default create({
       changeValue,
       changeValue,
       close,
       close,
       onTips,
       onTips,
+      focus,
       show,
       show,
       closeIcon
       closeIcon
     };
     };