|
@@ -1,12 +1,12 @@
|
|
|
<template>
|
|
<template>
|
|
|
<view>
|
|
<view>
|
|
|
<nut-dialog
|
|
<nut-dialog
|
|
|
- title="请输入密码"
|
|
|
|
|
- :visible="dialogShow"
|
|
|
|
|
|
|
+ :title="title"
|
|
|
|
|
+ :visible="isVisible"
|
|
|
@ok-btn-click="sureClick"
|
|
@ok-btn-click="sureClick"
|
|
|
- @cancel-btn-click="dialogShow = false"
|
|
|
|
|
|
|
+ @cancel-btn-click="close"
|
|
|
@close="close"
|
|
@close="close"
|
|
|
- :noFooter="noButton"
|
|
|
|
|
|
|
+ :no-footer="noButton"
|
|
|
>
|
|
>
|
|
|
<view class="nut-shortpsd-subtitle">您使用了虚拟资产,请进行验证</view>
|
|
<view class="nut-shortpsd-subtitle">您使用了虚拟资产,请进行验证</view>
|
|
|
<view class="nut-input-w">
|
|
<view class="nut-input-w">
|
|
@@ -19,43 +19,39 @@
|
|
|
@input="changeValue"
|
|
@input="changeValue"
|
|
|
/>
|
|
/>
|
|
|
<view class="nut-shortpsd-fake" @click="focus">
|
|
<view class="nut-shortpsd-fake" @click="focus">
|
|
|
- <view class="nut-shortpsd-li"
|
|
|
|
|
- ><view class="nut-shortpsd-icon" v-if="realInput.length > 0"></view
|
|
|
|
|
- ></view>
|
|
|
|
|
- <view class="nut-shortpsd-li"
|
|
|
|
|
- ><view class="nut-shortpsd-icon" v-if="realInput.length > 1"></view
|
|
|
|
|
- ></view>
|
|
|
|
|
- <view class="nut-shortpsd-li"
|
|
|
|
|
- ><view class="nut-shortpsd-icon" v-if="realInput.length > 2"></view
|
|
|
|
|
- ></view>
|
|
|
|
|
- <view class="nut-shortpsd-li"
|
|
|
|
|
- ><view class="nut-shortpsd-icon" v-if="realInput.length > 3"></view
|
|
|
|
|
- ></view>
|
|
|
|
|
- <view v-if="length >= 5" class="nut-shortpsd-li"
|
|
|
|
|
- ><view class="nut-shortpsd-icon" v-if="realInput.length > 4"></view
|
|
|
|
|
- ></view>
|
|
|
|
|
- <view v-if="length == 6" class="nut-shortpsd-li"
|
|
|
|
|
- ><view class="nut-shortpsd-icon" v-if="realInput.length > 5"></view
|
|
|
|
|
- ></view>
|
|
|
|
|
|
|
+ <view
|
|
|
|
|
+ class="nut-shortpsd-li"
|
|
|
|
|
+ v-for="(sublen, index) in new Array(comLen)"
|
|
|
|
|
+ v-bind:key="index"
|
|
|
|
|
+ >
|
|
|
|
|
+ <view
|
|
|
|
|
+ class="nut-shortpsd-icon"
|
|
|
|
|
+ v-if="realInput.length > index"
|
|
|
|
|
+ ></view>
|
|
|
|
|
+ </view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="nut-shortpsd-message">
|
|
<view class="nut-shortpsd-message">
|
|
|
<view class="nut-shortpsd-error">{{ errorMsg }}</view>
|
|
<view class="nut-shortpsd-error">{{ errorMsg }}</view>
|
|
|
- <view class="nut-shortpsd-forget">
|
|
|
|
|
- <nut-icon class="icon" size="11px" name="tips"></nut-icon
|
|
|
|
|
- >忘记密码</view
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <view class="nut-shortpsd-forget" v-if="showPasswordTips">
|
|
|
|
|
+ <nut-icon class="icon" size="11px" name="tips"></nut-icon>
|
|
|
|
|
+ <view @click="link">忘记密码</view>
|
|
|
|
|
+ </view>
|
|
|
</view>
|
|
</view>
|
|
|
</nut-dialog>
|
|
</nut-dialog>
|
|
|
</view>
|
|
</view>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
<script lang="ts">
|
|
|
-import { ref, onMounted, watch, reactive, watchEffect } from 'vue';
|
|
|
|
|
|
|
+import { ref, watch, computed } from 'vue';
|
|
|
import { createComponent } from '@/utils/create';
|
|
import { createComponent } from '@/utils/create';
|
|
|
const { create } = createComponent('shortpassword');
|
|
const { create } = createComponent('shortpassword');
|
|
|
export default create({
|
|
export default create({
|
|
|
props: {
|
|
props: {
|
|
|
|
|
+ title: {
|
|
|
|
|
+ type: String,
|
|
|
|
|
+ default: '请输入密码'
|
|
|
|
|
+ },
|
|
|
isVisible: {
|
|
isVisible: {
|
|
|
type: Boolean,
|
|
type: Boolean,
|
|
|
default: false
|
|
default: false
|
|
@@ -73,17 +69,33 @@ export default create({
|
|
|
default: true
|
|
default: true
|
|
|
},
|
|
},
|
|
|
length: {
|
|
length: {
|
|
|
- type: String || Number,
|
|
|
|
|
|
|
+ type: [String, Number], //4~6
|
|
|
default: 6
|
|
default: 6
|
|
|
|
|
+ },
|
|
|
|
|
+ showPasswordTips: {
|
|
|
|
|
+ type: Boolean,
|
|
|
|
|
+ default: true
|
|
|
|
|
+ },
|
|
|
|
|
+ link: {
|
|
|
|
|
+ type: String,
|
|
|
|
|
+ default: ''
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ emits: [
|
|
|
|
|
+ 'sure-click',
|
|
|
|
|
+ 'update:value',
|
|
|
|
|
+ 'update:is-visible',
|
|
|
|
|
+ 'complete',
|
|
|
|
|
+ 'input'
|
|
|
|
|
+ ],
|
|
|
setup(props, { emit }) {
|
|
setup(props, { emit }) {
|
|
|
- const dialogShow = ref(false);
|
|
|
|
|
const realInput = ref(props.value);
|
|
const realInput = ref(props.value);
|
|
|
const realpwd = ref();
|
|
const realpwd = ref();
|
|
|
|
|
+ const comLen = computed(() => range(Number(props.length)));
|
|
|
|
|
+
|
|
|
// 方法
|
|
// 方法
|
|
|
function sureClick() {
|
|
function sureClick() {
|
|
|
- emit('sureClick');
|
|
|
|
|
|
|
+ emit('sure-click', realInput.value);
|
|
|
}
|
|
}
|
|
|
function focus() {
|
|
function focus() {
|
|
|
realpwd.value.focus();
|
|
realpwd.value.focus();
|
|
@@ -91,36 +103,35 @@ export default create({
|
|
|
function changeValue(e: Event) {
|
|
function changeValue(e: Event) {
|
|
|
const input = e.target as HTMLInputElement;
|
|
const input = e.target as HTMLInputElement;
|
|
|
let val = input.value;
|
|
let val = input.value;
|
|
|
- if (val.length > Number(props.length)) {
|
|
|
|
|
- val = val.slice(0, Number(props.length));
|
|
|
|
|
|
|
+ if (val.length > comLen.value) {
|
|
|
|
|
+ val = val.slice(0, comLen.value);
|
|
|
|
|
+ realInput.value = val;
|
|
|
}
|
|
}
|
|
|
- if (realInput.value.length > Number(props.length)) {
|
|
|
|
|
- realInput.value = realInput.value.slice(0, Number(props.length));
|
|
|
|
|
|
|
+ if (realInput.value.length === comLen.value) {
|
|
|
|
|
+ emit('complete', val);
|
|
|
}
|
|
}
|
|
|
emit('input', val);
|
|
emit('input', val);
|
|
|
emit('update:value', val);
|
|
emit('update:value', val);
|
|
|
}
|
|
}
|
|
|
function close() {
|
|
function close() {
|
|
|
- emit('update:isVisible', false);
|
|
|
|
|
|
|
+ emit('update:is-visible', false);
|
|
|
|
|
+ }
|
|
|
|
|
+ function range(val: number) {
|
|
|
|
|
+ return Math.min(Math.max(4, val), 6);
|
|
|
|
|
+ }
|
|
|
|
|
+ function link() {
|
|
|
|
|
+ if (props.link) window.location.href = props.link;
|
|
|
}
|
|
}
|
|
|
- watch(
|
|
|
|
|
- () => props.isVisible,
|
|
|
|
|
- val => {
|
|
|
|
|
- if (val) {
|
|
|
|
|
- dialogShow.value = true;
|
|
|
|
|
- } else {
|
|
|
|
|
- dialogShow.value = false;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- );
|
|
|
|
|
return {
|
|
return {
|
|
|
- dialogShow,
|
|
|
|
|
|
|
+ comLen,
|
|
|
sureClick,
|
|
sureClick,
|
|
|
realInput,
|
|
realInput,
|
|
|
realpwd,
|
|
realpwd,
|
|
|
focus,
|
|
focus,
|
|
|
|
|
+ range,
|
|
|
changeValue,
|
|
changeValue,
|
|
|
- close
|
|
|
|
|
|
|
+ close,
|
|
|
|
|
+ link
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|