hagerInput.vue
3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!--
* @Date: 2024-10-20 09:59:52
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-10-28 15:57:50
* @FilePath: /hager/src/components/common/hagerInput.vue
* @Description: 文件描述
-->
<template>
<div :class="['hager-input-page', required ? 'required': 'normal']">
<div :class="['input-box', disable ? 'disable': '']">
<div class="typeIcon" :style="{backgroundImage: 'url('+typeIcon+')'}"></div>
<input class="input" :value="value" @input="onInput" :type="type === 'pwd' ? 'password': 'text'" :disabled="disable" :placeholder="placeholder" />
<div v-if="reset" class="send" @click="resetPwd">发送验证码</div>
</div>
</div>
</template>
<script>
import mixin from 'common/mixin';
import { Message } from 'element-ui';
import { getCodeAPI } from "@/api/hager.js";
export default {
mixins: [mixin.init],
props: {
value: {
default: ''
},
placeholder: {
type: String,
default: '请输入内容'
},
type: {
type: String,
default: 'email'
},
required: {
type: Boolean,
default: false
},
disable: {
type: Boolean,
default: false
},
reset: {
type: Boolean,
default: false
}
},
data () {
return {
email: '',
pwd: '',
}
},
computed: {
typeIcon () {
switch (this.type) {
case 'email':
return 'https://cdn.ipadbiz.cn/hager/icon/input/%E9%82%AE%E7%AE%B1@2x.png';
case 'pwd':
return 'https://cdn.ipadbiz.cn/hager/icon/input/%E5%AF%86%E7%A0%81@2x.png';
case 'code':
return 'https://cdn.ipadbiz.cn/hager/icon/%E9%AA%8C%E8%AF%81%E7%A0%81@2x.png';
case 'username':
return 'https://cdn.ipadbiz.cn/hager/icon/input/%E5%A7%93%E5%90%8D@2x.png';
case 'tel':
return 'https://cdn.ipadbiz.cn/hager/icon/input/%E7%94%B5%E8%AF%9D@2x.png';
case 'corp':
return 'https://cdn.ipadbiz.cn/hager/icon/input/%E5%85%AC%E5%8F%B8@2x.png';
case 'department':
return 'https://cdn.ipadbiz.cn/hager/icon/input/%E8%81%8C%E4%BD%8D@2x.png';
}
}
},
mounted () {
},
methods: {
// 当输入框内容发生变化时,触发父组件的 `input` 事件
onInput(event) {
// 使用 $emit 触发 input 事件,传递新的输入值
this.$emit('input', event.target.value);
},
async resetPwd () {
this.$emit('send', this.value);
}
}
}
</script>
<style lang="less" scoped>
.hager-input-page {
display: flex;
align-items: center;
&.required::before {
content: '*';
color: #FF0000;
margin-right: 0.5rem;
}
&.normal {
// margin-left: 1rem;
}
&.normal::before {
content: '*';
color: #FFF;
margin-right: 0.5rem;
}
.input-box {
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box; /* 确保内边距和边框不会增加总宽度 */
background: #FFFFFF;
border-radius: 5px;
border: 1px solid #DADADA;
padding: 0.5rem 0.75rem;
width: 100%;
margin: 0.5rem 0;
&.disable {
background-color:#F9F9F9;
border: 1px solid #F9F9F9;
input {
background-color:#F9F9F9;
color: #666;
}
}
.typeIcon {
width: 1rem;
height: 0.9rem;
background-size: contain;
background-repeat: no-repeat;
background-position: center;
margin-right: 0.5rem;
}
.input {
border: 0;
flex: 1;
}
.send {
color: @secondary-color;
font-size: 0.8rem;
&:hover {
cursor: pointer;
}
}
}
}
</style>