blob: b290497bc735ab148bb633983ce0505f6f1dc322 [file] [log] [blame]
<template>
<view class="otherLogin">
<u-cell-group>
<u-cell-item title="指纹" :arrow="false">
<u-icon slot="icon" size="32" name="fingerprint"></u-icon>
<u-switch slot="right-icon" v-model="fingerprint" @change="finger"></u-switch>
</u-cell-item>
<u-cell-item title="手势" :arrow="false">
<u-icon name="hands" custom-prefix="custom-icon" size="32" slot="icon"></u-icon>
<u-switch slot="right-icon" v-model="hands" @change="openHands"></u-switch>
</u-cell-item>
<u-cell-item title="人脸" :arrow="false">
<u-icon name="face" custom-prefix="custom-icon" size="32" slot="icon"></u-icon>
<u-switch slot="right-icon" v-model="face" @change="openFace"></u-switch>
</u-cell-item>
</u-cell-group>
</view>
</template>
<script>
export default {
data() {
return {
fingerprint: false,
hands: false,
face: false,
list: []
}
},
onShow() {
let hands = wx.getStorageSync("hands")
let face = wx.getStorageSync("face")
let fingerprint = wx.getStorageSync("fingerprint")
this.hands = hands.length > 0 ? true : false
this.face = face ? true : false
this.fingerprint = fingerprint ? true : false
},
onLoad() {
},
methods: {
finger(e) {
let that = this
if (e) {
uni.checkIsSupportSoterAuthentication({
success(res) {
let str = res.supportMode.join("")
if (str.indexOf("fingerPrint") != -1) {
uni.setStorageSync("fingerprint", true)
uni.showToast({
title:'开启指纹解锁成功',
icon:'none'
})
that.fingerprint = true
} else {
uni.showToast({
title:'该设备不支持指纹解锁',
icon:'none'
})
that.fingerprint = false
}
},
fail(res) {
uni.showToast({
title:'开启指纹解锁失败',
icon:'none'
})
that.fingerprint = false
}
})
} else {
uni.removeStorageSync("fingerprint")
}
},
openFace(e) {
let that = this
if (e) {
uni.checkIsSupportSoterAuthentication({
success(res) {
let str = res.supportMode.join("")
if (str.indexOf("facial") == -1) {
uni.showToast({
title:'该设备不支持面容解锁',
icon:'none'
})
that.face = false
} else {
uni.showToast({
title:'开启棉柔解锁成功',
icon:'none'
})
uni.setStorageSync("face", true)
that.face = true
}
},
fail(res) {
uni.showToast({
title:'开启面容识别失败',
icon:'none'
})
that.face = false
}
})
} else {
uni.removeStorageSync("face")
}
},
openHands(e) {
if (e) {
uni.navigateTo({
url: "/pages/sub_mine/lock"
})
} else {
uni.showModal({
title: "提示",
content: "确定关闭手势解锁吗?",
success: (res) => {
if (res.confirm) {
uni.navigateTo({
url: "/pages/sub_mine/lock"
})
} else if (res.cancel) {
this.hands = true
}
}
})
}
}
}
}
// uni.checkIsSoterEnrolledInDevice({
// checkAuthMode: 'fingerPrint',
// success(res) {
// if (res.isEnrolled) {
// uni.startSoterAuthentication({
// requestAuthModes: ['fingerPrint'],
// authContent: e ? '开启指纹解锁' : "关闭指纹解锁",
// success(res) {
// console.log(res);
// this.fingerprint = true
// },
// fail(res) {
// this.fingerprint = false
// }
// })
// } else {
// this.fingerprint = false
// }
// },
// })
</script>
<style scoped lang="scss">
</style>