chore:提取公共常量

This commit is contained in:
weiwei committed 2025-08-26 20:12:22 +08:00
1 parent 97eb387436
commit 88e5660b29
8 files changed
+41 -19

No files matched your search

+3 -2
View File
@@ -1,6 +1,7 @@
<script lang="ts">
import { getLaunchParam } from "@/sheep/utils/app"
import { getAppInfo } from "@@/utils/app"
import { APPENV } from "./sheep/constant"
interface TabbarItem {
pagePath: string
@@ -152,7 +153,7 @@ export default {
const appInfo = await getAppInfo()
// 浙政钉环境
if (appInfo == "zzd") {
if (appInfo == APPENV.ZZD) {
if (!launchParam) return uni.hideTabBar()
setTabbar(launchParam)
@@ -161,7 +162,7 @@ export default {
}
// 诗画环境
if (appInfo == "sh") {
if (appInfo == APPENV.SH) {
if (!launchParam) return uni.hideTabBar()
const userRole = uni.getStorageSync("userRole")
+14 -8
View File
@@ -137,13 +137,15 @@
import { reactive, nextTick } from "vue"
import { onLoad, onShow } from "@dcloudio/uni-app"
import { isEmpty } from "radash"
import { router } from "@@/index"
import { hooks, router } from "@@/index"
import { foodApi, merchantApi, payApi, shopApi } from "@@/api"
import { filePath } from "@@/utils/file"
import ProductRow from "./components/product-row.vue"
import ProductCart from "./components/product-cart.vue"
import ProductTotal from "./components/product-total.vue"
import ProductSku from "./components/product-sku.vue"
import { getAppInfo } from "@/sheep/utils/app"
import { APPENV } from "@/sheep/constant"
// 商品详情相关数据
const state = reactive<any>({
@@ -336,15 +338,19 @@ const submitPay = async () => {
}
// 联系商家
const doPhone = (item: string) => {
if (isEmpty(item)) {
uni.showToast({ title: "该商户没有预留电话", icon: "none" })
const doPhone = async (item: string) => {
if (isEmpty(item)) return uni.showToast({ title: "该商户没有预留电话", icon: "none" })
if ((await getAppInfo()) == APPENV.ZZD) {
;(window as any).dd
.callPhone({ phoneNum: item.trim() })
.then((res) => {})
.catch((err) => {})
return
}
if ((await getAppInfo()) == APPENV.SH) {
hooks.useMakePhoneCall(item.trim())
return
}
;(window as any).dd
.callPhone({ phoneNum: item.trim() })
.then((res) => {})
.catch((err) => {})
}
</script>
+3 -2
View File
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { APPENV } from "@/sheep/constant"
import { getAppInfo, getLaunchParam, isDevEnv } from "@/sheep/utils/app"
import { onShow } from "@dcloudio/uni-app"
@@ -57,7 +58,7 @@ const jumpByParam = async () => {
const launchParam = getLaunchParam() // 获取启动参数
// 浙政钉环境
if (appInfo == "zzd") {
if (appInfo == APPENV.ZZD) {
switch (launchParam) {
case "canteen": // 食堂
uni.setStorageSync("launchParam", launchParam)
@@ -87,7 +88,7 @@ const jumpByParam = async () => {
}
// 诗画环境
if (appInfo == "sh") {
if (appInfo == APPENV.SH) {
const userRole = uni.getStorageSync("userRole") // 获取用户角色
if (!launchParam) return uni.hideTabBar()
+4 -3
View File
@@ -40,7 +40,7 @@
</view>
</view>
<view class="h-30rpx" />
<view v-if="state.appInfo == 'sh'" class="flex-col-center m-t-40rpx m-x-30rpx">
<view v-if="state.appInfo == APPENV.SH" class="flex-col-center m-t-40rpx m-x-30rpx">
<view class="w-full text-center sub-text-28 p-y-20rpx rounded-40rpx border-solid border border-#0094ff" @tap="doChangeRole">
切换角色
</view>
@@ -68,6 +68,7 @@ import { getAppInfo } from "@@/utils/app"
import { hooks, router, constant } from "@@/index"
import { userApi } from "@@/api"
import { isDevEnv } from "@/sheep/utils/app"
import { APPENV } from "@/sheep/constant"
const state = reactive<{
wallet: any[]
@@ -300,11 +301,11 @@ const scanCode = {
uni.showModal({ content: "开发环境不是浙政钉和诗画环境,扫码仅供测试,收款商家为测试商户超市" })
return testQrCode
} else if (state.appInfo == "zzd") {
} else if (state.appInfo == APPENV.ZZD) {
// 浙政钉扫码
const res: any = await (window as any).dd.scan({ type: "all" })
return res.text
} else if (state.appInfo == "sh") {
} else if (state.appInfo == APPENV.SH) {
// 诗画扫码
const res = await (window as any).CP2.showScanQr({ needResult: 1 })
if (res.code == 1) return res.data.qrCode
+7
View File
@@ -0,0 +1,7 @@
/**
* ZZD:浙政钉 | SH:诗画
*/
export default {
ZZD: "zzd",
SH: "sh",
}
+2
View File
@@ -1,3 +1,5 @@
export { default as serviceEnum } from "./service-enum"
export { default as storageConstant } from "./storage-constant"
export { default as APPENV } from "./app-env"
+5 -2
View File
@@ -1,4 +1,7 @@
// app运行环境
import { APPENV } from "../constant"
// export default () => import.meta.env.VITE_DEV_ENV === "dev"
export const isDevEnv = (): boolean => process.env.NODE_ENV === "development"
@@ -14,11 +17,11 @@ export const getAppInfo = async (): Promise<string> => {
// 浙政钉环境
if (res.code === 0) {
console.log("环境:浙政钉-zzd")
return "zzd"
return APPENV.ZZD
} else {
// 诗画环境
console.log("环境:诗画浦江-sh")
return "sh"
return APPENV.SH
}
} catch (error) {
return "unknown"
+3 -2
View File
@@ -4,6 +4,7 @@ import { isEmpty } from "radash"
import { getAppInfo, isDevEnv } from "@@/utils/app"
import { userApi } from "../api"
import showVerifyDeviceImpModel from "../components/verifyDeviceImpModel/verifyDeviceImpModel"
import { APPENV } from "../constant"
const TOKEN_KEY = constant.storageConstant.TOKEN
const USER_INFO_KEY = constant.storageConstant.USERINFO
@@ -210,9 +211,9 @@ async function refreshToken(): Promise<any> {
const autoLogin = async (): Promise<boolean> => {
const appInfo = await getAppInfo()
// 浙政钉环境
if (appInfo == "zzd") return await loginByZzd()
if (appInfo == APPENV.ZZD) return await loginByZzd()
// 诗画环境
if (appInfo == "sh") return await loginBySh()
if (appInfo == APPENV.SH) return await loginBySh()
uni.showToast({ title: "app环境错误", icon: "none" })
return false