feat:小程序新的指纹唯一编号
This commit is contained in:
1 parent
150b8b3ac7
commit
d7fbf72df4
7 files changed
+47
-3
No files matched your search
@@ -101,7 +101,7 @@ const state = reactive<any>({
|
||||
{ text: "我参加的活动", icon: "/static/icon/act.png", path: "/pages/merchant/my-act-list" },
|
||||
{ text: "我的钱包", icon: "/static/icon/service_3.png", path: "/pages/wallet/list" },
|
||||
{ text: "我的人脸", icon: "/static/icon/service_5.png", path: "/pages/human-face/list" },
|
||||
{ text: "车辆管理", icon: "/static/icon/service_6.png", path: "/pages/car/user-car/list" },
|
||||
// { text: "车辆管理", icon: "/static/icon/service_6.png", path: "/pages/car/user-car/list" },
|
||||
{ text: "清除缓存", icon: "/static/icon/clear-storage.png", path: "" },
|
||||
],
|
||||
appInfo: "",
|
||||
|
||||
@@ -112,7 +112,7 @@ export default {
|
||||
}),
|
||||
|
||||
// 设备认证
|
||||
verifyDevice: (data: { mobilePhone: string; code: string, uniqueCode?: string, deviceJson?: string }) =>
|
||||
verifyDevice: (data: { mobilePhone: string; code: string, deviceUniqueCode?: string }) =>
|
||||
request({
|
||||
url: "/thirdparty/thirdPartyOAth2/mini-app/verify-device",
|
||||
method: "POST",
|
||||
@@ -120,7 +120,7 @@ export default {
|
||||
}),
|
||||
|
||||
// 判断该设备是否被验证
|
||||
isVerifyDevice: (data: { mobile: string; userId: string, uniqueCode?: string, deviceJson?: string }) =>
|
||||
isVerifyDevice: (data: { mobile: string; userId: string, uniqueCode?: string, deviceUniqueCode?: string }) =>
|
||||
request({
|
||||
url: "/thirdparty/thirdPartyOAth2/is-verify-device",
|
||||
method: "POST",
|
||||
|
||||
@@ -5,6 +5,7 @@ import { router, hooks, constant } from "@@/index"
|
||||
import { useTabbarStore } from "@@/stores/tabbar"
|
||||
import { jump } from "@/sheep/router";
|
||||
import { userApi } from "@@/api/index"
|
||||
import { buildUserDeviceFingerprint } from "@@/utils/device-unique"
|
||||
|
||||
import VerifyDeviceImpModel from "../../verify-device-imp-model.vue"
|
||||
|
||||
@@ -133,9 +134,11 @@ async function checkVerifyDevice() {
|
||||
if (constant.DEVICE_VERIFY_WRITE_LIST.includes(userInfo.sysUser.phone)) {
|
||||
return
|
||||
}
|
||||
const fingerprint = await buildUserDeviceFingerprint(true)
|
||||
const _params = {
|
||||
mobile: userInfo.sysUser.phone,
|
||||
userId: userInfo.sysUser.userId,
|
||||
deviceUniqueCode: fingerprint?.fingerprint,
|
||||
}
|
||||
try {
|
||||
const { data, code }: any = await userApi.isVerifyDevice(_params)
|
||||
|
||||
@@ -31,6 +31,7 @@ import { ref, reactive, watch, onUnmounted } from "vue"
|
||||
import { constant } from "@@/index"
|
||||
import { userApi } from "@@/api"
|
||||
import { getMiniUniqueCode, getDeviceKey } from "@@/utils/mini-tool"
|
||||
import { buildUserDeviceFingerprint } from "@@/utils/device-unique"
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -109,9 +110,11 @@ const doSubmit = async () => {
|
||||
if (!isPass) return
|
||||
|
||||
uni.showLoading({ title: "验证中...", mask: true })
|
||||
const fingerprint = await buildUserDeviceFingerprint(false)
|
||||
const params = {
|
||||
mobilePhone: form.mobilePhone,
|
||||
code: form.code,
|
||||
deviceUniqueCode: fingerprint?.fingerprint,
|
||||
}
|
||||
const res: any = await userApi.verifyDevice(params)
|
||||
if (res.code != 0) {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import CryptoJS from "crypto-js"
|
||||
import { constant } from "@@/index"
|
||||
|
||||
const INSTALL_ID_KEY = "DEVICE_INSTALL_ID"
|
||||
|
||||
export async function buildUserDeviceFingerprint(force?: boolean) {
|
||||
if (!force) {
|
||||
const cacheResult = uni.getStorageSync(INSTALL_ID_KEY)
|
||||
if (cacheResult) {
|
||||
return cacheResult
|
||||
}
|
||||
}
|
||||
const userInfo = uni.getStorageSync(constant.storageConstant.USERINFO)
|
||||
const systemInfo = await uni.getSystemInfo()
|
||||
const payload = {
|
||||
userId: userInfo.sysUser.userId || "",
|
||||
uniPlatform: systemInfo.uniPlatform || "",
|
||||
hostName: systemInfo.hostName || "",
|
||||
osName: systemInfo.osName || "",
|
||||
osVersion: systemInfo.osVersion || "",
|
||||
deviceModel: systemInfo.deviceModel || systemInfo.model || "",
|
||||
deviceType: systemInfo.deviceType || "",
|
||||
devicePixelRatio: String(systemInfo.devicePixelRatio || ""),
|
||||
pixelRatio: String(systemInfo.pixelRatio || ""),
|
||||
screenWidth: String(systemInfo.screenWidth || ""),
|
||||
screenHeight: String(systemInfo.screenHeight || ""),
|
||||
windowWidth: String(systemInfo.windowWidth || ""),
|
||||
windowHeight: String(systemInfo.windowHeight || ""),
|
||||
}
|
||||
const raw = JSON.stringify(payload)
|
||||
const fingerprint = CryptoJS.MD5(raw).toString()
|
||||
const result = {
|
||||
fingerprint,
|
||||
payload,
|
||||
}
|
||||
uni.setStorageSync(INSTALL_ID_KEY, result)
|
||||
return result
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 6.3 KiB |
Reference in new issue
Block a user