<view class='wx_frame'>
<text class='wx_text'>指纹开\关灯</text>
<switch class='weui-swt' color='#8D1CB7'></switch>
</view>
.wx_frame {
margin-top: 156px;
height: 44px;
width: 100%;
background: #fff;
border: 1px solid #dAdAdA;
}
.wx_text {
font-size: 17px;
padding-left: 15px;
}
.weui-swt {
padding-top: 7.5px;
padding-left: 190px;
}
wx.showLoading({
title: '靠近连接',
mask: false
})
<view class='wx_frame'>
<text class='wx_text'>指纹开\关灯</text>
<switch class='weui-swt' color='#8D1CB7' bindchange='switchLED'></switch>
</view>
onLoad: function (options) {
// wx.showLoading({
// title: '靠近连接',
// mask: false
// })
// bleComm.connectDevice().then(res => {
// wx.showToast({
// title: '蓝牙连接成功',
// icon: 'success',
// duration: 300
// })
// });
},
switchLED: function (e) {
console.log('switch点击后的值:', e.detail.value)
}
switchLED: function (e) {
console.log('switch点击后的值:', e.detail.value)
if (e.detail.value)
bleComm.writeValue('ON');
else
bleComm.writeValue('OFF');
}
switchLED: function (e) {
console.log('switch点击后的值:', e.detail.value)
var msg;
if (e.detail.value)
msg = '1';
else
msg = '0';
wx.checkIsSupportSoterAuthentication({
success(res) {
wx.startSoterAuthentication({
requestAuthModes: ['fingerPrint'],
challenge: '123456',
authContent: 'Hello LiBin',
success(res) {
console.log('finger is ok', msg);
bleComm.writeValue(msg);
}
})
},
fail(res) {
console.log("不支持指纹");
wx.showModal({
title: '抱歉',
content: '设备不支持指纹',
cancelText: '取消',
confirmText: '确认',
success: function (res) {
}
})
}
})
},
import bleComm from '../utils/bleComm.js';
var msg;
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.showLoading({
title: '靠近连接',
mask: true
})
bleComm.connectDevice().then(res => {
wx.showToast({
title: '蓝牙连接成功',
icon: 'success',
duration: 300
})
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
bleComm.disConnect();
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
bleComm.disConnect();
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
switchLED: function (e) {
console.log('switch点击后的值:', e.detail.value)
var msg;
if (e.detail.value)
msg = '1';
else
msg = '0';
wx.checkIsSupportSoterAuthentication({
success(res) {
wx.startSoterAuthentication({
requestAuthModes: ['fingerPrint'],
challenge: '123456',
authContent: 'Hello LiBin',
success(res) {
console.log('finger is ok', msg);
bleComm.writeValue(msg);
}
})
},
fail(res) {
console.log("不支持指纹");
wx.showModal({
title: '抱歉',
content: '设备不支持指纹',
cancelText: '取消',
confirmText: '确认',
success: function (res) {
}
})
}
})
},
})
杨立斌
美科
解惑
创建时间:2017/12/22
25指纹密码