This commit is contained in:
Aiden 2024-10-22 11:24:43 +08:00
parent e7ed00472d
commit 37c099ebf8
3 changed files with 17 additions and 10 deletions

View File

@ -1,8 +1,13 @@
<script>
export default {
onLaunch: function () {},
onLaunch: function () {
const token = window?.plus?.storage.getItem("token");
uni.setStorageSync("token", token);
},
onShow: function () {
console.log("App Show");
const token = window?.plus?.storage.getItem("token");
uni.setStorageSync("token", token);
},
onHide: function () {
console.log("App Hide");

View File

@ -120,12 +120,12 @@ onLoad((options) => {
console.log("options", options);
state.id = options.id;
state.pid = options.pid;
const token =
window?.plus?.storage.getItem("token") ||
uni.getStorageSync("store-token");
console.log("token", token);
const token = window?.plus?.storage.getItem("token");
if (!uni.setStorageSync("token", token)) {
uni.setStorageSync("token", token);
}
//
if (token) {
if (uni.getStorageSync("token") || uni.getStorageSync("store-token")) {
paintingDetail();
getBtngetRules();
}

View File

@ -2,7 +2,11 @@ import Request from "./request/index.js";
import useToast from "@/hooks/toast/useToast.js";
import { OAorMc } from "../index.js";
const { showMessage } = useToast();
console.log(window?.plus?.storage.getItem("token"));
console.log(
"token",
window?.plus?.storage.getItem("token"),
uni.getStorageSync("token")
);
const request = new Request({
baseURL:
OAorMc() === "MC"
@ -18,9 +22,7 @@ const request = new Request({
: "application/json";
const token =
window?.plus?.storage.getItem("token") ||
uni.getStorageSync("store-token") ||
"";
uni.getStorageSync("token") || uni.getStorageSync("store-token") || "";
if (config.isFormData) {
config.headers["Content-Type"] = "multipart/form-data";
config.headers["Authorization"] = token;