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 /> <X />
</div> </div>
<div class="m-[34rpx] flex items-center"> <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]" /> <img src="/images/product/share-friend.png" alt="share-friend" class="w-[320rpx] h-[284rpx]" />
</div> </div>
</div> </div>
@ -15,6 +15,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { X } from "lucide-vue-next"; import { X } from "lucide-vue-next";
import { useRoute } from "vue-router";
const props = defineProps({ const props = defineProps({
show: { show: {
@ -23,6 +24,7 @@
}, },
}); });
const route = useRoute();
const emits = defineEmits(["update:show"]); const emits = defineEmits(["update:show"]);
const innerShow = computed({ const innerShow = computed({
@ -37,4 +39,19 @@
const handleClose = () => { const handleClose = () => {
emits("update:show", false); 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> </script>

View File

@ -8,13 +8,13 @@
</nut-tabbar> </nut-tabbar>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from "vue"; import { menus } from "@/composables/useTabbar";
import { ref } from "vue";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
const route = useRoute() const route = useRoute()
const activeIndex = ref(0); 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 routeQuery = Object.entries(route.query).map(([key, value]) => `${key}=${value}`).join("&");
const tabSwitch = (item: Record<string, unknown>, index: number) => { 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 { createRouter, createWebHistory } from "vue-router";
import { publicRoutes } from "./publicRoutes"; import { publicRoutes } from "./publicRoutes";
import { privateRoutes } from "./privateRoutes"; import { privateRoutes } from "./privateRoutes";
import type { RouteLocationNormalized, NavigationGuardNext } from 'vue-router';
import { menus } from "@/composables/useTabbar";
function getRoutes() { function getRoutes() {
const routes = [ // 私有路由,请在这里添加 const routes = [
// 私有路由,请在这里添加
...privateRoutes, ...privateRoutes,
// 公共路由 // 公共路由
@ -19,12 +23,10 @@ const router = createRouter({
routes: getRoutes(), routes: getRoutes(),
}); });
// 全局前置守卫,这边可以对身份进行验证 function checkUserRole(to: RouteLocationNormalized, userRole: string, next: NavigationGuardNext) {
router.beforeEach((to, _from, next) => {
let userRole = "admin";
// 如果目标路由没有角色限制
if (!to.meta.role) { if (!to.meta.role) {
next(); next();
return;
} }
// 判断当前用户角色是否在目标路由的允许角色列表中 // 判断当前用户角色是否在目标路由的允许角色列表中
if ((to.meta.role as string[]).includes(userRole)) { if ((to.meta.role as string[]).includes(userRole)) {
@ -34,6 +36,25 @@ router.beforeEach((to, _from, next) => {
// 如果角色不匹配,跳转到 unauthorized 页面 // 如果角色不匹配,跳转到 unauthorized 页面
next({ path: "/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

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

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="flex flex-col bg-[#28BEBB]"> <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"> <div class="flex items-center px-[28rpx] py-[12rpx] rounded-full bg-[#00000066]" @click="toMap">
<MapPin /> <MapPin />
<div class="text-[32rpx] font-500 max-w-[200rpx] truncate">{{ address }}</div> <div class="text-[32rpx] font-500 max-w-[200rpx] truncate">{{ address }}</div>

View File

@ -10,7 +10,7 @@
<template #page> <template #page>
<div <div
class="w-[76rpx] h-[44rpx] bg-[#545255] absolute bottom-[16rpx] right-[16rpx] flex items-center justify-center rounded-full text-[#FDFDFD] text-[28rpx]"> 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> </div>
</template> </template>
</nut-swiper> </nut-swiper>

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

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

View File

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