@@ -1,6 +1,6 @@ | |||||
# Suimang-wxapp | # Suimang-wxapp | ||||
setStorageSync 键名 | |||||
# setStorageSync 键名 | |||||
userId --用户id,用于邀请分享功能 | userId --用户id,用于邀请分享功能 | ||||
loginAwardCoin --注册奖励金币 | loginAwardCoin --注册奖励金币 | ||||
inviteAwardCoin --邀请奖励金币 | inviteAwardCoin --邀请奖励金币 | ||||
@@ -10,7 +10,6 @@ import { findImageApi, findGlodApi } from "./api/home"; | |||||
const userInfoModulesPinia = userInfoModules(); | const userInfoModulesPinia = userInfoModules(); | ||||
onLaunch(() => { | onLaunch(() => { | ||||
console.log("App Launch!"); | console.log("App Launch!"); | ||||
// 获取平台及系统信息 | // 获取平台及系统信息 | ||||
uni.getSystemInfo({ | uni.getSystemInfo({ | ||||
success: function (res) { | success: function (res) { | ||||
@@ -22,7 +21,7 @@ onLaunch(() => { | |||||
uni.setStorageSync("plat", 1); | uni.setStorageSync("plat", 1); | ||||
uniPlatform = 2; | uniPlatform = 2; | ||||
} else if (res.uniPlatform == "mp-toutiao") { | } else if (res.uniPlatform == "mp-toutiao") { | ||||
uni.setStorageSync("plat", 2); | |||||
uni.setStorageSync("plat", 3); | |||||
uniPlatform = 3; | uniPlatform = 3; | ||||
} | } | ||||
if (res.osName == "windows") { | if (res.osName == "windows") { | ||||
@@ -200,7 +200,7 @@ function chooseImg(index) { | |||||
}, | }, | ||||
header: { | header: { | ||||
// Authorization: userInfoModulesPinia.token, | // Authorization: userInfoModulesPinia.token, | ||||
token: userInfoModulesPinia.token, | |||||
token: uni.getStorageSync("token"), | |||||
}, | }, | ||||
success: async (res2) => { | success: async (res2) => { | ||||
if (JSON.parse(res2.data).code != 200) { | if (JSON.parse(res2.data).code != 200) { | ||||
@@ -221,7 +221,7 @@ function chooseImg(index) { | |||||
}, | }, | ||||
header: { | header: { | ||||
// Authorization: userInfoModulesPinia.token, | // Authorization: userInfoModulesPinia.token, | ||||
token: userInfoModulesPinia.token, | |||||
token: uni.getStorageSync("token"), | |||||
}, | }, | ||||
success: (res3) => { | success: (res3) => { | ||||
if (JSON.parse(res3.data).code != 200) { | if (JSON.parse(res3.data).code != 200) { | ||||
@@ -242,7 +242,7 @@ function chooseImg(index) { | |||||
}, | }, | ||||
header: { | header: { | ||||
"Content-Type": "multipart/form-data", | "Content-Type": "multipart/form-data", | ||||
token: userInfoModulesPinia.token, | |||||
token: uni.getStorageSync("token"), | |||||
}, | }, | ||||
success: async (res4) => { | success: async (res4) => { | ||||
if (JSON.parse(res4.data).code != 200) { | if (JSON.parse(res4.data).code != 200) { | ||||
@@ -29,6 +29,7 @@ import { | |||||
} from "../../api/coin.js"; | } from "../../api/coin.js"; | ||||
import { userInfoModules } from "@/store/modules/userInfo"; | import { userInfoModules } from "@/store/modules/userInfo"; | ||||
const userInfoModulesPinia = userInfoModules(); | const userInfoModulesPinia = userInfoModules(); | ||||
//#endregion ---------------------------------- | |||||
const active = ref(""); | const active = ref(""); | ||||
const orderNumber = ref(""); | const orderNumber = ref(""); | ||||
@@ -78,7 +79,7 @@ const createProductPay = async (orderNumber) => { | |||||
const data = { | const data = { | ||||
orderNumber, | orderNumber, | ||||
openId, | openId, | ||||
payVendor: 1, //Number,1:微信;2:抖音 | |||||
payVendor: userInfoModulesPinia.platForm == 2 ? 1 : 5, //Number,1:微信;5:抖音 | |||||
}; | }; | ||||
const res = await createPay(data); | const res = await createPay(data); | ||||
startPay(res.data); | startPay(res.data); | ||||
@@ -90,54 +91,106 @@ const createProductPay = async (orderNumber) => { | |||||
// 拉起收银台 | // 拉起收银台 | ||||
const startPay = (data) => { | const startPay = (data) => { | ||||
const orderInfo = { | |||||
package: data.package, | |||||
nonceStr: data.nonceStr, | |||||
timeStamp: data.timeStamp, | |||||
paySign: data.paySign, | |||||
signType: data.signType, | |||||
}; | |||||
console.log(orderInfo, "orderInfo"); | |||||
uni.hideLoading(); | |||||
uni.requestPayment({ | |||||
provider: "wxpay", //固定值为"wxpay" | |||||
...orderInfo, | |||||
success: function (res) { | |||||
console.log(res, "res"); | |||||
getStatusOfOrder(orderNumber.value).then((res) => { | |||||
console.log(res, "status"); | |||||
if (res == 1) { | |||||
uni.showToast({ | |||||
title: "支付取消", | |||||
icon: "exception", | |||||
}); | |||||
} else if (res == 2) { | |||||
} else if (res == 3) { | |||||
uni.showToast({ | |||||
title: "支付成功!", | |||||
icon: "success", | |||||
success() { | |||||
setTimeout(() => { | |||||
uni.navigateBack(); | |||||
}, 2000); | |||||
}, | |||||
}); | |||||
} else if (res == 4) { | |||||
uni.showToast({ | |||||
title: "支付取消", | |||||
icon: "exception", | |||||
}); | |||||
} | |||||
}); | |||||
}, | |||||
fail: function (err) { | |||||
uni.showToast({ | |||||
title: "支付失败!", | |||||
icon: "error", | |||||
}); | |||||
console.log("支付失败", err); | |||||
}, | |||||
}); | |||||
let orderInfo = null; | |||||
if (userInfoModulesPinia.platForm == 2) { | |||||
orderInfo = { | |||||
package: data.package, | |||||
nonceStr: data.nonceStr, | |||||
timeStamp: data.timeStamp, | |||||
paySign: data.paySign, | |||||
signType: data.signType, | |||||
}; | |||||
console.log(orderInfo, "orderInfo"); | |||||
uni.hideLoading(); | |||||
uni.requestPayment({ | |||||
provider: "wxpay", //固定值为"wxpay" | |||||
...orderInfo, | |||||
success: function (res) { | |||||
console.log(res, "res"); | |||||
getStatusOfOrder(orderNumber.value).then((res) => { | |||||
console.log(res, "status"); | |||||
if (res == 1) { | |||||
uni.showToast({ | |||||
title: "支付取消", | |||||
icon: "exception", | |||||
}); | |||||
} else if (res == 2) { | |||||
} else if (res == 3) { | |||||
uni.showToast({ | |||||
title: "支付成功!", | |||||
icon: "success", | |||||
success() { | |||||
setTimeout(() => { | |||||
uni.navigateBack(); | |||||
}, 2000); | |||||
}, | |||||
}); | |||||
} else if (res == 4) { | |||||
uni.showToast({ | |||||
title: "支付取消", | |||||
icon: "exception", | |||||
}); | |||||
} | |||||
}); | |||||
}, | |||||
fail: function (err) { | |||||
uni.showToast({ | |||||
title: "支付失败!", | |||||
icon: "fail", | |||||
}); | |||||
console.log("支付失败", err); | |||||
}, | |||||
}); | |||||
} | |||||
// 抖音支付 | |||||
else if (userInfoModulesPinia.platForm == 3) { | |||||
orderInfo = { | |||||
order_id: data.orderId, | |||||
order_token: data.token, | |||||
}; | |||||
console.log(orderInfo, "orderInfo"); | |||||
uni.hideLoading(); | |||||
uni.requestPayment({ | |||||
provider: "toutiao", //固定值为"wxpay" | |||||
orderInfo: orderInfo, | |||||
service: 5, | |||||
success: function (res) { | |||||
console.log(res, "res"); | |||||
getStatusOfOrder(orderNumber.value).then((res) => { | |||||
console.log(res, "status"); | |||||
if (res == 1) { | |||||
uni.showToast({ | |||||
title: "支付取消", | |||||
icon: "exception", | |||||
}); | |||||
} else if (res == 2) { | |||||
} else if (res == 3) { | |||||
uni.showToast({ | |||||
title: "支付成功!", | |||||
icon: "success", | |||||
success() { | |||||
setTimeout(() => { | |||||
uni.navigateBack(); | |||||
}, 2000); | |||||
}, | |||||
}); | |||||
} else if (res == 4) { | |||||
uni.showToast({ | |||||
title: "支付取消", | |||||
icon: "exception", | |||||
}); | |||||
} | |||||
}); | |||||
}, | |||||
fail: function (err) { | |||||
uni.showToast({ | |||||
title: "支付失败!", | |||||
icon: "fail", | |||||
}); | |||||
console.log("支付失败", err); | |||||
}, | |||||
}); | |||||
} | |||||
}; | }; | ||||
const getStatusOfOrder = async (orderNumber) => { | const getStatusOfOrder = async (orderNumber) => { | ||||
@@ -256,17 +256,17 @@ function chooseAvatar() { | |||||
//#region 路由跳转 | //#region 路由跳转 | ||||
function goBuyCoin() { | function goBuyCoin() { | ||||
if (userInfoModulesPinia.platForm == 3) { | |||||
uni.showToast({ | |||||
title: "暂未开放", | |||||
icon: "none", | |||||
mask: true, | |||||
}); | |||||
} else { | |||||
uni.navigateTo({ | |||||
url: "/pages/index/buyCoin", | |||||
}); | |||||
} | |||||
// if (userInfoModulesPinia.platForm == 3) { | |||||
// uni.showToast({ | |||||
// title: "暂未开放", | |||||
// icon: "none", | |||||
// mask: true, | |||||
// }); | |||||
// } else { | |||||
// } | |||||
uni.navigateTo({ | |||||
url: "/pages/index/buyCoin", | |||||
}); | |||||
} | } | ||||
function goLookPhoto(id, status) { | function goLookPhoto(id, status) { | ||||
@@ -205,6 +205,7 @@ async function dogetphonenumber(e) { | |||||
title: "获取成功", | title: "获取成功", | ||||
}); | }); | ||||
userInfoModulesPinia.token = res2.data.token; | userInfoModulesPinia.token = res2.data.token; | ||||
uni.setStorageSync("token", userInfoModulesPinia.token); | |||||
uni.switchTab({ | uni.switchTab({ | ||||
url: "/pages/uploadPhoto/uploadPhoto", | url: "/pages/uploadPhoto/uploadPhoto", | ||||
}); | }); | ||||
@@ -465,180 +466,215 @@ const handleOpenPrivacyContract = () => { | |||||
//#region 初始化 | //#region 初始化 | ||||
const urlUid = ref(""); //通过邀请来的会携带邀请人ID参数 | const urlUid = ref(""); //通过邀请来的会携带邀请人ID参数 | ||||
onLoad((options) => { | 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({ | uni.showToast({ | ||||
title: "登录失败,请重试", | title: "登录失败,请重试", | ||||
icon: "none", | icon: "none", | ||||
}); | }); | ||||
} | } | ||||
} else { | } 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({ | // uni.redirectTo({ | ||||
// url: "pages/index/index", | // url: "pages/index/index", | ||||
// }); | // }); | ||||
console.log(error, "error2"); | |||||
console.log("error4"); | |||||
uni.showToast({ | uni.showToast({ | ||||
title: "登录失败,请重试", | title: "登录失败,请重试", | ||||
icon: "none", | 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 { | } else { | ||||
uni.hideLoading(); | |||||
// uni.redirectTo({ | |||||
// url: "/pages/login/index", | |||||
// }); | |||||
console.log("error1"); | |||||
console.log("error3"); | |||||
uni.showToast({ | uni.showToast({ | ||||
title: "登录失败,请重试", | title: "登录失败,请重试", | ||||
icon: "none", | icon: "none", | ||||
}); | }); | ||||
} | } | ||||
uni.hideLoading(); | |||||
} catch (error) { | |||||
uni.hideLoading(); | |||||
console.log(error, "error2"); | |||||
}, | |||||
fail: (err) => { | |||||
console.log("error4"); | |||||
uni.showToast({ | uni.showToast({ | ||||
title: "登录失败,请重试", | title: "登录失败,请重试", | ||||
icon: "none", | icon: "none", | ||||
}); | }); | ||||
} | |||||
} else { | |||||
console.log("error3"); | |||||
uni.showToast({ | |||||
title: "登录失败,请重试", | |||||
icon: "none", | |||||
}); | |||||
} | |||||
}, | |||||
fail: (err) => { | |||||
console.log("error4"); | |||||
uni.showToast({ | |||||
title: "登录失败,请重试", | |||||
icon: "none", | |||||
}, | |||||
}); | }); | ||||
}, | |||||
}); | |||||
} | |||||
} | |||||
}, | |||||
}); | |||||
}); | }); | ||||
//#endregion --------------------------------- | //#endregion --------------------------------- | ||||
@@ -117,7 +117,7 @@ const showImgUrl2 = ref(null); //回显路径 未压缩 | |||||
// 点击上传图片或打开相机 | // 点击上传图片或打开相机 | ||||
function chooseImage() { | function chooseImage() { | ||||
// 检查token | // 检查token | ||||
if (!userInfoModulesPinia.token) { | |||||
if (!uni.getStorageSync("token")) { | |||||
uni.showModal({ | uni.showModal({ | ||||
title: "提示", | title: "提示", | ||||
content: "登录以体验完整功能", | content: "登录以体验完整功能", | ||||
@@ -178,7 +178,7 @@ function chooseImage() { | |||||
// console.log(userInfoModulesPinia.token, "token"); | // console.log(userInfoModulesPinia.token, "token"); | ||||
async function toCloseStyle() { | async function toCloseStyle() { | ||||
// 检查token | // 检查token | ||||
if (!userInfoModulesPinia.token) { | |||||
if (!uni.getStorageSync("token")) { | |||||
uni.showModal({ | uni.showModal({ | ||||
title: "提示", | title: "提示", | ||||
content: "登录以体验完整功能", | content: "登录以体验完整功能", | ||||
@@ -220,7 +220,7 @@ async function toCloseStyle() { | |||||
}, | }, | ||||
header: { | header: { | ||||
// Authorization: userInfoModulesPinia.token, | // Authorization: userInfoModulesPinia.token, | ||||
token: userInfoModulesPinia.token, | |||||
token: uni.getStorageSync("token"), | |||||
}, | }, | ||||
success: (res0) => { | success: (res0) => { | ||||
if (JSON.parse(res0.data).code != 200) { | if (JSON.parse(res0.data).code != 200) { | ||||
@@ -238,7 +238,7 @@ async function toCloseStyle() { | |||||
}, | }, | ||||
header: { | header: { | ||||
// Authorization: userInfoModulesPinia.token, | // Authorization: userInfoModulesPinia.token, | ||||
token: userInfoModulesPinia.token, | |||||
token: uni.getStorageSync("token"), | |||||
}, | }, | ||||
success: (res) => { | success: (res) => { | ||||
if (JSON.parse(res.data).code != 200) { | if (JSON.parse(res.data).code != 200) { | ||||
@@ -499,6 +499,7 @@ onLoad((options) => { | |||||
uni.hideLoading(); | uni.hideLoading(); | ||||
} else { | } else { | ||||
uni.hideLoading(); | uni.hideLoading(); | ||||
uni.setStorageSync("token", null); | |||||
uni.redirectTo({ | uni.redirectTo({ | ||||
url: "/pages/login/index", | url: "/pages/login/index", | ||||
}); | }); | ||||