diff --git a/src/App.vue b/src/App.vue
index 9f0d742..d9dc173 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -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
+ }
}
- }
+ })
},
},
}
diff --git a/src/pages.json b/src/pages.json
index 191b91e..b193088 100644
--- a/src/pages.json
+++ b/src/pages.json
@@ -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": "",
diff --git a/src/pages/tabbar/userRole.vue b/src/pages/tabbar/userRole.vue
deleted file mode 100644
index bf91dd0..0000000
--- a/src/pages/tabbar/userRole.vue
+++ /dev/null
@@ -1,3 +0,0 @@
-aaa
-
-
diff --git a/src/pages/user/userRole.vue b/src/pages/user/userRole.vue
new file mode 100644
index 0000000..5e096cc
--- /dev/null
+++ b/src/pages/user/userRole.vue
@@ -0,0 +1,54 @@
+
+
+
+ 请选择您的身份
+
+
+
+
+
+
+
+
+ 我是用户
+
+
+
+
+
+
+
+
+ 我是商户
+
+
+
+
+
+ 确 定
+
+
+
+
+
diff --git a/src/static/page/merchantRole.svg b/src/static/page/merchantRole.svg
new file mode 100644
index 0000000..0ec265d
--- /dev/null
+++ b/src/static/page/merchantRole.svg
@@ -0,0 +1,33 @@
+
\ No newline at end of file
diff --git a/src/static/page/userRole.svg b/src/static/page/userRole.svg
new file mode 100644
index 0000000..613b7b4
--- /dev/null
+++ b/src/static/page/userRole.svg
@@ -0,0 +1,21 @@
+
\ No newline at end of file