诗画用户登录身份选择和tabbar控制
This commit is contained in:
1 parent
e908eab8fd
commit
64636d0eab
6 files changed
+270
-107
No files matched your search
+150
-91
@@ -6,7 +6,6 @@ import isDevEnv from "./sheep/utils/isDevEnv"
|
||||
// onShow(() => {})
|
||||
// onHide(() => {})
|
||||
|
||||
// zhezhengding:浙政钉 | shihua:诗画
|
||||
const tabbar = [
|
||||
{
|
||||
pagePath: "pages/tabbar/canteen",
|
||||
@@ -14,7 +13,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 +21,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 +29,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 +37,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 +45,7 @@ const tabbar = [
|
||||
iconPath: "/static/tabbar/order.png",
|
||||
selectedIconPath: "/static/tabbar/order-select.png",
|
||||
authPath: [],
|
||||
auth: [],
|
||||
auth: ["merchant"],
|
||||
},
|
||||
{
|
||||
pagePath: "pages/tabbar/individualOrder",
|
||||
@@ -54,7 +53,7 @@ const tabbar = [
|
||||
iconPath: "/static/tabbar/order.png",
|
||||
selectedIconPath: "/static/tabbar/order-select.png",
|
||||
authPath: [],
|
||||
auth: [],
|
||||
auth: ["merchant"],
|
||||
},
|
||||
{
|
||||
pagePath: "pages/tabbar/my",
|
||||
@@ -62,112 +61,172 @@ 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" })
|
||||
// }
|
||||
// })
|
||||
|
||||
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
|
||||
}
|
||||
// 诗画浦江获取用户信息进行环境判断
|
||||
;(window as any).CP2.getUserInfo().then((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 {
|
||||
// 是诗画环境
|
||||
return uni.redirectTo({ url: "/pages/user/userRole" })
|
||||
}
|
||||
})
|
||||
},
|
||||
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.getUserInfo().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
@@ -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": "",
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<template>aaa</template>
|
||||
|
||||
<script setup lang="ts"></script>
|
||||
@@ -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>
|
||||
@@ -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 |
@@ -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 |
Reference in new issue
Block a user