mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 20:28:44 +08:00 
			
		
		
		
	使用 uview 重构实际登陆
This commit is contained in:
		@@ -0,0 +1,84 @@
 | 
			
		||||
export default {
 | 
			
		||||
    props: {
 | 
			
		||||
        // 键盘的类型,number-数字键盘,card-身份证键盘,car-车牌号键盘
 | 
			
		||||
        mode: {
 | 
			
		||||
            type: String,
 | 
			
		||||
            default: uni.$u.props.keyboard.mode
 | 
			
		||||
        },
 | 
			
		||||
        // 是否显示键盘的"."符号
 | 
			
		||||
        dotDisabled: {
 | 
			
		||||
            type: Boolean,
 | 
			
		||||
            default: uni.$u.props.keyboard.dotDisabled
 | 
			
		||||
        },
 | 
			
		||||
        // 是否显示顶部工具条
 | 
			
		||||
        tooltip: {
 | 
			
		||||
            type: Boolean,
 | 
			
		||||
            default: uni.$u.props.keyboard.tooltip
 | 
			
		||||
        },
 | 
			
		||||
        // 是否显示工具条中间的提示
 | 
			
		||||
        showTips: {
 | 
			
		||||
            type: Boolean,
 | 
			
		||||
            default: uni.$u.props.keyboard.showTips
 | 
			
		||||
        },
 | 
			
		||||
        // 工具条中间的提示文字
 | 
			
		||||
        tips: {
 | 
			
		||||
            type: String,
 | 
			
		||||
            default: uni.$u.props.keyboard.tips
 | 
			
		||||
        },
 | 
			
		||||
        // 是否显示工具条左边的"取消"按钮
 | 
			
		||||
        showCancel: {
 | 
			
		||||
            type: Boolean,
 | 
			
		||||
            default: uni.$u.props.keyboard.showCancel
 | 
			
		||||
        },
 | 
			
		||||
        // 是否显示工具条右边的"完成"按钮
 | 
			
		||||
        showConfirm: {
 | 
			
		||||
            type: Boolean,
 | 
			
		||||
            default: uni.$u.props.keyboard.showConfirm
 | 
			
		||||
        },
 | 
			
		||||
        // 是否打乱键盘按键的顺序
 | 
			
		||||
        random: {
 | 
			
		||||
            type: Boolean,
 | 
			
		||||
            default: uni.$u.props.keyboard.random
 | 
			
		||||
        },
 | 
			
		||||
        // 是否开启底部安全区适配,开启的话,会在iPhoneX机型底部添加一定的内边距
 | 
			
		||||
        safeAreaInsetBottom: {
 | 
			
		||||
            type: Boolean,
 | 
			
		||||
            default: uni.$u.props.keyboard.safeAreaInsetBottom
 | 
			
		||||
        },
 | 
			
		||||
        // 是否允许通过点击遮罩关闭键盘
 | 
			
		||||
        closeOnClickOverlay: {
 | 
			
		||||
            type: Boolean,
 | 
			
		||||
            default: uni.$u.props.keyboard.closeOnClickOverlay
 | 
			
		||||
        },
 | 
			
		||||
        // 控制键盘的弹出与收起
 | 
			
		||||
        show: {
 | 
			
		||||
            type: Boolean,
 | 
			
		||||
            default: uni.$u.props.keyboard.show
 | 
			
		||||
        },
 | 
			
		||||
        // 是否显示遮罩,某些时候数字键盘时,用户希望看到自己的数值,所以可能不想要遮罩
 | 
			
		||||
        overlay: {
 | 
			
		||||
            type: Boolean,
 | 
			
		||||
            default: uni.$u.props.keyboard.overlay
 | 
			
		||||
        },
 | 
			
		||||
        // z-index值
 | 
			
		||||
        zIndex: {
 | 
			
		||||
            type: [String, Number],
 | 
			
		||||
            default: uni.$u.props.keyboard.zIndex
 | 
			
		||||
        },
 | 
			
		||||
        // 取消按钮的文字
 | 
			
		||||
        cancelText: {
 | 
			
		||||
            type: String,
 | 
			
		||||
            default: uni.$u.props.keyboard.cancelText
 | 
			
		||||
        },
 | 
			
		||||
        // 确认按钮的文字
 | 
			
		||||
        confirmText: {
 | 
			
		||||
            type: String,
 | 
			
		||||
            default: uni.$u.props.keyboard.confirmText
 | 
			
		||||
        },
 | 
			
		||||
        // 输入一个中文后,是否自动切换到英文
 | 
			
		||||
        autoChange: {
 | 
			
		||||
            type: Boolean,
 | 
			
		||||
            default: uni.$u.props.keyboard.autoChange
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,164 @@
 | 
			
		||||
<template>
 | 
			
		||||
	<u-popup
 | 
			
		||||
	    :overlay="overlay"
 | 
			
		||||
	    :closeOnClickOverlay="closeOnClickOverlay"
 | 
			
		||||
	    mode="bottom"
 | 
			
		||||
	    :popup="false"
 | 
			
		||||
	    :show="show"
 | 
			
		||||
	    :safeAreaInsetBottom="safeAreaInsetBottom"
 | 
			
		||||
	    @close="popupClose"
 | 
			
		||||
	    :zIndex="zIndex"
 | 
			
		||||
	    :customStyle="{
 | 
			
		||||
			backgroundColor: 'rgb(214, 218, 220)'
 | 
			
		||||
		}"
 | 
			
		||||
	>
 | 
			
		||||
		<view class="u-keyboard">
 | 
			
		||||
			<slot />
 | 
			
		||||
			<view
 | 
			
		||||
			    class="u-keyboard__tooltip"
 | 
			
		||||
			    v-if="tooltip"
 | 
			
		||||
			>
 | 
			
		||||
				<view
 | 
			
		||||
				    hover-class="u-hover-class"
 | 
			
		||||
				    :hover-stay-time="100"
 | 
			
		||||
				>
 | 
			
		||||
					<text
 | 
			
		||||
					    class="u-keyboard__tooltip__item u-keyboard__tooltip__cancel"
 | 
			
		||||
					    v-if="showCancel"
 | 
			
		||||
					    @tap="onCancel"
 | 
			
		||||
					>{{showCancel && cancelText}}</text>
 | 
			
		||||
				</view>
 | 
			
		||||
				<view>
 | 
			
		||||
					<text
 | 
			
		||||
					    v-if="showTips"
 | 
			
		||||
					    class="u-keyboard__tooltip__item u-keyboard__tooltip__tips"
 | 
			
		||||
					>{{tips ? tips : mode == 'number' ? '数字键盘' : mode == 'card' ? '身份证键盘' : '车牌号键盘'}}</text>
 | 
			
		||||
				</view>
 | 
			
		||||
				<view
 | 
			
		||||
				    hover-class="u-hover-class"
 | 
			
		||||
				    :hover-stay-time="100"
 | 
			
		||||
				>
 | 
			
		||||
					<text
 | 
			
		||||
					    v-if="showConfirm"
 | 
			
		||||
					    @tap="onConfirm"
 | 
			
		||||
					    class="u-keyboard__tooltip__item u-keyboard__tooltip__submit"
 | 
			
		||||
					    hover-class="u-hover-class"
 | 
			
		||||
					>{{showConfirm && confirmText}}</text>
 | 
			
		||||
				</view>
 | 
			
		||||
			</view>
 | 
			
		||||
			<template v-if="mode == 'number' || mode == 'card'">
 | 
			
		||||
				<u-number-keyboard
 | 
			
		||||
				    :random="random"
 | 
			
		||||
				    @backspace="backspace"
 | 
			
		||||
				    @change="change"
 | 
			
		||||
				    :mode="mode"
 | 
			
		||||
				    :dotDisabled="dotDisabled"
 | 
			
		||||
				></u-number-keyboard>
 | 
			
		||||
			</template>
 | 
			
		||||
			<template v-else>
 | 
			
		||||
				<u-car-keyboard
 | 
			
		||||
				    :random="random"
 | 
			
		||||
					:autoChange="autoChange"
 | 
			
		||||
				    @backspace="backspace"
 | 
			
		||||
				    @change="change"
 | 
			
		||||
				></u-car-keyboard>
 | 
			
		||||
			</template>
 | 
			
		||||
		</view>
 | 
			
		||||
	</u-popup>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
	import props from './props.js';
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * keyboard 键盘
 | 
			
		||||
	 * @description 此为uViw自定义的键盘面板,内含了数字键盘,车牌号键,身份证号键盘3中模式,都有可以打乱按键顺序的选项。
 | 
			
		||||
	 * @tutorial https://www.uviewui.com/components/keyboard.html
 | 
			
		||||
	 * @property {String}			mode				键盘类型,见官网基本使用的说明 (默认 'number' )
 | 
			
		||||
	 * @property {Boolean}			dotDisabled			是否显示"."按键,只在mode=number时有效 (默认 true )
 | 
			
		||||
	 * @property {Boolean}			tooltip				是否显示键盘顶部工具条 (默认 true )
 | 
			
		||||
	 * @property {Boolean}			showTips			是否显示工具条中间的提示 (默认 true )
 | 
			
		||||
	 * @property {String}			tips				工具条中间的提示文字,见上方基本使用的说明,如不需要,请传""空字符
 | 
			
		||||
	 * @property {Boolean}			showCancel			是否显示工具条左边的"取消"按钮 (默认 true )
 | 
			
		||||
	 * @property {Boolean}			showConfirm			是否显示工具条右边的"完成"按钮( 默认 true )
 | 
			
		||||
	 * @property {Boolean}			random				是否打乱键盘按键的顺序 (默认 false )
 | 
			
		||||
	 * @property {Boolean}			safeAreaInsetBottom	是否开启底部安全区适配 (默认 true )
 | 
			
		||||
	 * @property {Boolean}			closeOnClickOverlay	是否允许点击遮罩收起键盘 (默认 true )
 | 
			
		||||
	 * @property {Boolean}			show				控制键盘的弹出与收起(默认 false )
 | 
			
		||||
	 * @property {Boolean}			overlay				是否显示遮罩 (默认 true )
 | 
			
		||||
	 * @property {String | Number}	zIndex				弹出键盘的z-index值 (默认 1075 )
 | 
			
		||||
	 * @property {String}			cancelText			取消按钮的文字 (默认 '取消' )
 | 
			
		||||
	 * @property {String}			confirmText			确认按钮的文字 (默认 '确认' )
 | 
			
		||||
	 * @property {Object}			customStyle			自定义样式,对象形式
 | 
			
		||||
	 * @event {Function} change 按键被点击(不包含退格键被点击)
 | 
			
		||||
	 * @event {Function} cancel 键盘顶部工具条左边的"取消"按钮被点击
 | 
			
		||||
	 * @event {Function} confirm 键盘顶部工具条右边的"完成"按钮被点击
 | 
			
		||||
	 * @event {Function} backspace 键盘退格键被点击
 | 
			
		||||
	 * @example <u-keyboard mode="number" v-model="show"></u-keyboard>
 | 
			
		||||
	 */
 | 
			
		||||
	export default {
 | 
			
		||||
		name: "u-keyboard",
 | 
			
		||||
		data() {
 | 
			
		||||
			return {
 | 
			
		||||
 | 
			
		||||
			}
 | 
			
		||||
		},
 | 
			
		||||
		mixins: [uni.$u.mpMixin, uni.$u.mixin,props],
 | 
			
		||||
		methods: {
 | 
			
		||||
			change(e) {
 | 
			
		||||
				this.$emit('change', e);
 | 
			
		||||
			},
 | 
			
		||||
			// 键盘关闭
 | 
			
		||||
			popupClose() {
 | 
			
		||||
				this.$emit('close');
 | 
			
		||||
			},
 | 
			
		||||
			// 输入完成
 | 
			
		||||
			onConfirm() {
 | 
			
		||||
				this.$emit('confirm');
 | 
			
		||||
			},
 | 
			
		||||
			// 取消输入
 | 
			
		||||
			onCancel() {
 | 
			
		||||
				this.$emit('cancel');
 | 
			
		||||
			},
 | 
			
		||||
			// 退格键
 | 
			
		||||
			backspace() {
 | 
			
		||||
				this.$emit('backspace');
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<style lang="scss" scoped>
 | 
			
		||||
	@import "../../libs/css/components.scss";
 | 
			
		||||
 | 
			
		||||
	.u-keyboard {
 | 
			
		||||
 | 
			
		||||
		&__tooltip {
 | 
			
		||||
			@include flex;
 | 
			
		||||
			justify-content: space-between;
 | 
			
		||||
			background-color: #FFFFFF;
 | 
			
		||||
			padding: 14px 12px;
 | 
			
		||||
 | 
			
		||||
			&__item {
 | 
			
		||||
				color: #333333;
 | 
			
		||||
				flex: 1;
 | 
			
		||||
				text-align: center;
 | 
			
		||||
				font-size: 15px;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			&__submit {
 | 
			
		||||
				text-align: right;
 | 
			
		||||
				color: $u-primary;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			&__cancel {
 | 
			
		||||
				text-align: left;
 | 
			
		||||
				color: #888888;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			&__tips {
 | 
			
		||||
				color: $u-tips-color;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
</style>
 | 
			
		||||
		Reference in New Issue
	
	Block a user