feat: remove backbtn and create weixin adapter

master
xjs 2025-07-31 11:00:37 +08:00
parent 6d91e71dc3
commit f8d31917da
9 changed files with 188 additions and 179 deletions

View File

@ -6,7 +6,7 @@
<X />
</div>
<div class="m-[34rpx] flex items-center">
<img src="/images/product/share-wx.png" alt="share-qrcode" class="w-[320rpx] h-[284rpx]" />
<img src="/images/product/share-wx.png" alt="share-qrcode" class="w-[320rpx] h-[284rpx]" @click="handleShareWx"/>
<img src="/images/product/share-friend.png" alt="share-friend" class="w-[320rpx] h-[284rpx]" />
</div>
</div>
@ -15,6 +15,7 @@
<script lang="ts" setup>
import { X } from "lucide-vue-next";
import { useRoute } from "vue-router";
const props = defineProps({
show: {
@ -23,6 +24,7 @@
},
});
const route = useRoute();
const emits = defineEmits(["update:show"]);
const innerShow = computed({
@ -37,4 +39,19 @@
const handleClose = () => {
emits("update:show", false);
};
const handleShareWx = () => {
uni.postMessage({
data: {
type: "share",
msg: {
type: "wx",
},
},
})
uni.navigateTo({
url: `/pages/temporary/index?webFullPath=${encodeURIComponent(route.fullPath)}`,
})
}
</script>

View File

@ -8,13 +8,13 @@
</nut-tabbar>
</template>
<script lang="ts" setup>
import { menus } from "@/composables/useTabbar";
import { ref } from "vue";
import { useRoute } from "vue-router";
const route = useRoute()
const activeIndex = ref(0);
const menus = [{name:'首页',href:'/home'},{name:'健康',href:"/medical"},{name:'商城',href:'/shop'},{name:'我的',href:'/mine'}]
// const routeQuery = Object.entries(route.query).map(([key, value]) => `${key}=${value}`).join("&");
const tabSwitch = (item: Record<string, unknown>, index: number) => {

View File

@ -0,0 +1,6 @@
export const menus = [
{ name: "首页", href: "/home" },
{ name: "健康", href: "/medical" },
{ name: "商城", href: "/shop" },
{ name: "我的", href: "/mine" },
];

View File

@ -1,8 +1,12 @@
import { createRouter, createWebHistory } from "vue-router";
import { publicRoutes } from "./publicRoutes";
import { privateRoutes } from "./privateRoutes";
import type { RouteLocationNormalized, NavigationGuardNext } from 'vue-router';
import { menus } from "@/composables/useTabbar";
function getRoutes() {
const routes = [ // 私有路由,请在这里添加
const routes = [
// 私有路由,请在这里添加
...privateRoutes,
// 公共路由
@ -19,12 +23,10 @@ const router = createRouter({
routes: getRoutes(),
});
// 全局前置守卫,这边可以对身份进行验证
router.beforeEach((to, _from, next) => {
let userRole = "admin";
// 如果目标路由没有角色限制
function checkUserRole(to: RouteLocationNormalized, userRole: string, next: NavigationGuardNext) {
if (!to.meta.role) {
next();
return;
}
// 判断当前用户角色是否在目标路由的允许角色列表中
if ((to.meta.role as string[]).includes(userRole)) {
@ -34,6 +36,25 @@ router.beforeEach((to, _from, next) => {
// 如果角色不匹配,跳转到 unauthorized 页面
next({ path: "/unauthorized" });
}
}
// 全局前置守卫,这边可以对身份进行验证
router.beforeEach((to, _from, next) => {
let userRole = "admin";
// 如果目标路由没有角色限制
if(typeof uni !== 'undefined'){
uni.getEnv((res) => {
if(res.miniprogram && _from.fullPath !== '/' && menus.findIndex(item => item.href === to.path) === -1){
uni.navigateTo({
url: `/pages/temporary/index?webFullPath=${encodeURIComponent(to.fullPath)}`,
})
}else{
checkUserRole(to, userRole, next);
}
})
}else{
checkUserRole(to, userRole, next);
}
});
// 监听路由变化,动态设置网页标题

View File

@ -9,7 +9,7 @@ export const publicRoutes:RouteRecordRaw[] = [
},
components: {
default: () => import("../views/home/index.vue"),
tabbar: () => import("../components/tabbar/index.vue")
tabbar: () => import("../components/tabbar/index.vue"),
},
},
{
@ -18,7 +18,7 @@ export const publicRoutes:RouteRecordRaw[] = [
meta: {
title: "新增地址",
},
components: {default:() => import("../views/location/map.vue"),backButton:() => import("../components/back-button/index.vue")},
components: { default: () => import("../views/location/map.vue") },
},
{
path: "/location/administrative",
@ -36,7 +36,7 @@ export const publicRoutes:RouteRecordRaw[] = [
},
components: {
default: () => import("../views/medical/index.vue"),
tabbar: () => import("../components/tabbar/index.vue")
tabbar: () => import("../components/tabbar/index.vue"),
},
},
{
@ -47,7 +47,7 @@ export const publicRoutes:RouteRecordRaw[] = [
},
components: {
default: () => import("../views/shop/index.vue"),
tabbar: () => import("../components/tabbar/index.vue")
tabbar: () => import("../components/tabbar/index.vue"),
},
},
{
@ -64,10 +64,7 @@ export const publicRoutes:RouteRecordRaw[] = [
meta: {
title: "确认订单",
},
components: {default:() => import("../views/checkout/index.vue"),backButton:() => import("../components/back-button/index.vue")},
props:{
backButton:{bottom:"15vh"}
}
components: { default: () => import("../views/checkout/index.vue") },
},
{
path: "/checkout/payment",
@ -81,23 +78,17 @@ export const publicRoutes:RouteRecordRaw[] = [
path: "/checkout/health-care",
name: "health-care-checkout",
meta: {
title:"确认订单"
title: "确认订单",
},
components:{default:() => import("../views/checkout/healthCare.vue"),backButton:() => import("../components/back-button/index.vue")},
props:{
backButton:{bottom:"15vh"}
}
components: { default: () => import("../views/checkout/healthCare.vue") },
},
{
path: "/housekeeping/order/:id",
name: "housekeeping-checkout",
meta: {
title:"确认订单"
title: "确认订单",
},
components:{default:() => import("../views/housekeeping/order.vue"),backButton:() => import("../components/back-button/index.vue")},
props:{
backButton:{bottom:"15vh"}
}
components: { default: () => import("../views/housekeeping/order.vue") },
},
{
@ -108,211 +99,184 @@ export const publicRoutes:RouteRecordRaw[] = [
},
components: {
default: () => import("../views/mine/index.vue"),
tabbar: () => import("../components/tabbar/index.vue")
tabbar: () => import("../components/tabbar/index.vue"),
},
},
{
path:'/mine/address',
name:'my-address',
path: "/mine/address",
name: "my-address",
meta: {
title:'收获地址管理'
title: "收获地址管理",
},
component: () => import("../views/mine/addressManagement.vue")
component: () => import("../views/mine/addressManagement.vue"),
},
{
path:'/mine/add/address',
name:'add-address',
path: "/mine/add/address",
name: "add-address",
meta: {
title:'收获地址管理'
title: "收获地址管理",
},
component: () => import("../views/mine/addAddress.vue")
component: () => import("../views/mine/addAddress.vue"),
},
{
path:'/mine/add/paramedic',
name:'add-paramedic',
path: "/mine/add/paramedic",
name: "add-paramedic",
meta: {
title:'新增被护理人'
title: "新增被护理人",
},
component: () => import("../views/mine/addParamedic.vue")
component: () => import("../views/mine/addParamedic.vue"),
},
{
path:'/mine/notice',
name:'notice',
path: "/mine/notice",
name: "notice",
meta: {
title:'消息中心'
title: "消息中心",
},
components: {default:() => import("../views/mine/notice.vue"),backButton:() => import("../components/back-button/index.vue")},
props:{
backButton:{bottom:"15vh"}
}
components: { default: () => import("../views/mine/notice.vue") },
},
{
path:'/mine/orders',
path: "/mine/orders",
name: "mine-orders",
meta: {
title:'我的订单'
title: "我的订单",
},
components: {default:() => import("../views/mine/orders.vue"),backButton:() => import("../components/back-button/index.vue")},
props:{
backButton:{bottom:"15vh"}
}
components: { default: () => import("../views/mine/orders.vue") },
},
{
path:'/mine/user-info',
name:'mine-user-info',
path: "/mine/user-info",
name: "mine-user-info",
meta: {
title:'个人资料'
title: "个人资料",
},
component: () => import("../views/mine/userInfo.vue")
component: () => import("../views/mine/userInfo.vue"),
},
{
path:'/restaurant',
name:'restaurant',
path: "/restaurant",
name: "restaurant",
meta: {
title:'社区点餐'
title: "社区点餐",
},
components: {default:() => import("../views/restaurant/index.vue"),backButton:() => import("../components/back-button/index.vue")},
props:{
backButton:{bottom:"15vh"}
}
components: { default: () => import("../views/restaurant/index.vue") },
},
{
path: "/restaurant/detail/:id",
name: "restaurant-detail",
meta: {
title:"商品详情"
title: "商品详情",
},
components: {default:() => import("../views/restaurant/detail.vue"),backButton:() => import("../components/back-button/index.vue")}
components: { default: () => import("../views/restaurant/detail.vue") },
},
{
path:'/courses',
name:'courses',
path: "/courses",
name: "courses",
meta: {
title:'课程学习'
title: "课程学习",
},
components: {default:() => import("../views/courses/index.vue"),backButton:() => import("../components/back-button/index.vue")},
props:{
backButton:{bottom:"15vh"}
}
components: { default: () => import("../views/courses/index.vue") },
},
{
path:'/courses/detail/:id',
name:'courses-detail',
path: "/courses/detail/:id",
name: "courses-detail",
meta: {
title:'课程详情'
title: "课程详情",
},
components: {default:() => import("../views/courses/detail.vue"),backButton:() => import("../components/back-button/index.vue")}
components: { default: () => import("../views/courses/detail.vue") },
},
{
path:'/courses/cart/:id',
name:'courses-cart',
path: "/courses/cart/:id",
name: "courses-cart",
meta: {
title:'购买课程'
title: "购买课程",
},
component: () => import("../views/courses/courseCart.vue")
component: () => import("../views/courses/courseCart.vue"),
},
{
path:'/travel',
name:'travel',
path: "/travel",
name: "travel",
meta: {
title:'乐享夕阳行'
title: "乐享夕阳行",
},
components: {default:() => import("../views/travel/index.vue"),backButton:() => import("../components/back-button/index.vue")},
props:{
backButton:{bottom:"15vh"}
}
components: { default: () => import("../views/travel/index.vue") },
},
{
path:'/health-care',
name:'health-care',
path: "/health-care",
name: "health-care",
meta: {
title:'康养护理'
title: "康养护理",
},
components: {default:() => import("../views/healthCare/index.vue"),backButton:() => import("../components/back-button/index.vue")},
props:{
backButton:{bottom:"15vh"}
}
components: { default: () => import("../views/healthCare/index.vue") },
},
{
path:'/health-care/order/:id',
name:'health-care-order',
path: "/health-care/order/:id",
name: "health-care-order",
meta: {
title:'预约'
title: "预约",
},
components: {default:() => import("../views/healthCare/order.vue"),backButton:() => import("../components/back-button/index.vue")},
components: { default: () => import("../views/healthCare/order.vue") },
},
{
path:'/jinze',
name:'jinze',
path: "/jinze",
name: "jinze",
meta: {
title:'锦泽安康'
title: "锦泽安康",
},
components: {default:() => import("../views/jinze/index.vue"),backButton:() => import("../components/back-button/index.vue")},
props:{
backButton:{bottom:"15vh"}
}
components: { default: () => import("../views/jinze/index.vue") },
},
{
path:'/jinze/detail/:id',
name:'jinze-detail',
path: "/jinze/detail/:id",
name: "jinze-detail",
meta: {
title:'养老院详情'
title: "养老院详情",
},
components: {default:() => import("../views/jinze/detail.vue"),backButton:() => import("../components/back-button/index.vue")},
components: { default: () => import("../views/jinze/detail.vue") },
},
{
path:'/jinze/images/:id',
name:'jinze-images',
path: "/jinze/images/:id",
name: "jinze-images",
meta: {
title:'泰康之家·锦绣府'
title: "泰康之家·锦绣府",
},
components: {default:() => import("../views/jinze/images.vue"),backButton:() => import("../components/back-button/index.vue")},
props:{
backButton:{bottom:"15vh"}
}
components: { default: () => import("../views/jinze/images.vue") },
},
{
path:'/jinze/patient-situation',
name:'jinze-patient-situation',
path: "/jinze/patient-situation",
name: "jinze-patient-situation",
meta: {
title:'情况描述'
title: "情况描述",
},
component: () => import("../views/jinze/patientSituation.vue")
component: () => import("../views/jinze/patientSituation.vue"),
},
{
path:'/home/address',
name:'current-address',
path: "/home/address",
name: "current-address",
meta: {
title:'选择定位'
title: "选择定位",
},
component: () => import("../views/home/currentLocation.vue")
component: () => import("../views/home/currentLocation.vue"),
},
{
path:'/housekeeping',
name:'housekeeping',
path: "/housekeeping",
name: "housekeeping",
meta: {
title:'预约家政'
title: "预约家政",
},
components: {default:() => import("../views/housekeeping/index.vue"),backButton:() => import("../components/back-button/index.vue")},
props:{
backButton:{bottom:"15vh"}
}
components: { default: () => import("../views/housekeeping/index.vue") },
},
{
path: "/housekeeping/detail/:id",
name: "housekeeping-detail",
meta: {
title:"家政详情"
title: "家政详情",
},
components: {default:() => import("../views/housekeeping/detail.vue"),backButton:() => import("../components/back-button/index.vue")},
components: { default: () => import("../views/housekeeping/detail.vue") },
},
{
path:'/decoration',
name:'decoration',
path: "/decoration",
name: "decoration",
meta: {
title:'装饰'
title: "装饰",
},
components: {default:() => import("../views/decoration/index.vue"),backButton:() => import("../components/back-button/index.vue")},
components: { default: () => import("../views/decoration/index.vue") },
},
{
path: "/unauthorized",

View File

@ -1,6 +1,6 @@
<template>
<div class="flex flex-col bg-[#28BEBB]">
<header class="flex items-start justify-start text-[#fff] h-[284rpx] pt-[20rpx] pr-[30rpx] bg-[url(/images/home/greet.png)] bg-bottom-right bg-no-repeat custom-bg-size ml-[24rpx]">
<header class="flex items-start justify-start text-[#fff] h-[304rpx] pt-[20rpx] pr-[30rpx] bg-[url(/images/home/greet.png)] bg-bottom-right bg-no-repeat custom-bg-size ml-[24rpx]">
<div class="flex items-center px-[28rpx] py-[12rpx] rounded-full bg-[#00000066]" @click="toMap">
<MapPin />
<div class="text-[32rpx] font-500 max-w-[200rpx] truncate">{{ address }}</div>

View File

@ -10,7 +10,7 @@
<template #page>
<div
class="w-[76rpx] h-[44rpx] bg-[#545255] absolute bottom-[16rpx] right-[16rpx] flex items-center justify-center rounded-full text-[#FDFDFD] text-[28rpx]">
{{ val }}/4
{{ val }}/{{ swapperList.length }}
</div>
</template>
</nut-swiper>

1
src/window-env.d.ts vendored
View File

@ -1,3 +1,4 @@
interface Window {
wx:any
T:any
}

View File

@ -14,7 +14,7 @@ const pathSrc = resolve(__dirname, "src");
// https://vite.dev/config/
export default defineConfig({
assetsInclude: ["**/*.svg"],
base: "./" /* 这个就是webpack里面的publicPath */,
base: "/" /* 这个就是webpack里面的publicPath */,
build: {
rollupOptions: {
output: {