# Conflicts:
#	.env
This commit is contained in:
dzc committed 2025-04-01 20:20:21 +08:00
commit f4faab9436
10 files changed
+511 -209

No files matched your search

+4 -6
View File
@@ -18,19 +18,17 @@ VITE_OAUTH2_APP_CLIENT='mini:mini'
# 图片访问基础地址
#VITE_IMAGE_BASE_PATH = http://localhost:9999
VITE_IMAGE_BASE_PATH = http://192.168.101.81:9999 # 邓-本地
# VITE_IMAGE_BASE_PATH = https://123.156.230.15:8089/api # 线上
# VITE_IMAGE_BASE_PATH = http://192.168.101.81:9999 # 邓-本地
# VITE_IMAGE_BASE_PATH = http://220.191.229.171:8090/api # 线上
# VITE_IMAGE_BASE_PATH = http://pjcloud.center.takin.cc # 张
#VITE_IMAGE_BASE_PATH = http://59.202.170.152:81/api # 信创线上
# VITE_IMAGE_BASE_PATH = https://stgl.pj.gov.cn/api # 域名线上
VITE_IMAGE_BASE_PATH = https://stgl.pj.gov.cn/api # 域名线上
# ******************** start 开发环境 start ****************
#VITE_APP_DEV_SERVICE = http://59.202.170.152:81/api # 信创线上
# VITE_APP_DEV_SERVICE = https://stgl.pj.gov.cn/api # 域名线上
VITE_APP_DEV_SERVICE = http://192.168.101.81:9999 # 邓-本地
VITE_APP_DEV_SERVICE = https://stgl.pj.gov.cn/api # 域名线上
# VITE_APP_DEV_SERVICE = http://192.168.101.81:9999 # 邓-本地
# VITE_APP_DEV_SERVICE = http://127.0.0.1:9999
# VITE_APP_DEV_SERVICE = http://123.156.230.15:8089/api/ # 线上
# VITE_APP_DEV_SERVICE = http://220.191.229.171:8090/api # 线上
# VITE_APP_DEV_SERVICE = http://localhost:9999
# ******************** end 开发环境 end ********************
+164 -90
View File
@@ -1,4 +1,5 @@
<script lang="ts">
import user from "./sheep/api/user"
import isDevEnv from "./sheep/utils/isDevEnv"
// import { onLaunch, onShow, onHide } from "@dcloudio/uni-app"
@@ -6,7 +7,6 @@ import isDevEnv from "./sheep/utils/isDevEnv"
// onShow(() => {})
// onHide(() => {})
// zhezhengding:浙政钉 | shihua:诗画
const tabbar = [
{
pagePath: "pages/tabbar/canteen",
@@ -14,7 +14,7 @@ const tabbar = [
iconPath: "/static/tabbar/canteen.png",
selectedIconPath: "/static/tabbar/canteen-select.png",
authPath: ["pages/tabbar/canteen"],
auth: ["zhezhengding"],
auth: [],
},
{
pagePath: "pages/tabbar/selfMerchant",
@@ -22,7 +22,7 @@ const tabbar = [
iconPath: "/static/tabbar/selfMerchant.png",
selectedIconPath: "/static/tabbar/selfMerchant-select.png",
authPath: ["pages/tabbar/selfMerchant"],
auth: ["zhezhengding"],
auth: [],
},
{
pagePath: "pages/tabbar/coopMerchant",
@@ -30,7 +30,7 @@ const tabbar = [
iconPath: "/static/tabbar/coopMerchant.png",
selectedIconPath: "/static/tabbar/coopMerchant-select.png",
authPath: ["pages/tabbar/selfMerchant"],
auth: ["zhezhengding"],
auth: ["user"],
},
{
pagePath: "pages/tabbar/order",
@@ -38,7 +38,7 @@ const tabbar = [
iconPath: "/static/tabbar/order.png",
selectedIconPath: "/static/tabbar/order-select.png",
authPath: ["pages/tabbar/canteen", "pages/tabbar/selfMerchant"],
auth: ["zhezhengding"],
auth: ["user"],
},
{
pagePath: "pages/tabbar/flowStatistics",
@@ -46,7 +46,7 @@ const tabbar = [
iconPath: "/static/tabbar/order.png",
selectedIconPath: "/static/tabbar/order-select.png",
authPath: [],
auth: [],
auth: ["merchant"],
},
{
pagePath: "pages/tabbar/individualOrder",
@@ -54,7 +54,7 @@ const tabbar = [
iconPath: "/static/tabbar/order.png",
selectedIconPath: "/static/tabbar/order-select.png",
authPath: [],
auth: [],
auth: ["merchant"],
},
{
pagePath: "pages/tabbar/my",
@@ -62,112 +62,186 @@ const tabbar = [
iconPath: "/static/tabbar/my.png",
selectedIconPath: "/static/tabbar/my-select.png",
authPath: ["pages/tabbar/canteen", "pages/tabbar/selfMerchant"],
auth: ["zhezhengding"],
auth: ["user", "merchant"],
},
]
export default {
onLaunch() {
console.log("环境判断")
// ;(window as any).CP2.getUserInfo().then((res) => {
// console.log(res)
// if (res.code == 0) {
// uni.showToast({ title: res.msg || "当前环境不支持", icon: "none" })
// }
// })
// 诗画浦江获取用户信息进行环境判断
;(window as any).CP2.getAppInfo().then(async (res) => {
if (res.code !== 0) {
// 不是诗画环境
const launchParam = new URL(window.location.href).searchParams.get("launchParam")
console.log("app launch 启动路径参数", launchParam)
switch (launchParam) {
case "canteen":
uni.switchTab({ url: "/pages/tabbar/canteen" })
break
case "selfMerchant":
uni.switchTab({ url: "/pages/tabbar/selfMerchant" })
break
default:
break
}
} else {
// 是诗画环境
const userRole = uni.getStorageSync("userRole")
if (userRole && userRole == "user") uni.switchTab({ url: "/pages/tabbar/coopMerchant" })
if (userRole && userRole == "merchant") uni.switchTab({ url: "/pages/tabbar/individualOrder" })
const launchParam = new URL(window.location.href).searchParams.get("launchParam")
console.log("app launch 启动路径参数", launchParam)
switch (launchParam) {
case "canteen":
uni.switchTab({ url: "/pages/tabbar/canteen" })
break
case "selfMerchant":
uni.switchTab({ url: "/pages/tabbar/selfMerchant" })
break
default:
break
}
const res = await user.isMerchant()
if (res.code == 0) {
if (res.data) {
return uni.redirectTo({ url: "/pages/user/userRole" })
} else {
uni.setStorageSync("userRole", "user")
uni.switchTab({ url: "/pages/tabbar/coopMerchant" })
}
} else {
uni.showToast({ title: "角色身份判断失败", icon: "none" })
}
}
})
},
onShow() {},
onHide() {},
methods: {
_initTabbar() {
// console.log("环境判断")
// let appEnv = 1 // 1:浙政钉 2:诗画
// const launchPath = uni.getLaunchOptionsSync().path
// console.log("启动路径", launchPath)
const launchParam = new URL(window.location.href).searchParams.get("launchParam")
console.log("tabbar launch 启动路径参数", launchParam)
if (isDevEnv()) {
tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath, auth }, index) => {
uni.setTabBarItem({
index,
pagePath,
text,
iconPath,
selectedIconPath,
visible: true,
})
})
} else {
switch (launchParam) {
case "canteen":
tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath }, index) => {
if (authPath.includes("pages/tabbar/canteen")) {
uni.setTabBarItem({
index,
pagePath,
text,
iconPath,
selectedIconPath,
visible: true,
})
} else {
uni.setTabBarItem({
index,
pagePath,
text,
iconPath,
selectedIconPath,
visible: false,
})
}
// 诗画浦江获取用户信息进行环境判断
;(window as any).CP2.getAppInfo().then((res) => {
if (res.code == 0) {
// 不是诗画环境
if (isDevEnv()) {
tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath, auth }, index) => {
uni.setTabBarItem({
index,
pagePath,
text,
iconPath,
selectedIconPath,
visible: true,
})
})
break
case "selfMerchant":
tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath }, index) => {
if (authPath.includes("pages/tabbar/selfMerchant")) {
uni.setTabBarItem({
index,
pagePath,
text,
iconPath,
selectedIconPath,
visible: true,
} else {
switch (launchParam) {
case "canteen":
tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath }, index) => {
if (authPath.includes("pages/tabbar/canteen")) {
uni.setTabBarItem({
index,
pagePath,
text,
iconPath,
selectedIconPath,
visible: true,
})
} else {
uni.setTabBarItem({
index,
pagePath,
text,
iconPath,
selectedIconPath,
visible: false,
})
}
})
} else {
uni.setTabBarItem({
index,
pagePath,
text,
iconPath,
selectedIconPath,
visible: false,
break
case "selfMerchant":
tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath }, index) => {
if (authPath.includes("pages/tabbar/selfMerchant")) {
uni.setTabBarItem({
index,
pagePath,
text,
iconPath,
selectedIconPath,
visible: true,
})
} else {
uni.setTabBarItem({
index,
pagePath,
text,
iconPath,
selectedIconPath,
visible: false,
})
}
})
}
})
break
default:
uni.hideTabBar()
uni.showToast({ title: "启动参数不合法", icon: "none" })
break
break
default:
uni.hideTabBar()
uni.showToast({ title: "启动参数不合法", icon: "none" })
break
}
}
} else {
// 是诗画环境
const userRole = uni.getStorageSync("userRole")
switch (userRole) {
case "user":
tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath, auth }, index) => {
if (auth.includes("user")) {
uni.setTabBarItem({
index,
pagePath,
text,
iconPath,
selectedIconPath,
visible: true,
})
} else {
uni.setTabBarItem({
index,
pagePath,
text,
iconPath,
selectedIconPath,
visible: false,
})
}
})
break
case "merchant":
tabbar.forEach(({ pagePath, text, iconPath, selectedIconPath, authPath, auth }, index) => {
if (auth.includes("merchant")) {
uni.setTabBarItem({
index,
pagePath,
text,
iconPath,
selectedIconPath,
visible: true,
})
} else {
uni.setTabBarItem({
index,
pagePath,
text,
iconPath,
selectedIconPath,
visible: false,
})
}
})
break
default:
uni.hideTabBar()
uni.showToast({ title: "用户身份未确认", icon: "none" })
break
}
}
}
})
},
},
}
+12 -13
View File
@@ -9,13 +9,6 @@
}
},
"pages": [
// {
// "path": "pages/tabbar/userRole",
// "style": {
// "navigationBarTitleText": "用户角色",
// "disableScroll": true
// }
// },
{
"path": "pages/tabbar/canteen",
"style": {
@@ -292,6 +285,18 @@
}
]
},
{
"root": "pages/user",
"pages": [
{
"path": "userRole",
"style": {
"navigationBarTitleText": "用户身份",
"disableScroll": true
}
}
]
},
{
"root": "pages/pay",
"pages": [
@@ -321,12 +326,6 @@
},
"tabBar": {
"list": [
// {
// "pagePath": "pages/tabbar/userRole",
// "text": "",
// "iconPath": "",
// "selectedIconPath": ""
// },
{
"pagePath": "pages/tabbar/canteen",
"text": "",
+26 -15
View File
@@ -75,13 +75,16 @@ const onTabLogin = () => (isDevEnv() ? router.jump("/pages/test/login") : checkA
const loginMethods = {
// 诗画环境登录
async shihuaLogin() {
// const appInfo = await (window as any).CP2.getAppInfo()
// if (appInfo.code !== 0) return false
// const userInfo = await (window as any).CP2.getUserInfo()
// const { accountId, sessionId } = userInfo.data
// return doLogin(1, null, accountId, sessionId)
return false
const appInfo = await (window as any).CP2.getAppInfo()
if (appInfo.code == 0) return false
const userInfo = await (window as any).CP2.getUserInfo()
if (userInfo.code == 0) {
return uni.showToast({ title: "获取诗画用户信息失败", icon: "none" })
} else {
const { accountId, sessionId } = userInfo.data
return doLogin(1, "", accountId, sessionId)
// return doLogin(1, "", "67186e49d63fea141aad6772", "67186e49d63fea141aad6776")
}
},
// 浙政钉登录
@@ -89,7 +92,7 @@ const loginMethods = {
const params = new URL(window.location.href).searchParams
const token = params.get("uabaseToken")
if (token) {
return doLogin(2, token, null, null)
return doLogin(2, token, "", "")
}
return false
},
@@ -113,7 +116,7 @@ const checkAppInfo = async () => {
}
// loginType 1:诗画登录 2:浙政钉登录
const doLogin = async (loginType: number, token: string, accountId: string | null, sessionId: string | null) => {
const doLogin = async (loginType: number, token: string, accountId: string, sessionId: string) => {
const tokenKey = constant.storageConstant.TOKEN
const userInfoKey = constant.storageConstant.USERINFO
const tokenStorage = uni.getStorageSync(tokenKey)
@@ -121,14 +124,22 @@ const doLogin = async (loginType: number, token: string, accountId: string | nul
switch (loginType) {
case 1:
// 诗画
// const params = {
// accountId: accountId,
// sessionId: sessionId,
// }
// const response = await userApi.authsh(params)
// authData = response.data
uni.showLoading({ title: "登录中...", mask: true })
const response = await userApi.authsh({ accountId, sessionId })
if (response.code == 0) {
uni.setStorageSync(tokenKey, { accessToken: response.data.accessToken })
uni.hideLoading()
uni.showToast({ title: "登录成功", icon: "none" })
const { data: userData } = await userApi.userInfo()
uni.setStorageSync(userInfoKey, userData)
getStorageUserInfo()
} else {
uni.hideLoading()
uni.showToast({ title: "登录失败", icon: "none" })
}
break
case 2:
// 浙政钉
if (isEmpty(tokenStorage) || isEmpty(userStorage)) {
try {
uni.showLoading({ title: "登录中...", mask: true })
-3
View File
@@ -1,3 +0,0 @@
<template>aaa</template>
<script setup lang="ts"></script>
+54
View File
@@ -0,0 +1,54 @@
<template>
<view class="flex-col min-h-screen bg-gray-100">
<view class="text-center py-12">
<view class="main-text-40 mb-2">请选择您的身份</view>
</view>
<view class="px-6 my-20">
<view
class="card mb-6 overflow-hidden relative border-8 border-solid border-white duration-200"
:class="{ 'border-8 border-solid border-blue!': userRole === 'user' }"
@click="selectRole('user')"
>
<view class="flex-row items-center p-6">
<view class="w-64 h-64 rounded-full flex-col-center mr-8">
<image src="@/static/page/userRole.svg" />
</view>
<view class="main-text-32 mb-1">我是用户</view>
</view>
</view>
<view
class="card overflow-hidden relative border-8 border-solid border-white duration-200"
:class="{ 'border-8 border-solid border-blue!': userRole === 'merchant' }"
@click="selectRole('merchant')"
>
<view class="flex-row items-center p-6">
<view class="w-64 h-64 rounded-full flex-col-center mr-8">
<image src="@/static/page/merchantRole.svg" />
</view>
<view class="main-text-32 mb-1">我是商户</view>
</view>
</view>
</view>
<view class="flex-row-center px-10 mt-auto pb-10 font-bold">
<tm-button block @click="confirmRole">确 定</tm-button>
</view>
</view>
</template>
<script setup lang="ts">
import { ref } from "vue"
const userRole = ref("user")
const selectRole = (role: "user" | "merchant") => (userRole.value = role)
// 确认选择
const confirmRole = () => {
uni.setStorageSync("userRole", userRole.value)
if (userRole.value === "user") uni.switchTab({ url: "/pages/tabbar/coopMerchant" })
if (userRole.value === "merchant") uni.switchTab({ url: "/pages/tabbar/individualOrder" })
}
</script>
+11 -2
View File
@@ -38,9 +38,9 @@ export default {
}),
// 诗画授权
authsh: (params: { accountId: string; sessionId: string }) =>
authsh: (params: { accountId: string; sessionId: string }): Promise<any> =>
request({
url: `/sys/auth/shjnsso`,
url: `/thirdparty/thirdPartyOAth2/shjnsso`,
method: "POST",
custom: {
showLoading: false,
@@ -87,4 +87,13 @@ export default {
},
})
},
// 判断是否是商户角色
isMerchant: (): Promise<any> =>
request({
url: "/admin/role/isMchUser",
method: "GET",
custom: {
showLoading: false,
},
}),
}
+186 -80
View File
@@ -64,32 +64,57 @@ const checkAndRefreshToken = async (tokenStorage: any) => {
// console.log("现在的时间大于过期时间吗:", new Date().getTime() >= expiresDate)
if (new Date().getTime() >= expiresDate) {
try {
uni.showLoading({ title: "加载中...", mask: true })
const params = new URL(window.location.href).searchParams
const token = params.get("uabaseToken")
if (token) {
const res = await userApi.auth(token)
if (res?.code === 0) {
uni.setStorageSync(TOKEN_KEY, res.data)
} else {
uni.removeStorageSync(TOKEN_KEY)
uni.removeStorageSync(USER_INFO_KEY)
uni.showToast({ title: res.msg, icon: "none" })
const appInfo = await (window as any).CP2.getAppInfo()
if (appInfo.code == 0) {
try {
uni.showLoading({ title: "加载中...", mask: true })
const params = new URL(window.location.href).searchParams
const token = params.get("uabaseToken")
if (token) {
const res = await userApi.auth(token)
if (res?.code === 0) {
uni.setStorageSync(TOKEN_KEY, res.data)
} else {
uni.removeStorageSync(TOKEN_KEY)
uni.removeStorageSync(USER_INFO_KEY)
uni.showToast({ title: res.msg, icon: "none" })
}
}
} catch (error) {
uni.showToast({ title: "错误", icon: "none" })
} finally {
uni.hideLoading()
}
} else {
// 诗画
try {
uni.showLoading({ title: "登录中...", mask: true })
const userInfo = await (window as any).CP2.getUserInfo()
if (userInfo.code == 0) {
return uni.showToast({ title: "获取诗画用户信息失败", icon: "none" })
} else {
const { accountId, sessionId } = userInfo.data
const response = await userApi.authsh({ accountId, sessionId })
if (response.code == 0) {
uni.setStorageSync(TOKEN_KEY, { accessToken: response.data.accessToken })
uni.showToast({ title: "登录成功", icon: "none" })
const { data: userData } = await userApi.userInfo()
uni.setStorageSync(USER_INFO_KEY, userData)
} else {
uni.showToast({ title: "获取用户信息失败", icon: "none" })
}
}
} catch (error) {
uni.showToast({ title: "错误", icon: "none" })
} finally {
uni.hideLoading()
}
} catch (error) {
uni.showToast({ title: "错误", icon: "none" })
} finally {
uni.hideLoading()
}
}
}
// 请求拦截器
http.interceptors.request.use(async (config) => {
console.log("请求之前")
const tokenStorage = uni.getStorageSync(TOKEN_KEY)
const config_header: any = config?.header || {}
@@ -113,7 +138,7 @@ http.interceptors.request.use(async (config) => {
// 设置认证头
if (
!config.url?.startsWith("/thirdparty/thirdPartyOAth2/zzdsso") &&
!config.url?.startsWith("/thirdparty/thirdPartyOAth2") &&
config.url !== "/sys/auth/refresh-token" &&
config.url !== "/auth/oauth2/token"
) {
@@ -127,24 +152,51 @@ http.interceptors.request.use(async (config) => {
}
} else {
// token不存在,则发起登录
const params = new URL(window.location.href).searchParams
const token = params.get("uabaseToken")
const appInfo = await (window as any).CP2.getAppInfo()
if (appInfo.code == 0) {
// 浙政钉
const params = new URL(window.location.href).searchParams
const token = params.get("uabaseToken")
if (token) {
try {
uni.showLoading({ title: "加载中...", mask: true })
const res = await userApi.auth(token)
if (res.code == 0) {
uni.setStorageSync(TOKEN_KEY, res.data)
const { data: userData } = await userApi.userInfo()
uni.setStorageSync(USER_INFO_KEY, userData)
if (token) {
try {
uni.showLoading({ title: "加载中...", mask: true })
const res = await userApi.auth(token)
if (res.code == 0) {
uni.setStorageSync(TOKEN_KEY, res.data)
const { data: userData } = await userApi.userInfo()
uni.setStorageSync(USER_INFO_KEY, userData)
const authHeader = getAuthHeader(tokenStorage)
if (authHeader) {
config_header.Authorization = authHeader
const authHeader = getAuthHeader(tokenStorage)
if (authHeader) {
config_header.Authorization = authHeader
}
} else {
uni.showToast({ title: "获取浙政钉用户信息失败", icon: "none" })
}
} catch (error) {
uni.showToast({ title: "错误", icon: "none" })
} finally {
uni.hideLoading()
}
}
} else {
// 诗画
try {
uni.showLoading({ title: "登录中...", mask: true })
const userInfo = await (window as any).CP2.getUserInfo()
if (userInfo.code == 0) {
return uni.showToast({ title: "获取诗画用户信息失败", icon: "none" })
} else {
uni.showToast({ title: "获取浙政钉用户信息失败", icon: "none" })
const { accountId, sessionId } = userInfo.data
const response = await userApi.authsh({ accountId, sessionId })
if (response.code == 0) {
uni.setStorageSync(TOKEN_KEY, { accessToken: response.data.accessToken })
uni.showToast({ title: "登录成功", icon: "none" })
const { data: userData } = await userApi.userInfo()
uni.setStorageSync(USER_INFO_KEY, userData)
} else {
uni.showToast({ title: "获取用户信息失败", icon: "none" })
}
}
} catch (error) {
uni.showToast({ title: "错误", icon: "none" })
@@ -159,7 +211,7 @@ http.interceptors.request.use(async (config) => {
}, Promise.reject)
// 处理错误响应
const handleErrorResponse = (response: any) => {
const handleErrorResponse = async (response: any) => {
if (!response.config?.custom?.showError) return
switch (response.data.code) {
@@ -172,28 +224,55 @@ const handleErrorResponse = (response: any) => {
}, 500)
break
case 424:
try {
const params = new URL(window.location.href).searchParams
const token = params.get("uabaseToken")
if (token) {
userApi.auth(token).then((res) => {
if (res?.code === 0) {
uni.setStorageSync(TOKEN_KEY, res.data)
} else {
uni.removeStorageSync(TOKEN_KEY)
uni.removeStorageSync(USER_INFO_KEY)
// uni.showToast({ title: "登录已过期", icon: "none" })
return Promise.resolve({
code: 1,
data: "登录已过期",
msg: "登录已过期",
})
}
})
const appInfo = await (window as any).CP2.getAppInfo()
if (appInfo.code == 0) {
try {
const params = new URL(window.location.href).searchParams
const token = params.get("uabaseToken")
if (token) {
userApi.auth(token).then((res) => {
if (res?.code === 0) {
uni.setStorageSync(TOKEN_KEY, res.data)
} else {
uni.removeStorageSync(TOKEN_KEY)
uni.removeStorageSync(USER_INFO_KEY)
// uni.showToast({ title: "登录已过期", icon: "none" })
return Promise.resolve({
code: 1,
data: "登录已过期",
msg: "登录已过期",
})
}
})
}
} catch (error) {
uni.hideLoading()
uni.showToast({ title: "错误", icon: "none" })
}
} else {
// 诗画
try {
uni.showLoading({ title: "登录中...", mask: true })
const userInfo = await (window as any).CP2.getUserInfo()
if (userInfo.code == 0) {
return uni.showToast({ title: "获取诗画用户信息失败", icon: "none" })
} else {
const { accountId, sessionId } = userInfo.data
const response = await userApi.authsh({ accountId, sessionId })
if (response.code == 0) {
uni.setStorageSync(TOKEN_KEY, { accessToken: response.data.accessToken })
uni.showToast({ title: "登录成功", icon: "none" })
const { data: userData } = await userApi.userInfo()
uni.setStorageSync(USER_INFO_KEY, userData)
} else {
uni.showToast({ title: "获取用户信息失败", icon: "none" })
}
}
} catch (error) {
uni.showToast({ title: "错误", icon: "none" })
} finally {
uni.hideLoading()
}
} catch (error) {
uni.hideLoading()
uni.showToast({ title: "错误", icon: "none" })
}
break
default:
@@ -244,7 +323,7 @@ http.interceptors.response.use(
return Promise.resolve(response.data)
},
(error) => {
async (error) => {
// 处理 424 错误(token过期)
if (error.statusCode === 424) {
if (isDevEnv()) {
@@ -255,30 +334,57 @@ http.interceptors.response.use(
router.jump("/pages/test/login")
return false
} else {
try {
uni.showLoading({ title: "加载中...", mask: true })
const params = new URL(window.location.href).searchParams
const token = params.get("uabaseToken")
if (token) {
userApi.auth(token).then((res) => {
if (res?.code === 0) {
uni.setStorageSync(TOKEN_KEY, res.data)
} else {
uni.removeStorageSync(TOKEN_KEY)
uni.removeStorageSync(USER_INFO_KEY)
// uni.showToast({ title: "登录已过期", icon: "none" })
return Promise.resolve({
code: 1,
data: "登录已过期",
msg: "登录已过期",
})
}
})
const appInfo = await (window as any).CP2.getAppInfo()
if (appInfo.code == 0) {
try {
uni.showLoading({ title: "加载中...", mask: true })
const params = new URL(window.location.href).searchParams
const token = params.get("uabaseToken")
if (token) {
userApi.auth(token).then((res) => {
if (res?.code === 0) {
uni.setStorageSync(TOKEN_KEY, res.data)
} else {
uni.removeStorageSync(TOKEN_KEY)
uni.removeStorageSync(USER_INFO_KEY)
// uni.showToast({ title: "登录已过期", icon: "none" })
return Promise.resolve({
code: 1,
data: "登录已过期",
msg: "登录已过期",
})
}
})
}
} catch (error) {
uni.showToast({ title: "错误", icon: "none" })
} finally {
uni.hideLoading()
}
} else {
// 诗画
try {
uni.showLoading({ title: "登录中...", mask: true })
const userInfo = await (window as any).CP2.getUserInfo()
if (userInfo.code == 0) {
return uni.showToast({ title: "获取诗画用户信息失败", icon: "none" })
} else {
const { accountId, sessionId } = userInfo.data
const response = await userApi.authsh({ accountId, sessionId })
if (response.code == 0) {
uni.setStorageSync(TOKEN_KEY, { accessToken: response.data.accessToken })
uni.showToast({ title: "登录成功", icon: "none" })
const { data: userData } = await userApi.userInfo()
uni.setStorageSync(USER_INFO_KEY, userData)
} else {
uni.showToast({ title: "获取用户信息失败", icon: "none" })
}
}
} catch (error) {
uni.showToast({ title: "错误", icon: "none" })
} finally {
uni.hideLoading()
}
} catch (error) {
uni.showToast({ title: "错误", icon: "none" })
} finally {
uni.hideLoading()
}
}
}
+33
View File
@@ -0,0 +1,33 @@
<svg
t="1743474372390"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="23753"
width="48"
height="48"
>
<path d="M0 0h1024v1024H0z" fill="#FFFFFF" p-id="23754"></path>
<path
d="M842 984H182c-33.084 0-60-26.916-60-60V510c0-33.084 26.916-60 60-60h660c33.084 0 60 26.916 60 60v414c0 33.084-26.916 60-60 60z"
fill="#D8DDE3"
p-id="23755"
></path>
<path
d="M182 490c-11.028 0-20 8.972-20 20v414c0 11.028 8.972 20 20 20h660c11.028 0 20-8.972 20-20V510c0-11.028-8.972-20-20-20H182m0-80h660c55.228 0 100 44.772 100 100v414c0 55.228-44.772 100-100 100H182c-55.228 0-100-44.772-100-100V510c0-55.228 44.772-100 100-100z"
fill="#505873"
p-id="23756"
></path>
<path
d="M835.348 566.004c-30.586 0-60.34-9.472-83.784-26.672l-23.66-17.36-23.66 17.356c-23.454 17.204-53.214 26.676-83.8 26.676-30.956 0-60.98-9.668-84.54-27.226L512 520.968l-23.9 17.81c-23.562 17.558-53.586 27.226-84.544 27.226-30.584 0-60.346-9.472-83.8-26.676l-23.66-17.356-23.66 17.36c-23.442 17.2-53.196 26.672-83.782 26.672-72.044 0-130.656-51.26-130.656-114.274 0-2.03 0.06-4.046 0.18-6.05l0.14-2.406-0.146-2.402c-0.056-0.946-0.1-1.9-0.13-2.852L106.44 139.59l0.516-3.18v-3.222c0-51.618 60.894-93.184 111.312-93.184h587.46c50.42 0 111.32 41.566 111.32 93.184v3.222l0.516 3.18 48.386 298.426c-0.03 0.956-0.074 1.906-0.132 2.856l-0.146 2.4 0.142 2.408c0.12 2.004 0.182 4.02 0.182 6.05 0 63.012-58.608 114.274-130.648 114.274z"
fill="#FFFFFF"
p-id="23757"
></path>
<path
d="M835.348 526.004c49.984 0 90.648-33.32 90.648-74.274 0-1.234-0.038-2.46-0.112-3.68l-0.284-4.808 0.184-3.028-47.704-294.22-1.032-6.36v-6.446c0-24.852-37.994-53.184-71.32-53.184h-587.46c-33.324 0-71.312 28.332-71.312 53.184v6.444l-1.032 6.36-47.714 294.23 0.184 3.02-0.286 4.808c-0.072 1.22-0.108 2.446-0.108 3.68 0 40.954 40.666 74.274 90.656 74.274 22.138 0 43.49-6.72 60.12-18.922l47.316-34.714 47.324 34.706c16.644 12.208 38.004 18.93 60.142 18.93 22.404 0 43.94-6.856 60.642-19.3l47.802-35.622 47.8 35.62c16.704 12.446 38.24 19.302 60.644 19.302 22.138 0 43.498-6.722 60.14-18.93l47.322-34.706 47.316 34.714c16.634 12.204 37.986 18.922 60.124 18.922m0 80c-40.722 0-78.116-12.902-107.446-34.422-29.34 21.52-66.732 34.422-107.456 34.422-41.188 0-78.962-13.184-108.444-35.152-29.48 21.968-67.256 35.152-108.444 35.152-40.724 0-78.116-12.902-107.456-34.422-29.33 21.52-66.732 34.422-107.446 34.422C94.404 606.004 18 536.938 18 451.73c0-2.828 0.084-5.632 0.25-8.426A135.136 135.136 0 0 1 18 435.08L66.956 133.188c0-73.556 77.574-133.184 151.312-133.184h587.46c73.736 0 151.32 59.628 151.32 133.184l48.948 301.89c0 2.76-0.086 5.504-0.252 8.226 0.166 2.794 0.252 5.6 0.252 8.426 0 85.208-76.396 154.274-170.648 154.274z"
fill="#505873"
p-id="23758"
></path>
<path d="M262 362h500a40 40 0 0 1 0 80H262a40 40 0 0 1 0-80z" fill="#FF402A" p-id="23759"></path>
</svg>

After

Width:  |  Height:  |  Size: 3.0 KiB

+21
View File
@@ -0,0 +1,21 @@
<svg
t="1743474000421"
class="icon"
viewBox="0 0 1024 1024"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
p-id="28044"
width="48"
height="48"
>
<path
d="M564.63 935.61c-23.13 0-41.94-18.82-41.94-41.94 0-38.83 10.32-76.93 29.86-110.19 18.97-32.3 46.16-59.24 78.76-78.08-31.95-29.91-50.18-71.95-50.14-115.86 0-87.62 71.29-158.9 158.91-158.9S899 501.92 899 589.55c0 43.86-18.24 85.91-50.14 115.86 32.61 18.83 59.8 45.77 78.77 78.07 19.53 33.25 29.86 71.36 29.86 110.19 0 23.13-18.82 41.94-41.94 41.94H564.63z m302.26-83.88c-17.57-53.47-66.78-90.11-123.4-91.53l-3.43-0.03c-57.2 0.01-108.88 37.51-126.76 91.57h253.59z m-126.8-337.21c-41.37 0-75.02 33.66-75.02 75.03 0 41.37 33.66 75.03 75.02 75.03s75.02-33.66 75.02-75.03c0-41.37-33.65-75.03-75.02-75.03zM155.24 935.61c-23.13 0-45.03-8.85-61.66-24.92-16.63-16.07-26.23-37.65-27.02-60.77l-0.05-2.93V180.16c0-23.13 8.85-45.03 24.92-61.66 16.07-16.63 37.65-26.23 60.77-27.02l2.93-0.05h620.04c23.13 0 45.03 8.85 61.66 24.92 16.63 16.07 26.23 37.65 27.02 60.77l0.05 2.93v187.26c0.03 22.86-17.86 41.29-40.71 41.96-0.42 0.01-0.84 0.02-1.25 0.02-22.19 0-40.57-17.36-41.86-39.53l-0.07-2.39V180.15c0-2.39-1.77-4.44-4.12-4.79l-0.92-0.05H155.24c-2.39 0-4.44 1.76-4.79 4.12l-0.06 0.93v666.52c0 2.39 1.77 4.44 4.12 4.79l0.93 0.06h292.21c22.86 0 41.29 17.88 41.96 40.71 0.67 22.86-16.69 41.79-39.51 43.11l-2.35 0.07H155.24z"
fill="#303133"
p-id="28045"
></path>
<path
d="M258.25 672.43v-0.06c-21.8-1.12-39.05-18.58-39.69-40.66-0.67-22.85 16.68-41.78 39.51-43.1l2.39-0.07h234c22.86 0 41.29 17.88 41.96 40.72 0.67 22.85-16.68 41.78-39.51 43.11l-2.35 0.07H258.25z m0-263.18v-0.06c-21.8-1.12-39.05-18.57-39.69-40.66-0.67-22.85 16.68-41.78 39.51-43.1l2.39-0.07h350.97c22.86 0 41.29 17.88 41.96 40.71 0.67 22.85-16.68 41.79-39.51 43.11l-2.36 0.07H258.25z"
fill="#FF6F26"
p-id="28046"
></path>
</svg>

After

Width:  |  Height:  |  Size: 1.9 KiB