You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.8 KiB
Vue

<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:'',
}
},
onShow(){
console.log('ererer')
uni.login({
provider: 'weixin',
success(res) {
console.log(res,'resssssss')
},
fail(err) {
}
});
},
onLoad(options){
this.sn=options.sn
this.getPhoto()
},
methods:{
changeSwitch(data){
uni.request({
method:'post',
responseType: 'arraybuffer',
url:'https://erpapi.fontree.cn/secret/set/door',
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',
url:'https://erpapi.fontree.cn/secret/batch/capture/photo',
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>