feat: 对接完接口

This commit is contained in:
anonymous
2025-01-02 11:05:26 +08:00
parent 6d62cc0567
commit bcd940efe3
48 changed files with 1711 additions and 360 deletions
+32 -20
View File
@@ -1,5 +1,6 @@
import { pages, subPackages, tabBar } from '@/pages.json'
import { isMp } from './platform'
import dayjs from 'dayjs'
export const getLastPage = () => {
// getCurrentPages() 至少有1个元素,所以不再额外判断
@@ -128,26 +129,7 @@ export const notNeedLoginPages: string[] = getAllPages('notNeedLogin').map((page
*/
export const getEnvBaseUrl = () => {
// 请求基准地址
let baseUrl = import.meta.env.VITE_SERVER_BASEURL
// 小程序端环境区分
if (isMp) {
const {
miniProgram: { envVersion },
} = uni.getAccountInfoSync()
switch (envVersion) {
case 'develop':
baseUrl = 'https://ukw0y1.laf.run'
break
case 'trial':
baseUrl = 'https://ukw0y1.laf.run'
break
case 'release':
baseUrl = 'https://ukw0y1.laf.run'
break
}
}
const baseUrl = import.meta.env.VITE_SERVER_BASEURL
return baseUrl
}
@@ -158,6 +140,9 @@ export const getEnvBaseUrl = () => {
export const getEnvBaseUploadUrl = () => {
// 请求基准地址
let baseUploadUrl = import.meta.env.VITE_UPLOAD_BASEURL
if (JSON.parse(__VITE_APP_PROXY__)) {
baseUploadUrl = `${import.meta.env.VITE_APP_PROXY_PREFIX}/${baseUploadUrl.split(import.meta.env.VITE_APP_PROXY_PREFIX + '/')[1]}`
}
// 小程序端环境区分
if (isMp) {
@@ -207,3 +192,30 @@ export function mergeStep(wrapped: (...rest: any[]) => Promise<any>) {
return _mergeStepRequestInstance
}
}
// Promise 版modal
export const showModal = (
content: string,
{ showCancel, title, ...options }: UniApp.ShowModalOptions = {},
) => {
return new Promise((resolve, reject) =>
uni.showModal({
showCancel: showCancel === true,
title: title || '提示',
...options,
content,
success(e) {
if (e.confirm) {
return resolve(e)
}
reject(e)
},
fail: reject,
}),
)
}
/** 格式化时间 */
export const formatTime = (time: string | number) => {
return dayjs(time).format('YYYY-MM-DD HH:mm:ss')
}