<template>
    <view>
        <view class="uni-padding-wrap uni-common-mt">

            <view class="uni-form-item uni-column">

                <text class="title uni-center">从文本框输入垃圾关键字查询</text>
                <view class="weui-cells weui-cells_after-title">
                    <view class="weui-cell ">
                        <view class="weui-cell__bd">
                            <input class="weui-input" v-model="textValue" placeholder="请输入垃圾关键字" @input="changeTextQuery" />
                        </view>
                    </view>
                </view>
            </view>

            <view class="uni-flex uni-column">
                <text class="title uni-center">点击图标拍照查询</text>
                <view class="flex-item flex-item-V uni-center">
                <image class="photo"  @click="chooseImage"></image>
                </view>
            </view>

        </view>
    </view>
</template>

<script>
    export default {
        name: "query",
        data:function(){
            return {
                title:"垃圾分类查询",
                textValue:""
            }
        },
        methods:{
            changeTextQuery:function () {
                console.info("文本查询值："+this.textValue)
            },
            chooseImage:function () {
                console.info("拍照查询")
                uni.authorize({
                    scope:"scope.camera",
                    success:function () {
                        console.info("摄像头调用成功")
                        uni.chooseImage({
                            sourceType:["camera"],
                            success:function (obj) {
                                console.info("拍照成功，照片路径"+obj.tempFilePaths[0])
                            },
                            fail:function () {
                                console.error("拍照失败")
                            }
                        })
                    },
                    fail:function () {
                        console.error("授权摄像头权限失败，请刷新页面重新授权")
                    }
                })
            }
        }
    }
</script>

<style scoped>
   .photo{
       background-image:url("~@/static/photo.png");
       background-size: 100% 100%;
       width: 100%;
   }
    text{
        font-size: 15px;
    }
</style>