vue中使用fingerprintjs生成终端id

·

安装组件:

npm i @fingerprintjs/fingerprintjs -S
# or
yarn add @fingerprintjs/fingerprintjs -S

创建一个async的methord:

async asyncCall() {
      // We recommend to call `load` at application startup.
      const fp = await FingerprintJS.load()

      // The FingerprintJS agent is ready.
      // Get a visitor identifier when you'd like to.
      const result = await fp.get()

      // This is the visitor identifier:
      const visitorId = result.visitorId

      console.log(visitorId)
      return visitorId
    }

在业务代码中使用:

this.asyncCall().then(res => {
            const terminalId = res
            that.$api
              .Login({
                employeeNumber: that.formLogin.employeeNumber,
                password: that.formLogin.password,
                terminalId: terminalId,
                terminalType: that.formLogin.terminalType
              })
              .then(() => {
              // 登录成功后的操作
               
              })
          })

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理