|
|
@@ -205,6 +205,7 @@ async function dogetphonenumber(e) { |
|
|
|
title: "获取成功", |
|
|
|
}); |
|
|
|
userInfoModulesPinia.token = res2.data.token; |
|
|
|
uni.setStorageSync("token", userInfoModulesPinia.token); |
|
|
|
uni.switchTab({ |
|
|
|
url: "/pages/uploadPhoto/uploadPhoto", |
|
|
|
}); |
|
|
@@ -465,180 +466,215 @@ const handleOpenPrivacyContract = () => { |
|
|
|
//#region 初始化 |
|
|
|
const urlUid = ref(""); //通过邀请来的会携带邀请人ID参数 |
|
|
|
onLoad((options) => { |
|
|
|
// 二维码扫描进入时 |
|
|
|
if (options.scene) { |
|
|
|
const str = decodeURIComponent(options.scene); |
|
|
|
const regex = /_u:(\d+)/; // 正则表达式匹配_u:后面的数字 |
|
|
|
const match = str.match(regex); |
|
|
|
urlUid.value = match[1]; |
|
|
|
} |
|
|
|
// 分享链接进入时 |
|
|
|
else if (options.userId) { |
|
|
|
urlUid.value = options.userId; |
|
|
|
} else { |
|
|
|
urlUid.value = null; |
|
|
|
} |
|
|
|
console.log(urlUid.value, "邀请人id"); |
|
|
|
uni.hideHomeButton(); |
|
|
|
// workId.value = options.id; |
|
|
|
// 获取平台及系统信息 |
|
|
|
uni.getSystemInfo({ |
|
|
|
success: function (res) { |
|
|
|
let uniPlatform = ""; |
|
|
|
let osName = ""; |
|
|
|
if (res.uniPlatform == "web") { |
|
|
|
uniPlatform = 1; |
|
|
|
} else if (res.uniPlatform == "mp-weixin") { |
|
|
|
uni.setStorageSync("plat", 1); |
|
|
|
uniPlatform = 2; |
|
|
|
} else if (res.uniPlatform == "mp-toutiao") { |
|
|
|
uni.setStorageSync("plat", 3); |
|
|
|
uniPlatform = 3; |
|
|
|
} |
|
|
|
if (res.osName == "windows") { |
|
|
|
osName = 1; |
|
|
|
} else if (res.osName == "ios") { |
|
|
|
osName = 2; |
|
|
|
} else if (res.osName == "android") { |
|
|
|
osName = 3; |
|
|
|
} else if (res.osName == "mac") { |
|
|
|
osName = 4; |
|
|
|
} else if (res.osName == "linux") { |
|
|
|
osName = 5; |
|
|
|
} |
|
|
|
|
|
|
|
if (options.type == "tokenFfalse") { |
|
|
|
uni.showToast({ |
|
|
|
title: "登录失效,请重新登录", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} |
|
|
|
// 已有token时直接登录 |
|
|
|
if (uni.getStorageSync("token")) { |
|
|
|
uni.switchTab({ url: "/pages/uploadPhoto/uploadPhoto" }); |
|
|
|
} |
|
|
|
userInfoModulesPinia.platForm = uniPlatform; // 平台 |
|
|
|
userInfoModulesPinia.hostSystem = osName; // 系统 |
|
|
|
console.log(res.uniPlatform, uniPlatform, "PlatForm"); |
|
|
|
console.log(res.osName, osName, "System"); |
|
|
|
|
|
|
|
// 原来的登录逻辑 |
|
|
|
// 二维码扫描进入时 |
|
|
|
if (options.scene) { |
|
|
|
const str = decodeURIComponent(options.scene); |
|
|
|
const regex = /_u:(\d+)/; // 正则表达式匹配_u:后面的数字 |
|
|
|
const match = str.match(regex); |
|
|
|
urlUid.value = match[1]; |
|
|
|
} |
|
|
|
// 分享链接进入时 |
|
|
|
else if (options.userId) { |
|
|
|
urlUid.value = options.userId; |
|
|
|
} else { |
|
|
|
urlUid.value = null; |
|
|
|
} |
|
|
|
console.log(urlUid.value, "邀请人id"); |
|
|
|
uni.hideHomeButton(); |
|
|
|
// workId.value = options.id; |
|
|
|
|
|
|
|
if (userInfoModulesPinia.platForm == 2) { |
|
|
|
uni.login({ |
|
|
|
provider: "weixin", // 使用微信登录授权 |
|
|
|
success: async (res) => { |
|
|
|
console.log(res, "uni.login"); |
|
|
|
if (res.code) { |
|
|
|
try { |
|
|
|
uni.showLoading({ |
|
|
|
title: "加载中...", |
|
|
|
mask: true, |
|
|
|
}); |
|
|
|
const data = { |
|
|
|
appId: userInfoModulesPinia.getAppId(), |
|
|
|
code: res.code, |
|
|
|
}; |
|
|
|
const res2 = await loginApi(data); |
|
|
|
userInfoModulesPinia.openId = res2.data.openId; |
|
|
|
if (res2.data.token) { |
|
|
|
userInfoModulesPinia.token = res2.data.token; |
|
|
|
uni.setStorageSync("token", userInfoModulesPinia.token); |
|
|
|
console.log(userInfoModulesPinia.openId, "获取openid"); |
|
|
|
// 获取头像和金币 |
|
|
|
const res3 = await findImageApi(); |
|
|
|
if (res3.data) { |
|
|
|
uni.setStorageSync("userId", res3.data.id); |
|
|
|
} |
|
|
|
userInfoModulesPinia.myAvatar = |
|
|
|
res3.data && res3.data.image ? res3.data.image : ""; |
|
|
|
const res4 = await findGlodApi(); |
|
|
|
if (res4.data) { |
|
|
|
uni.setStorageSync("userId", res4.data.id); |
|
|
|
} |
|
|
|
if (!res4.data) { |
|
|
|
userInfoModulesPinia.myGlod = 0; |
|
|
|
} else { |
|
|
|
userInfoModulesPinia.myGlod = res4.data.digitalAvatarResidueGlod |
|
|
|
? res4.data.digitalAvatarResidueGlod |
|
|
|
: 0; |
|
|
|
} |
|
|
|
uni.hideLoading(); |
|
|
|
if (res2.data.token) { |
|
|
|
getPrivacySetting(1); |
|
|
|
} else { |
|
|
|
console.log("error1"); |
|
|
|
if (options.type == "tokenFfalse") { |
|
|
|
uni.showToast({ |
|
|
|
title: "登录失效,请重新登录", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} |
|
|
|
// 已有token时直接登录 |
|
|
|
if (uni.getStorageSync("token")) { |
|
|
|
uni.switchTab({ url: "/pages/uploadPhoto/uploadPhoto" }); |
|
|
|
} |
|
|
|
|
|
|
|
if (userInfoModulesPinia.platForm == 2) { |
|
|
|
uni.login({ |
|
|
|
provider: "weixin", // 使用微信登录授权 |
|
|
|
success: async (res) => { |
|
|
|
console.log(res, "uni.login"); |
|
|
|
if (res.code) { |
|
|
|
try { |
|
|
|
uni.showLoading({ |
|
|
|
title: "加载中...", |
|
|
|
mask: true, |
|
|
|
}); |
|
|
|
const data = { |
|
|
|
appId: userInfoModulesPinia.getAppId(), |
|
|
|
code: res.code, |
|
|
|
}; |
|
|
|
const res2 = await loginApi(data); |
|
|
|
userInfoModulesPinia.openId = res2.data.openId; |
|
|
|
if (res2.data.token) { |
|
|
|
userInfoModulesPinia.token = res2.data.token; |
|
|
|
uni.setStorageSync("token", userInfoModulesPinia.token); |
|
|
|
console.log(userInfoModulesPinia.openId, "获取openid"); |
|
|
|
// 获取头像和金币 |
|
|
|
const res3 = await findImageApi(); |
|
|
|
if (res3.data) { |
|
|
|
uni.setStorageSync("userId", res3.data.id); |
|
|
|
} |
|
|
|
userInfoModulesPinia.myAvatar = |
|
|
|
res3.data && res3.data.image ? res3.data.image : ""; |
|
|
|
const res4 = await findGlodApi(); |
|
|
|
if (res4.data) { |
|
|
|
uni.setStorageSync("userId", res4.data.id); |
|
|
|
} |
|
|
|
if (!res4.data) { |
|
|
|
userInfoModulesPinia.myGlod = 0; |
|
|
|
} else { |
|
|
|
userInfoModulesPinia.myGlod = res4.data |
|
|
|
.digitalAvatarResidueGlod |
|
|
|
? res4.data.digitalAvatarResidueGlod |
|
|
|
: 0; |
|
|
|
} |
|
|
|
uni.hideLoading(); |
|
|
|
if (res2.data.token) { |
|
|
|
getPrivacySetting(1); |
|
|
|
} else { |
|
|
|
console.log("error1"); |
|
|
|
uni.showToast({ |
|
|
|
title: "登录失败,请重试", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
getPrivacySetting(2); |
|
|
|
} |
|
|
|
uni.hideLoading(); |
|
|
|
} catch (error) { |
|
|
|
// uni.redirectTo({ |
|
|
|
// url: "pages/index/index", |
|
|
|
// }); |
|
|
|
console.log(error, "error2"); |
|
|
|
uni.showToast({ |
|
|
|
title: "登录失败,请重试", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
getPrivacySetting(2); |
|
|
|
// uni.redirectTo({ |
|
|
|
// url: "pages/index/index", |
|
|
|
// }); |
|
|
|
console.log("error3"); |
|
|
|
uni.showToast({ |
|
|
|
title: "登录失败,请重试", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} |
|
|
|
uni.hideLoading(); |
|
|
|
} catch (error) { |
|
|
|
}, |
|
|
|
fail: (err) => { |
|
|
|
// uni.redirectTo({ |
|
|
|
// url: "pages/index/index", |
|
|
|
// }); |
|
|
|
console.log(error, "error2"); |
|
|
|
console.log("error4"); |
|
|
|
uni.showToast({ |
|
|
|
title: "登录失败,请重试", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// uni.redirectTo({ |
|
|
|
// url: "pages/index/index", |
|
|
|
// }); |
|
|
|
console.log("error3"); |
|
|
|
uni.showToast({ |
|
|
|
title: "登录失败,请重试", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: (err) => { |
|
|
|
// uni.redirectTo({ |
|
|
|
// url: "pages/index/index", |
|
|
|
// }); |
|
|
|
console.log("error4"); |
|
|
|
uni.showToast({ |
|
|
|
title: "登录失败,请重试", |
|
|
|
icon: "none", |
|
|
|
}, |
|
|
|
}); |
|
|
|
}, |
|
|
|
}); |
|
|
|
} |
|
|
|
// 抖音头条授权 |
|
|
|
else if (userInfoModulesPinia.platForm == 3) { |
|
|
|
uni.login({ |
|
|
|
provider: "toutiao", // 使用微信登录授权 |
|
|
|
success: async (res) => { |
|
|
|
console.log(res, "uni.login"); |
|
|
|
if (res.code) { |
|
|
|
try { |
|
|
|
uni.showLoading({ |
|
|
|
title: "加载中...", |
|
|
|
mask: true, |
|
|
|
}); |
|
|
|
const data = { |
|
|
|
appId: userInfoModulesPinia.getAppId(), |
|
|
|
code: res.code, |
|
|
|
}; |
|
|
|
const res2 = await loginApi(data); |
|
|
|
userInfoModulesPinia.openId = res2.data.openId; |
|
|
|
if (res2.data.token) { |
|
|
|
userInfoModulesPinia.token = res2.data.token; |
|
|
|
// uni.setStorageSync("token", userInfoModulesPinia.token); |
|
|
|
console.log(userInfoModulesPinia.openId, "获取openid"); |
|
|
|
uni.hideLoading(); |
|
|
|
} |
|
|
|
// 抖音头条授权 |
|
|
|
else if (userInfoModulesPinia.platForm == 3) { |
|
|
|
uni.login({ |
|
|
|
provider: "toutiao", // 使用微信登录授权 |
|
|
|
success: async (res) => { |
|
|
|
console.log(res, "uni.login"); |
|
|
|
if (res.code) { |
|
|
|
try { |
|
|
|
uni.showLoading({ |
|
|
|
title: "加载中...", |
|
|
|
mask: true, |
|
|
|
}); |
|
|
|
const data = { |
|
|
|
appId: userInfoModulesPinia.getAppId(), |
|
|
|
code: res.code, |
|
|
|
}; |
|
|
|
const res2 = await loginApi(data); |
|
|
|
userInfoModulesPinia.openId = res2.data.openId; |
|
|
|
if (res2.data.token) { |
|
|
|
userInfoModulesPinia.token = res2.data.token; |
|
|
|
// uni.setStorageSync("token", userInfoModulesPinia.token); |
|
|
|
console.log(userInfoModulesPinia.openId, "获取openid"); |
|
|
|
uni.hideLoading(); |
|
|
|
} else { |
|
|
|
uni.hideLoading(); |
|
|
|
// uni.redirectTo({ |
|
|
|
// url: "/pages/login/index", |
|
|
|
// }); |
|
|
|
console.log("error1"); |
|
|
|
uni.showToast({ |
|
|
|
title: "登录失败,请重试", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} |
|
|
|
uni.hideLoading(); |
|
|
|
} catch (error) { |
|
|
|
uni.hideLoading(); |
|
|
|
console.log(error, "error2"); |
|
|
|
uni.showToast({ |
|
|
|
title: "登录失败,请重试", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
uni.hideLoading(); |
|
|
|
// uni.redirectTo({ |
|
|
|
// url: "/pages/login/index", |
|
|
|
// }); |
|
|
|
console.log("error1"); |
|
|
|
console.log("error3"); |
|
|
|
uni.showToast({ |
|
|
|
title: "登录失败,请重试", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} |
|
|
|
uni.hideLoading(); |
|
|
|
} catch (error) { |
|
|
|
uni.hideLoading(); |
|
|
|
console.log(error, "error2"); |
|
|
|
}, |
|
|
|
fail: (err) => { |
|
|
|
console.log("error4"); |
|
|
|
uni.showToast({ |
|
|
|
title: "登录失败,请重试", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
console.log("error3"); |
|
|
|
uni.showToast({ |
|
|
|
title: "登录失败,请重试", |
|
|
|
icon: "none", |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
fail: (err) => { |
|
|
|
console.log("error4"); |
|
|
|
uni.showToast({ |
|
|
|
title: "登录失败,请重试", |
|
|
|
icon: "none", |
|
|
|
}, |
|
|
|
}); |
|
|
|
}, |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
//#endregion --------------------------------- |
|
|
|
|
|
|
|