| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 1 | <template> |
| 2 | <view class="otherLogin"> |
| 3 | <u-cell-group> |
| 4 | <u-cell-item title="指纹" :arrow="false"> |
| 5 | <u-icon slot="icon" size="32" name="fingerprint"></u-icon> |
| 6 | <u-switch slot="right-icon" v-model="fingerprint" @change="finger"></u-switch> |
| 7 | </u-cell-item> |
| 8 | <u-cell-item title="手势" :arrow="false"> |
| 9 | <u-icon name="hands" custom-prefix="custom-icon" size="32" slot="icon"></u-icon> |
| 10 | <u-switch slot="right-icon" v-model="hands" @change="openHands"></u-switch> |
| 11 | </u-cell-item> |
| 12 | <u-cell-item title="人脸" :arrow="false"> |
| 13 | <u-icon name="face" custom-prefix="custom-icon" size="32" slot="icon"></u-icon> |
| 14 | <u-switch slot="right-icon" v-model="face" @change="openFace"></u-switch> |
| 15 | </u-cell-item> |
| 16 | </u-cell-group> |
| 17 | </view> |
| 18 | </template> |
| 19 | |
| 20 | <script> |
| 21 | export default { |
| 22 | data() { |
| 23 | return { |
| 24 | fingerprint: false, |
| 25 | hands: false, |
| 26 | face: false, |
| 27 | list: [] |
| 28 | } |
| 29 | }, |
| 30 | onShow() { |
| 31 | let hands = wx.getStorageSync("hands") |
| 32 | let face = wx.getStorageSync("face") |
| 33 | let fingerprint = wx.getStorageSync("fingerprint") |
| 34 | this.hands = hands.length > 0 ? true : false |
| 35 | this.face = face ? true : false |
| 36 | this.fingerprint = fingerprint ? true : false |
| 37 | }, |
| 38 | onLoad() { |
| 39 | |
| 40 | }, |
| 41 | methods: { |
| 42 | finger(e) { |
| 43 | let that = this |
| 44 | if (e) { |
| 45 | uni.checkIsSupportSoterAuthentication({ |
| 46 | success(res) { |
| 47 | let str = res.supportMode.join("") |
| 48 | if (str.indexOf("fingerPrint") != -1) { |
| 49 | uni.setStorageSync("fingerprint", true) |
| 50 | uni.showToast({ |
| 51 | title:'开启指纹解锁成功', |
| 52 | icon:'none' |
| 53 | }) |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 54 | that.fingerprint = true |
| 55 | } else { |
| 56 | uni.showToast({ |
| 57 | title:'该设备不支持指纹解锁', |
| 58 | icon:'none' |
| 59 | }) |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 60 | that.fingerprint = false |
| 61 | } |
| 62 | }, |
| 63 | fail(res) { |
| 64 | uni.showToast({ |
| 65 | title:'开启指纹解锁失败', |
| 66 | icon:'none' |
| 67 | }) |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 68 | that.fingerprint = false |
| 69 | } |
| 70 | }) |
| 71 | } else { |
| 72 | uni.removeStorageSync("fingerprint") |
| 73 | } |
| 74 | |
| 75 | |
| 76 | }, |
| 77 | openFace(e) { |
| 78 | let that = this |
| 79 | if (e) { |
| 80 | uni.checkIsSupportSoterAuthentication({ |
| 81 | success(res) { |
| 82 | let str = res.supportMode.join("") |
| 83 | if (str.indexOf("facial") == -1) { |
| 84 | uni.showToast({ |
| 85 | title:'该设备不支持面容解锁', |
| 86 | icon:'none' |
| 87 | }) |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 88 | that.face = false |
| 89 | } else { |
| 90 | uni.showToast({ |
| 91 | title:'开启棉柔解锁成功', |
| 92 | icon:'none' |
| 93 | }) |
| 94 | uni.setStorageSync("face", true) |
| 95 | that.face = true |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 96 | } |
| 97 | }, |
| 98 | fail(res) { |
| 99 | uni.showToast({ |
| 100 | title:'开启面容识别失败', |
| 101 | icon:'none' |
| 102 | }) |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 103 | that.face = false |
| 104 | } |
| 105 | }) |
| 106 | } else { |
| 107 | uni.removeStorageSync("face") |
| 108 | } |
| 109 | }, |
| 110 | openHands(e) { |
| 111 | if (e) { |
| 112 | uni.navigateTo({ |
| guangchao.xu | 6cdd45e | 2021-04-16 17:44:30 +0800 | [diff] [blame^] | 113 | url: "/pages/sub_mine/lock" |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 114 | }) |
| 115 | } else { |
| 116 | uni.showModal({ |
| 117 | title: "提示", |
| 118 | content: "确定关闭手势解锁吗?", |
| 119 | success: (res) => { |
| 120 | if (res.confirm) { |
| 121 | uni.navigateTo({ |
| guangchao.xu | 6cdd45e | 2021-04-16 17:44:30 +0800 | [diff] [blame^] | 122 | url: "/pages/sub_mine/lock" |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 123 | }) |
| 124 | } else if (res.cancel) { |
| 125 | this.hands = true |
| 126 | } |
| 127 | } |
| 128 | }) |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | } |
| 133 | } |
| 134 | // uni.checkIsSoterEnrolledInDevice({ |
| 135 | // checkAuthMode: 'fingerPrint', |
| 136 | // success(res) { |
| 137 | // if (res.isEnrolled) { |
| 138 | // uni.startSoterAuthentication({ |
| 139 | // requestAuthModes: ['fingerPrint'], |
| 140 | // authContent: e ? '开启指纹解锁' : "关闭指纹解锁", |
| 141 | // success(res) { |
| 142 | // console.log(res); |
| 143 | // this.fingerprint = true |
| 144 | // }, |
| 145 | // fail(res) { |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 146 | // this.fingerprint = false |
| 147 | // } |
| 148 | // }) |
| 149 | // } else { |
| guangchao.xu | 070005a | 2020-12-07 09:56:40 +0800 | [diff] [blame] | 150 | // this.fingerprint = false |
| 151 | // } |
| 152 | // }, |
| 153 | // }) |
| 154 | </script> |
| 155 | |
| 156 | <style scoped lang="scss"> |
| 157 | |
| 158 | </style> |