赵明涛
12 months ago
5 changed files with 359 additions and 272 deletions
-
73uniapp_project_code/src/components/index/keyboard/input_box_QR.vue
-
141uniapp_project_code/src/components/index/keyboard/view_keyboard.vue
-
5uniapp_project_code/src/pages/index/index.nvue
-
BINuniapp_project_code/src/static/index/del_btn.png
@ -0,0 +1,141 @@ |
|||
<template> |
|||
<view class="i-keyboard"> |
|||
<view class="num-btn" v-for="i in 11" |
|||
:class="[getNumBtnClass(i),{'active-value':(activeValue == i) }]" @click="clickKeyboard(i)"> |
|||
<text class="txt" v-if="(i<11)">{{getNumClick(i)}}</text> |
|||
<image class="img" v-else src="/static/index/del_btn.png" mode="widthFix" /> |
|||
</view> |
|||
</view> |
|||
</template> |
|||
|
|||
<script setup> |
|||
import util from "@/utils/util.js" |
|||
|
|||
import { |
|||
onMounted, |
|||
ref |
|||
} from 'vue' |
|||
|
|||
//触发自定义事件 |
|||
const emits = defineEmits(['inputValueUpdate']) |
|||
const props = defineProps({ |
|||
maxInput: { |
|||
type: Number, |
|||
default: 11 |
|||
}, |
|||
// inputValue : { |
|||
// type: Number, |
|||
// default: 11 |
|||
// }, |
|||
}) |
|||
|
|||
let inputValue = ref("") // |
|||
let activeValue = ref("") // |
|||
|
|||
onMounted(async (res) => { |
|||
console.log(res + ` the keyboard_box component is now mounted. ` + props.maskHeight) |
|||
}) |
|||
|
|||
const handle_closeKeyboardBox = () => { |
|||
emits("showIt", "false") |
|||
} |
|||
|
|||
const getNumBtnClass = (i) => { |
|||
if (i == 11) { |
|||
return "num-btn-last-child" |
|||
} |
|||
return "num-btn" |
|||
} |
|||
// getInputClass |
|||
const getInputClass = () => { |
|||
if (inputValue.value == "") { |
|||
return "txt-blank" |
|||
} |
|||
return "txt-write" |
|||
} |
|||
const getNumClick = (i) => { |
|||
if (i <= 9) return i |
|||
if (i == 10) return "0" |
|||
if (i == 11) return "" //delete |
|||
} |
|||
//click keyboard |
|||
const clickKeyboard = util.debounce((i) => { |
|||
console.log("clickKeyboard:", i) |
|||
// add input react |
|||
activeValue.value = i |
|||
setTimeout(() => { |
|||
activeValue.value = "" |
|||
}, 100) |
|||
|
|||
if (i == 11) { //handle delete input |
|||
inputValue.value = inputValue.value.substring(0, inputValue.value.length - 1) |
|||
} else { |
|||
//limit maxInput |
|||
if (inputValue.value.length >= props.maxInput) { |
|||
return util.showNone(`最大输入${props.maxInput}位`) |
|||
} |
|||
inputValue.value += getNumClick(i) |
|||
} |
|||
emits("inputValueUpdate", inputValue.value) |
|||
}, 20, true) |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
|
|||
.i-keyboard { |
|||
// width: 232.69rpx; |
|||
// height: 317.53rpx; |
|||
width: 260rpx; |
|||
// background-color: beige; |
|||
@include ctf(flex-start); |
|||
flex-direction: row; |
|||
flex-wrap: wrap; |
|||
|
|||
.num-btn { |
|||
width: 64rpx; |
|||
height: 64rpx; |
|||
background: #FFFFFF; |
|||
box-shadow: 0 2.08rpx 0 0 #00000033; |
|||
border-radius: 3rpx; |
|||
@include ctf(center); |
|||
margin: 11rpx; |
|||
|
|||
.txt { |
|||
font-weight: 800; |
|||
font-size: 44rpx; |
|||
color: #000000; |
|||
} |
|||
} |
|||
|
|||
.num-btn-last-child { |
|||
width: 150rpx; |
|||
background: #D1D6D8; |
|||
|
|||
.img { |
|||
width: 47.5rpx; |
|||
height: 38rpx; |
|||
// background: #454A52; |
|||
} |
|||
} |
|||
|
|||
.active-value { |
|||
background: #009874; |
|||
} |
|||
|
|||
.del-btn { |
|||
width: 69.44rpx; |
|||
height: 69.44rpx; |
|||
background: #FFFFFF; |
|||
border-radius: 6.94rpx; |
|||
@include ctf(center); |
|||
margin: 10rpx; |
|||
|
|||
.txt { |
|||
font-weight: 500; |
|||
font-size: 25rpx; |
|||
color: #333333; |
|||
} |
|||
} |
|||
} |
|||
|
|||
</style> |
After Width: 95 | Height: 76 | Size: 3.9 KiB |
Write
Preview
Loading…
Cancel
Save
Reference in new issue