Files
Wx_BLWConfigTools_V01_Prod/pages/test/test.js

647 lines
14 KiB
JavaScript
Raw Normal View History

2025-12-11 09:50:45 +08:00
const app = getApp()
//导入测试请求发方法
import {
OpenDoorTest,
RestartTheDevice,
GeteDeviceInfomation,
DeletePeopleFromDeviceByGroup,
GetThePeopleListOfDevice,
openRommCheckin,
roomCheckOut,GetFaceSN
} from '../../lib/RequestingCenter.js'
// pages/test/test.js
Page({
/**
* 页面的初始数据
*/
data: {
imgList:[],
cout:1,
isbut:false,
isbuts:false,
count:1,
//测试信息
sn:"",
hid:"",
HotelId:"",
HotelName:"",
Roomid:"",
openUserName:"李四",
openUserID:"123456789456123456",
openUserSex:"1",
outUserName:"",
outUserID:"",
imgurl:"",
openUserTel:"15915641569",
RoomNO:"",
faceadd:""
},
isCard(e) {
if(this.data.isCardds==this.data.isCard){
this.setData({
isCard: e.detail.value,
isCardds:!e.detail.value
})
}else{
this.setData({
isCard: e.detail.value,
isCardds:""
})
}
// this.setData({
// isCard: e.detail.value
// })
},
isCardds(e){
if(this.data.isCardds==this.data.isCard){
this.setData({
isCard: !e.detail.value,
isCardds:e.detail.value
})
}else{
this.setData({
isCard: "",
isCardds:e.detail.value
})
}
},
//开房测试
OpenRoom:function(params){
this.setData({
islogs: false,
openrom: !this.data.openrom
})
//调用打开摄像头代码
// wx.chooseMedia({
// count: 1, // 可以选择的图片数量
// sizeType: ['compressed'], // 可以指定是原图还是压缩图
// sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机
// success: function (res) {
// // 将拍照后的照片保存在本地文件夹中
// var tempFilePaths = res.tempFiles[0].tempFilePath
// console.log(res.tempFiles[0].tempFilePath)
// wx.uploadFile({
// url: 'http://localhost:56306/ImgServer/Update',//开发者放服务地址
// filePath: tempFilePaths,
// name: 'file',
// success: function (res) {
// var data = res.data;
// console.log(data);
// },
// fail: function (res) {
// console.log(res);
// }
// })
// }
// })
//授权获取用户摄像头权限
},
ViewImage(e) {
wx.previewImage({
urls: this.data.imgList,
current: e.currentTarget.dataset.url
});
},
ChooseImage() {
console.log(111111111111)
var that =this;
wx.chooseImage({
count: 1, //默认9
sizeType: ['original'], //可以指定是原图还是压缩图,默认二者都有,'compressed'
sourceType: ['camera'], //从相册选择camera,album
camera: 'front',
success: (res) => {
console.log(res.tempFilePaths)
if (that.data.imgList.length != 0) {
that.setData({
imgList: that.data.imgList.concat(res.tempFilePaths)
})
} else {
that.setData({
imgList: res.tempFilePaths
})
}
console.log(that.data.imgList)
// https://auth.blv-oa.com/Wx/Update
// http://auth.blv-oa.com/Wx/Update
wx.uploadFile({
url: 'https://auth.blv-oa.com/Wx/Update',//开发者放服务地址
filePath: that.data.imgList[0],
name: 'file',
success: function (res) {
var data = res.data;
console.log(res)
data=JSON.parse(data)
console.log(data.data.src)
that.setData({
imgurl:data.data.src
})
},
fail: function (res) {
console.log(res);
}
})
},
fail:(res)=>{
console.log(res)
}
});
// wx.authorize({
// scope: 'scope.camera',
// success: function () {
// console.log("授权成功");
// // wx.chooseMedia({
// // count: 1,
// // mediaType: ['image'],
// // sourceType: ['album'],
// // maxDuration: 30,
// // camera: 'front',
// // success(res) {
// // console.log(res.tempFiles)
// // // console.log(res.tempFiles[0].tempFilePath)
// // // console.log(res.tempFiles[0].size)
// // if (that.data.imgList.length != 0) {
// // that.setData({
// // imgList: that.data.imgList.concat(res.tempFiles[0].tempFilePath)
// // })
// // } else {
// // that.setData({
// // imgList: res.tempFiles[0].tempFilePath
// // })
// // }
// // console.log(that.data.imgList)
// // // wx.uploadFile({
// // // url: 'https://auth.blv-oa.com/Wx/Update',//开发者放服务地址
// // // filePath: that.data.imgList[0],
// // // name: 'file',
// // // success: function (res) {
// // // var data = res.data;
// // // console.log(res)
// // // data=JSON.parse(data)
// // // console.log(data.data.src)
// // // that.setData({
// // // imgurl:data.data.src
// // // })
// // // },
// // // fail: function (res) {
// // // console.log(res);
// // // }
// // // })
// // }
// // })
// },
// fail: function (err) {
// console.log(err);
// }
// })
},
DelImg(e) {
wx.showModal({
title: '',
content: '确定要删除这张照片吗?',
cancelText: '再看看',
confirmText: '再见',
success: res => {
if (res.confirm) {
this.data.imgList.splice(e.currentTarget.dataset.index, 1);
this.setData({
imgList: this.data.imgList
})
}
}
})
},
radioChang:function(e){
console.log("radio发生change事件携带value值为", e.detail.value)
this.setData({
openUserSex:e.detail.value
})
},
/// <summary>
/// pms开房测试
/// </summary>
/// <param name="idNumber"></param>
/// <param name="name"></param>
/// <param name="sex"></param>
/// <param name="picture"></param>
/// <param name="phone"></param>
/// <param name="hotel"></param>
/// <param name="room">房间编号</param>
/// <param name="checkin">开房时间</param>
/// <param name="shi">开房时间长度</param>
/// <returns></returns>
//开房按钮
Checkin:function(){
console.log("姓名:"+this.data.openUserName+"证件类型:"+this.data.openUserID+"性别:"+this.data.openUserSex+"照片路径:"+this.data.imgurl)
var that=this;
console.log("房间id:"+that.data.Roomid+"人脸机编号:"+that.data.sn+"酒店编号:"+that.data.hid)
openRommCheckin({
idNumber:that.data.openUserID,
name:that.data.openUserName,
sex:that.data.openUserSex,
picture:that.data.imgurl,
phone:that.data.openUserTel,
room:that.data.Roomid,
faceSN:that.data.sn,
hotelCode:that.data.hid,
}).then(
res => {
console.log(res)
if (res.Status == 200) {
app.toast(2, res.Message)
}
else{
app.toast(2, res.Message)
}
},
err => {
app.toast(2, "网络繁忙")
}
).catch(err => {
app.toast(2, "网络繁忙")
});
},
//解绑
JbSn:function(params) {
var that=this;
wx.showModal({
title: '提示',
content: '确定要解绑吗?',
success (res) {
if (res.confirm) {
GetFaceSN({
faceSN:that.data.sn,
roomID:that.data.RoomNO,
roomNumber:that.data.Roomid,
faceAddress:that.data.address,
HotelID:that.data.hid,
isjb:true
}).then(
res => {
if (res.Status == 200) {
switch (res.Data) {
case 0:
app.toast(1, "解绑成功~");
wx.navigateTo({
url: '/pages/Hosts/Hosts?HotelId='+that.data.hid
})
break;
case 1:
app.toast(2, "SN已经绑定酒店~")
break;
case 2:
app.toast(2, "SN绑定酒店失败~")
break;
case 3:
app.toast(2, "SN注册绑定酒店失败~")
break;
case 4:
app.toast(2, "未知错误~")
break;
case 5:
app.toast(2, "数据不符合~")
break;
case 6:
app.toast(2, "解绑失败~")
break;
default:
app.toast(2, "其他错误~")
break;
}
/// 0 成功
/// 1 已经注册已经绑定酒店
/// 2 已经注册更新失败
/// 3 未注册为分配酒店 添加注册 添加酒店是啊比
/// 4 未能预计的结果--
/// 5 数据不符合
/// 6 解绑失败
console.log(0)
}
else{
app.toast(2, "网络繁忙")
}
},
err => {
app.toast(2, "网络繁忙")
}
).catch(err => {
app.toast(2, "网络繁忙")
});
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
// if (confirm("你确定要继续吗?")) {
// } else {
// // 用户点击了取消
// }
},
//退房测试
checkOut:function(params){
var that=this;
wx.showModal({
title: '提示',
content: '确定退房吗?',
success (res) {
if (res.confirm) {
roomCheckOut({
room:that.data.Roomid,
faceSN:that.data.sn,
hotelCode:that.data.hid,
}).then(
res => {
if (res.Status == 200){
app.toast(2,"退房命令下发成功")
}
else{
app.toast(2, "退房命令下发成功")
}
},
err => {
app.toast(2, "退房命令下发失败")
}
).catch(err => {
app.toast(2, "退房命令下发失败")
});
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
// 帮助
HelpClick: function (params) {
this.setData({
islogs: false,
Help: !this.data.Help,
openrom: false
})
},
//功能测试
// featurutist:function(){
// },
//测试
// featurutistlist:function(e){
// },
//开门测试
OpenDoor:function(){
var that=this;
OpenDoorTest({faceSN:that.data.sn,isjb:true}).then(
res => {
if (res.Status == 200) {
app.toast(2, res.Message)
}
else{
app.toast(2, res.Message)
}
},
err => {
app.toast(2, "网络繁忙")
}
).catch(err => {
app.toast(2, "网络繁忙")
});
},
//版本号码查询
Getversionnumber:function(){
console.log(2);
var that=this;
GeteDeviceInfomation({faceSN:that.data.sn,hotelCode:that.data.HotelId, isjb:true}).then(
res => {
if (res.Status == 200) {
app.toast(2, res.Message)
}
else{
app.toast(2, res.Message)
}
},
err => {
app.toast(2, "网络繁忙")
}
).catch(err => {
app.toast(2, "网络繁忙")
});
},
//人数查询
Getpeopleobjained:function(){
console.log(3)
var that=this;
GetThePeopleListOfDevice({faceSN:that.data.sn,hotelCode:that.data.HotelId, isjb:true}).then(
res => {
if (res.Status == 200) {
app.toast(2, res.Message)
}
else{
app.toast(2, res.Message)
}
},
err => {
app.toast(2, "网络繁忙")
}
).catch(err => {
app.toast(2, "网络繁忙")
});
},
//删除所有人
Deletepeople:function(){
console.log(4)
var that=this;
wx.showModal({
title: '提示',
content: '确定删除设备中用户组为1的所有人信息吗',
success (res) {
if (res.confirm) {
DeletePeopleFromDeviceByGroup({faceSN:that.data.sn,hotelCode:that.data.HotelId, isjb:true}).then(
res => {
if (res.Status == 200) {
app.toast(2, res.Message)
}
else{
app.toast(2, res.Message)
}
},
err => {
app.toast(2, "网络繁忙")
}
).catch(err => {
app.toast(2, "网络繁忙")
});
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
//设备重新启动
RestartDevice:function(){
console.log(5)
var that=this;
wx.showModal({
title: '提示',
content: '确定让设备重新启动吗?',
success (res) {
if (res.confirm) {
RestartTheDevice({faceSN:that.data.sn,isjb:true}).then(
res => {
if (res.Status == 200) {
app.toast(2, res.Message)
}
else{
app.toast(2, res.Message)
}
},
err => {
app.toast(2, "网络繁忙")
}
).catch(err => {
app.toast(2, "网络繁忙")
});
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log(options)
var splitArray = options.Hotelinfo.split("_");
console.log(splitArray)
var that=this;
that.setData({
sn:splitArray[2],
HotelId:splitArray[3],
Roomid:splitArray[1],
HotelName:splitArray[0],
hid:splitArray[4],
RoomNO:options.RoomID,
faceadd:options.faceadd
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})