vue中使用fingerprintjs生成终端id

通过孟繁永

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(() => {
              // 登录成功后的操作
               
              })
          })

关于作者

孟繁永 administrator

发表评论

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据