联系热线和智能柜角色校验

This commit is contained in:
weiwei committed 2025-04-21 15:33:35 +08:00
1 parent 35d4b2c663
commit a222670d64
4 files changed
+69 -16

No files matched your search

+19 -11
View File
@@ -1,5 +1,4 @@
<script lang="ts">
import { userApi } from "./sheep/api"
import isDevEnv from "./sheep/utils/isDevEnv"
import { getAppInfo } from "@@/utils/getAppInfo"
@@ -32,7 +31,7 @@ const tabbar: TabbarItem[] = [
iconPath: "/static/tabbar/selfMerchant.png",
selectedIconPath: "/static/tabbar/selfMerchant-select.png",
launchParam: ["selfMerchant"],
auth: [],
auth: ["user"],
},
{
pagePath: "pages/tabbar/coopMerchant",
@@ -42,14 +41,14 @@ const tabbar: TabbarItem[] = [
launchParam: ["selfMerchant"],
auth: ["user"],
},
// {
// pagePath: "pages/tabbar/cabinet",
// text: "智能柜",
// iconPath: "/static/tabbar/cabinet.png",
// selectedIconPath: "/static/tabbar/cabinet-select.png",
// launchParam: ["selfMerchant"],
// auth: ["user"],
// },
{
pagePath: "pages/tabbar/cabinet",
text: "智能柜",
iconPath: "/static/tabbar/cabinet.png",
selectedIconPath: "/static/tabbar/cabinet-select.png",
launchParam: ["selfMerchant"],
auth: ["cabinetAdmin"],
},
{
pagePath: "pages/tabbar/order",
text: "订单",
@@ -112,7 +111,16 @@ const setTabbarByLaunchParam = (launchParam: string) => {
// 根据用户角色设置tabbar项目
const setTabbarByUserRole = (role: string) => {
tabbar.forEach((item, index) => {
const visible = item.auth.includes(role)
let visible = false
if (item.auth.includes("cabinetAdmin")) {
if (uni.getStorageSync("isHardDoorAdmin") == "true") {
visible = true
} else {
visible = false
}
} else {
visible = item.auth.includes(role)
}
setTabbarItem(index, item, visible)
})
}
+9
View File
@@ -3,6 +3,7 @@
<z-paging
ref="pageRef"
:fixed="false"
height="100%"
v-model="pageHook.list"
:default-page-size="10"
safe-area-inset-bottom
@@ -111,6 +112,7 @@ onShow(() => {
if (pageRef.value) {
pageRef.value.reload(false)
}
// getTotalWatar()
})
const query = (page: number, pagesize: number) => {
@@ -124,4 +126,11 @@ const datePickerConfirm = (date: any) => {
state.pa.createTimeList = formatVal.value.split("~")
pageRef.value.reload(false)
}
// 查询全部流水
// const getTotalWatar = async () => {
// const res: any = await flowStatisticsApi.mchWaterTotal()
// if (res.code == 0) {
// }
// }
</script>
+12
View File
@@ -42,6 +42,13 @@
切换角色
</view>
</view>
<view class="absolute bottom-0 left-0 right-0 second-text-26 text-center my-1">
<text>联系热线:</text>
<text @click="doPhone('18367908152')">18367908152</text>
&nbsp;
<text @click="doPhone('15657370065')">15657370065</text>
</view>
</crud-layout>
</template>
@@ -383,6 +390,11 @@ onShow(() => {
// 获取存储中的用户信息
storage.getUserInfo()
})
// 联系客服
const doPhone = (phone: string) => {
hooks.useMakePhoneCall(phone)
}
</script>
<style lang="scss" scoped>
+29 -5
View File
@@ -49,21 +49,45 @@ const selectRole = (role: "user" | "merchant") => (userRole.value = role)
// 确认选择
const confirmRole = async () => {
if (userRole.value === "user") {
uni.setStorageSync("userRole", userRole.value)
uni.reLaunch({ url: "/pages/tabbar/coopMerchant" })
return
uni.showLoading({ title: "正在验证身份", mask: true })
const res: any = await userApi.userRole().finally(() => uni.hideLoading())
if (res.code == 0) {
if (res.data.isHardDoorAdmin) {
uni.setStorageSync("userRole", userRole.value)
uni.setStorageSync("isHardDoorAdmin", "true")
uni.reLaunch({ url: "/pages/tabbar/coopMerchant" })
return
} else {
uni.setStorageSync("userRole", userRole.value)
uni.setStorageSync("isHardDoorAdmin", "false")
uni.reLaunch({ url: "/pages/tabbar/coopMerchant" })
return
}
} else {
uni.setStorageSync("userRole", userRole.value)
uni.setStorageSync("isHardDoorAdmin", "false")
uni.reLaunch({ url: "/pages/tabbar/coopMerchant" })
return
}
}
if (userRole.value === "merchant") {
uni.showLoading({ title: "正在验证身份", mask: true })
const res = await userApi.isMerchant().finally(() => uni.hideLoading())
const res: any = await userApi.userRole().finally(() => uni.hideLoading())
if (res.code == 0) {
if (res.data) {
if (res.data.isMch) {
uni.setStorageSync("userRole", userRole.value)
if (res.data.isHardDoorAdmin) {
uni.setStorageSync("isHardDoorAdmin", "true")
} else {
uni.setStorageSync("isHardDoorAdmin", "false")
}
uni.reLaunch({ url: "/pages/tabbar/individualOrder" })
return
} else {
uni.showToast({ title: "您不是商户", icon: "none" })
}
} else {
uni.showToast({ title: "身份验证失败", icon: "none" })
}
}
}