2023-12-29 06:00:06 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<tm-sheet >
|
|
|
|
<tm-alerts :label="`当前设备编号:${sn}`" close></tm-alerts>
|
|
|
|
<div style="display: flex;flex-direction: column;align-items: center">
|
|
|
|
<tm-images :src="imgUrl"></tm-images>
|
|
|
|
<tm-button @click="getPhoto" >获取当前照片</tm-button>
|
|
|
|
</div>
|
|
|
|
<tm-listitem title="开关门">
|
|
|
|
<template v-slot:rightIcon="">
|
|
|
|
<tm-switch :width="260" :height="80" offBgcolor="blue" :text="['打开','关闭']" v-model="switchValue" @change="changeSwitch" ></tm-switch>
|
|
|
|
</template>
|
|
|
|
</tm-listitem>
|
|
|
|
</tm-sheet>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: "index",
|
|
|
|
data(){
|
|
|
|
return{
|
|
|
|
sn:'',
|
|
|
|
switchValue:false,
|
|
|
|
imgUrl:'',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onLoad(options){
|
|
|
|
this.sn=options.sn
|
|
|
|
this.getPhoto()
|
|
|
|
},
|
|
|
|
methods:{
|
|
|
|
changeSwitch(data){
|
|
|
|
uni.request({
|
|
|
|
method:'post',
|
|
|
|
responseType: 'arraybuffer',
|
2023-12-29 06:04:20 +00:00
|
|
|
url:'https://erpapi.fontree.cn/secret/set/door',
|
2023-12-29 06:00:06 +00:00
|
|
|
data:{deviceNum:this.sn,value:data.checked?'on':'off'},
|
|
|
|
complete:(res)=>{
|
|
|
|
if (res.statusCode===200){
|
|
|
|
uni.showToast({ title: '操作成功', icon: 'none' });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getPhoto(){
|
|
|
|
uni.request({
|
|
|
|
method:'post',
|
|
|
|
responseType: 'arraybuffer',
|
2023-12-29 06:04:20 +00:00
|
|
|
url:'https://erpapi.fontree.cn/secret/batch/capture/photo',
|
2023-12-29 06:00:06 +00:00
|
|
|
data:{deviceNum:this.sn},
|
|
|
|
complete:(res)=>{
|
|
|
|
const arrayBuffer = new Uint8Array(res.data)
|
|
|
|
this.imgUrl = "data:image/png;base64," + uni.arrayBufferToBase64(arrayBuffer)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
|
|
|
</style>
|