绿满眶商城微信小程序-uniapp
xiangpei
6 天以前 70738d032bd80f5b13075f8a13045ff4de57c2c3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// TODO 第一版本暂无此功能 后续优化以及更新
<template>
  <view class="finger">
    <u-cell-group>
      <u-cell-item class="border-top" :arrow="false" title="指纹登录">
        <u-switch slot="right-icon" @change="fingerSwitchChange" :active-color="lightColor" size="40" v-model="checked"></u-switch>
      </u-cell-item>
    </u-cell-group>
    <view class="describe">开启后可使用指纹认证完成快捷登录,设置仅对本机生效。如需修改指纹,请在系统设置中操作。</view>
  </view>
</template>
 
<script>
import '@/components/uview-components/uview-ui'
import storage from "@/utils/storage.js";
import { setBiolofy } from "@/api/passport.js";
 
export default {
  data() {
    return {
      lightColor: this.$lightColor,
      checked: false,
    };
  },
  methods: {
    fingerSwitchChange(value) {
      if (value === true) {
        const res = uni.getSystemInfoSync();
        plus.device.getInfo({
          success: function (e) {
            let params = {
              mobile_type: res.model,
              secret_key: e.uuid,
            };
            setBiolofy(params).then((res) => {
              if (res.statusCode === 200) {
                storage.setFingerLogin(true);
              }
            });
          },
          fail: function (e) {
            console.error("getDeviceInfo failed: " + JSON.stringify(e));
          },
        });
      } else {
        storage.setFingerLogin(false);
      }
    },
  },
  onLoad() {
    // #ifdef APP-PLUS
    if (!plus.fingerprint.isSupport()) {
      plus.nativeUI.toast("此设备不支持指纹识别");
      uni.navigateBack();
    }
    if (!plus.fingerprint.isKeyguardSecure()) {
      plus.nativeUI.toast("此设备未设置密码锁屏");
      uni.navigateBack();
    }
    if (!plus.fingerprint.isEnrolledFingerprints()) {
      plus.nativeUI.toast("此设备未录入指纹");
      uni.navigateBack();
    }
    this.checked = storage.getFingerLogin() || false;
    // #endif
  },
};
</script>
 
<style scoped lang="scss">
</style>