22
schangxiang@126.com
2024-12-23 b6b3a245ee5159573a216affd79f449f3baa7d28
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
<template>
    <view class="width background_fff border_top_F2F2F2 flex align-center justify-between border_bottom_fff padding_surround">
        <view class="width70  flex align-center">
            <text class="fontSize32rpx margin_right10rpx iconfont icon-bar-code"></text>
            <input class="fontSize40rpx width" :focus="renamefocus" @focus='focuss' v-model="sacncode" @input="changeinput" @confirm="inputchange" 
            type="text" :placeholder="placeholder" />
        </view>
        <button style="padding: 0;background-color: unset;line-height: unset;border: unset;" 
        class="margin_right30rpx fontSize60rpx color_1989FA iconfont icon-saoma" 
         @click="tel()"></button>
    
    </view>
</template>
<script>
    // import {mixin} from '../utils/mixin.js'
    export default {
        name:"ScanCode",
        data() {
            return {
                renamefocus:true,//获取焦点
                sacncode:null,
                changecode:null
                };
        },
        // mixins:[mixin],
        props:{
            renameFocus:{
                type:Boolean,
                default:true
            },
            placeholder:{
                type:String,
                default:'请扫描盛具编码'
            }
        },
        onShow() {
            // setTimeout(() => {
            //     // 半毫秒后软键盘隐藏
            //     uni.hideKeyboard()
            // }, 10)
        },
        watch:{
            renameFocus:{
                handler(nv,ov){
                    this.renamefocus=nv
                },
                deep:true
            }
        },
        methods:{
            focuss() {
                // uni.hideKeyboard()
            },
            //扫码
            inputchange(event){
                uni.hideKeyboard()
                this.sacncode=event.target.value
                this.$emit('scancode',this.sacncode)
                
            },
            //模糊查询
            changeinput(event){
                // uni.hideKeyboard()
                this.changecode=event.target.value
                this.$emit('changecode',this.changecode)
                
            },
            //调用摄像头扫码
            tel(){
                // uni.scanCode({
                //     success:function(res){
                //         this.sacncode=JSON.stringify(res)
                //             console.log(JSON.stringify(res));
                //         },
                //         fail(res) {
                //             console.log(res)
                //         }
                // });
            },
            clearinquer(event){
                // setTimeout(()=>{
                    this.sacncode=''
                    // this.renamefocus=true
                    uni.hideKeyboard()
                // },500)
            }
        }
    }
</script>
 
<style lang="scss">
 
.uni-button{
    padding: 0 !important;
}
</style>