From 81d6ef44ef6cee0078ef1d81937a79008649928e Mon Sep 17 00:00:00 2001 From: YeMingfei666 <1619116647@qq.com> Date: Wed, 12 Feb 2025 13:52:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BA=97=E9=93=BA=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E9=A1=B5=E9=9D=A2=EF=BC=8C=E5=A2=9E=E5=8A=A0vue-amap?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/api/account/login.ts | 349 +++++++++++- src/api/account/menu.ts | 43 ++ src/api/account/shop.ts | 60 ++ src/data/shop.ts | 19 + src/enums/ResultEnum.ts | 2 +- src/main.ts | 8 +- src/router/index.ts | 10 + src/store/modules/permission.ts | 2 +- src/store/modules/user.ts | 44 +- src/utils/request.ts | 2 +- src/views/login/index.vue | 12 +- src/views/register/index.vue | 0 src/views/shop/list/components/addShop.vue | 523 ++++++++++++++++++ .../shop/list/components/detailModal.vue | 141 +++++ src/views/shop/list/index.vue | 232 ++++++++ tsconfig.json | 2 +- vite.config.ts | 11 +- 18 files changed, 1399 insertions(+), 62 deletions(-) create mode 100644 src/api/account/menu.ts create mode 100644 src/api/account/shop.ts create mode 100644 src/data/shop.ts create mode 100644 src/views/register/index.vue create mode 100644 src/views/shop/list/components/addShop.vue create mode 100644 src/views/shop/list/components/detailModal.vue create mode 100644 src/views/shop/list/index.vue diff --git a/package.json b/package.json index f1eeb30..e66fef6 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "@typescript-eslint/eslint-plugin": "^8.23.0", "@typescript-eslint/parser": "^8.23.0", "@vitejs/plugin-vue": "^5.2.1", + "@vuemap/unplugin-resolver": "^1.0.4", "autoprefixer": "^10.4.20", "commitizen": "^4.3.1", "cz-git": "^1.11.0", diff --git a/src/api/account/login.ts b/src/api/account/login.ts index 0275fbf..86bef30 100644 --- a/src/api/account/login.ts +++ b/src/api/account/login.ts @@ -3,8 +3,8 @@ const baseURL = "account/admin/"; const AuthAPI = { /** 登录接口*/ - login(data: LoginFormData) { - return request({ + login(data: loginRequest) { + return request({ url: `${baseURL}auth/login`, method: "post", data: data, @@ -13,14 +13,14 @@ const AuthAPI = { /** 获取验证码接口*/ getCaptcha() { - return request({ + return request({ url: `${baseURL}auth/captcha`, method: "get", }); }, /**getPermission */ getPermission() { - return request({ + return request({ url: `${baseURL}auth/permission`, method: "get", }); @@ -28,34 +28,327 @@ const AuthAPI = { }; export default AuthAPI; +/** + * 验证码信息 + * + * CzgResult«?» + */ +export interface codeResponse { + code?: number | null; + data?: null; + msg?: null | string; + [property: string]: any; +} -/** 登录表单数据 */ -export interface LoginFormData { - /** 用户名 */ - username: string; - /** 密码 */ - password: string; - /** 验证码缓存uuid */ - uuid: string; - /** 验证码 */ - code: string; - /** 登录类型 - * 0:商户登录 - * 1:员工登录 +/** + * 登录参数 + * + * SysLoginDTO + */ +export interface loginRequest { + /** + * 验证码 */ - loginType: number; + code: null | string; + /** + * 登录类型 0:商户登录 1:员工登录 + */ + loginType: number | null; + /** + * 密码 + */ + password: null | string; + /** + * 用户名 + */ + username: null | string; + /** + * 验证码uid + */ + uuid: null | string; + [property: string]: any; } -/** 登录响应 */ -export interface LoginResult { - /** 访问令牌 */ - token: string; +/** + * token信息 + * + * CzgResult«LoginVO» + */ +export interface loginResponse { + code?: number | null; + data?: LoginVO; + msg?: null | string; + [property: string]: any; } -/** 验证码信息 */ -export interface CaptchaInfo { - /** 验证码缓存uuid */ - uuid: string; - /** 验证码图片Base64字符串 */ - code: string; +/** + * LoginVO + */ +export interface LoginVO { + /** + * 登录类型,0商户 1员工 + */ + loginType?: number | null; + /** + * 接口权限集 + */ + promissionList?: string[] | null; + /** + * 店铺信息 + */ + shopInfo?: TbShopInfo; + /** + * token信息 + */ + tokenInfo?: SaTokenInfo; + [property: string]: any; +} + +/** + * 店铺信息 + * + * TbShopInfo + */ +export interface TbShopInfo { + /** + * 详细地址 + */ + address?: null | string; + /** + * 项目分类 + */ + article?: null | string; + /** + * 背景图 + */ + backImg?: null | string; + /** + * 开票系统账号 + */ + bindAccount?: null | string; + /** + * 台桌预订短信 + */ + bookingSms?: null | string; + /** + * 营业时间(周结束) + */ + businessEndDay?: null | string; + /** + * 营业时间(周开始) + */ + businessStartDay?: null | string; + /** + * 营业时间 + */ + businessTime?: null | string; + /** + * 连锁店扩展店名 + */ + chainName?: null | string; + /** + * 市 + */ + cities?: null | string; + /** + * 积分群体 all-所有 vip-仅针对会员 + */ + consumeColony?: null | string; + /** + * 联系人姓名 + */ + contactName?: null | string; + /** + * 封面图 + */ + coverImg?: null | string; + createTime?: null | string; + /** + * 店铺简介 + */ + detail?: null | string; + /** + * 区/县 + */ + districts?: null | string; + /** + * 就餐模式 堂食 dine-in 外带 take-out + */ + eatModel?: null | string; + /** + * 到期时间 + */ + expireTime?: null | string; + /** + * 门头照 + */ + frontImg?: null | string; + /** + * 使用系统用户 sys_user id + */ + id?: number | null; + /** + * 是否允许会员自定义金额 1 允许 0 不允许 + */ + isCustomAmount?: number | null; + /** + * 是否开启会员充值密码 1 启用 0 禁用 + */ + isMemberInPwd?: number | null; + /** + * 是否启用会员价 0否1是 + */ + isMemberPrice?: number | null; + /** + * 是否开启会员退款密码 1 启用 0 禁用 + */ + isMemberReturnPwd?: number | null; + /** + * 是否开启退款密码 1 启用 0 禁用 + */ + isReturnPwd?: number | null; + /** + * 是否免除桌位费 0否1是 + */ + isTableFee?: number | null; + /** + * 经纬度 + */ + lat?: null | string; + /** + * 经纬度 + */ + lng?: null | string; + /** + * 店铺logo + */ + logo?: null | string; + /** + * 主店id + */ + mainId?: number | null; + /** + * 0停业 1,正常营业 2,网上售卖 + */ + onSale?: number | null; + /** + * 操作密码 + */ + operationPwd?: null | string; + /** + * 店铺收款码 + */ + paymentQrcode?: null | string; + /** + * 联系电话 + */ + phone?: null | string; + /** + * trial试用版,release正式 + */ + profiles?: null | string; + /** + * 省 + */ + provinces?: null | string; + registerType?: null | string; + /** + * 数电发票类型 + */ + sdType?: null | string; + /** + * 店铺名称 + */ + shopName?: null | string; + /** + * 商家二维码 + */ + shopQrcode?: null | string; + /** + * 店铺类型 单店--only 连锁店--chain--加盟店join (对应原来 type) + */ + shopType?: null | string; + /** + * 小程序码(零点八零首页) + */ + smallQrcode?: null | string; + /** + * -1 平台禁用 0-过期,1正式营业, + */ + status?: number | null; + /** + * 店铺口号 + */ + subTitle?: null | string; + /** + * 桌位费 + */ + tableFee?: number | null; + /** + * 商家标签 + */ + tag?: null | string; + /** + * 税率 + */ + taxAmount?: null | string; + /** + * 管理 0否 1是, 1 为直接管理 可切换店铺 0 不可以切换 + */ + tubeType?: number | null; + updateTime?: null | string; + [property: string]: any; +} + +/** + * token信息 + * + * SaTokenInfo + */ +export interface SaTokenInfo { + /** + * 此 token 是否已经登录 + */ + isLogin?: boolean | null; + /** + * 登录设备类型 + */ + loginDevice?: null | string; + /** + * 此 token 对应的 LoginId,未登录时为 null + */ + loginId?: { [key: string]: any }; + /** + * 多账号体系下的账号类型 + */ + loginType?: null | string; + /** + * Account-Session 剩余有效时间(单位: 秒) + */ + sessionTimeout?: number | null; + /** + * 自定义数据(暂无意义,留作扩展) + */ + tag?: null | string; + /** + * token 距离被冻结还剩多少时间(单位: 秒) + */ + tokenActiveTimeout?: number | null; + /** + * token 名称 + */ + tokenName?: null | string; + /** + * Token-Session 剩余有效时间(单位: 秒) + */ + tokenSessionTimeout?: number | null; + /** + * token 剩余有效期(单位: 秒) + */ + tokenTimeout?: number | null; + /** + * token 值 + */ + tokenValue?: null | string; + [property: string]: any; } diff --git a/src/api/account/menu.ts b/src/api/account/menu.ts new file mode 100644 index 0000000..e1fdd00 --- /dev/null +++ b/src/api/account/menu.ts @@ -0,0 +1,43 @@ +import request from "@/utils/request"; +const baseURL = "account/admin/"; + +const MenuApi = { + /** 获取当前用户菜单列表*/ + getRoutes() { + return request({ + url: `${baseURL}menus`, + method: "get", + }); + }, +}; + +export default MenuApi; + +/** RouteVO,路由对象 */ +export interface RouteVO { + /** 子路由列表 */ + children: RouteVO[]; + /** 组件路径 */ + component?: string; + /** 路由属性 */ + meta?: Meta; + /** 路由名称 */ + name?: string; + /** 路由路径 */ + path?: string; + /** 跳转链接 */ + redirect?: string; +} +/** Meta,路由属性 */ +export interface Meta { + /** 【目录】只有一个子路由是否始终显示 */ + alwaysShow?: boolean; + /** 是否隐藏(true-是 false-否) */ + hidden?: boolean; + /** ICON */ + icon?: string; + /** 【菜单】是否开启页面缓存 */ + keepAlive?: boolean; + /** 路由title */ + title?: string; +} diff --git a/src/api/account/shop.ts b/src/api/account/shop.ts new file mode 100644 index 0000000..225dca8 --- /dev/null +++ b/src/api/account/shop.ts @@ -0,0 +1,60 @@ +import request from "@/utils/request"; +const baseURL = "account/admin/shopInfo"; + +const ShopApi = { + /** 获取店铺列表*/ + getList(params: PageQuery) { + return request({ + url: `${baseURL}`, + method: "get", + params: params, + }); + }, + add(data: ShopInfoEditDTO) { + return request({ + url: `${baseURL}`, + method: "post", + data, + }); + }, + edit(data: ShopInfoEditDTO) { + return request({ + url: `${baseURL}`, + method: "put", + data, + }); + }, +}; + +export default ShopApi; + +/** + * ShopInfoEditDTO + */ +export interface ShopInfoEditDTO { + accountName?: null | string; + accountPwd?: null | string; + activateCode?: null | string; + address?: null | string; + chainName?: null | string; + detail?: null | string; + frontImg?: null | string; + id: number | null; + lat?: null | string; + lng?: null | string; + logo?: null | string; + phone?: null | string; + profiles?: null | string; + roleId?: number | null; + shopName?: null | string; + shopType?: null | string; + [property: string]: any; +} + +export interface PageQuery { + page: number; + shopName?: string; + size: number; + status?: number; + [property: string]: any; +} diff --git a/src/data/shop.ts b/src/data/shop.ts new file mode 100644 index 0000000..e9930fe --- /dev/null +++ b/src/data/shop.ts @@ -0,0 +1,19 @@ +/** 店铺类型*/ +export const $ShopType: ShopType[] = [ + { + label: "单店", + value: "only", + }, + { + label: "连锁店", + value: "chain", + }, + { + label: "加盟店", + value: "join", + }, +]; +export interface ShopType { + label: string; + value: string; +} diff --git a/src/enums/ResultEnum.ts b/src/enums/ResultEnum.ts index 349a628..924ef2d 100644 --- a/src/enums/ResultEnum.ts +++ b/src/enums/ResultEnum.ts @@ -5,7 +5,7 @@ export const enum ResultEnum { /** * 成功 */ - SUCCESS = "00000", + SUCCESS = "200", /** * 错误 */ diff --git a/src/main.ts b/src/main.ts index 60d7936..1c9ed47 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,6 @@ import { createApp } from "vue"; import App from "./App.vue"; import setupPlugins from "@/plugins"; - // 本地SVG图标 import "virtual:svg-icons-register"; // 暗黑主题样式 @@ -13,6 +12,13 @@ import "uno.css"; // 自动为某些默认事件(如 touchstart、wheel 等)添加 { passive: true },提升滚动性能并消除控制台的非被动事件监听警告 import "default-passive-events"; +// vue-amp初始化 +import { initAMapApiLoader } from "@vuemap/vue-amap"; +import "@vuemap/vue-amap/dist/style.css"; +initAMapApiLoader({ + key: "6033c97e67bf2e9ceac306e1a3fa35f8", +}); + const app = createApp(App); // 注册插件 app.use(setupPlugins); diff --git a/src/router/index.ts b/src/router/index.ts index c4b8d42..8ca5344 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -114,6 +114,16 @@ export const constantRoutes: RouteRecordRaw[] = [ keepAlive: true, }, }, + { + path: "list", + component: () => import("@/views/shop/list/index.vue"), + name: "shopList", + meta: { + title: "店铺列表", + affix: false, + keepAlive: true, + }, + }, { path: "role", component: () => import("@/views/shop/role.vue"), diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index 0c89a9d..56f133d 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -3,7 +3,7 @@ import { constantRoutes } from "@/router"; import { store } from "@/store"; import router from "@/router"; -import MenuAPI, { type RouteVO } from "@/api/system/menu"; +import MenuAPI, { type RouteVO } from "@/api/account/menu"; const modules = import.meta.glob("../../views/**/**.vue"); const Layout = () => import("@/layout/index.vue"); diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 669cd36..95859d6 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -21,8 +21,8 @@ export const useUserStore = defineStore("user", () => { return new Promise((resolve, reject) => { AuthAPI.login(LoginFormData) .then((data) => { - Object.assign(userInfo.value, { ...data }); - const { token } = data; + Object.assign(userInfo.value, { ...data.shopInfo }); + const token = data.tokenInfo.tokenValue; setToken(token); // Bearer eyJhbGciOiJIUzI1NiJ9.xxx.xxx setRefreshToken(token); resolve(); @@ -61,14 +61,16 @@ export const useUserStore = defineStore("user", () => { */ function logout() { return new Promise((resolve, reject) => { - AuthAPI.logout() - .then(() => { - clearUserData(); - resolve(); - }) - .catch((error) => { - reject(error); - }); + clearUserData(); + resolve(); + // AuthAPI.logout() + // .then(() => { + // clearUserData(); + // resolve(); + // }) + // .catch((error) => { + // reject(error); + // }); }); } @@ -78,17 +80,17 @@ export const useUserStore = defineStore("user", () => { function refreshToken() { const refreshToken = getRefreshToken(); return new Promise((resolve, reject) => { - AuthAPI.refreshToken(refreshToken) - .then((data) => { - const { token } = data; - setToken(token); - setRefreshToken(refreshToken); - resolve(); - }) - .catch((error) => { - console.log(" refreshToken 刷新失败", error); - reject(error); - }); + // AuthAPI.refreshToken(refreshToken) + // .then((data) => { + // const { token } = data; + // setToken(token); + // setRefreshToken(refreshToken); + // resolve(); + // }) + // .catch((error) => { + // console.log(" refreshToken 刷新失败", error); + // reject(error); + // }); }); } diff --git a/src/utils/request.ts b/src/utils/request.ts index 84025ec..d70ed01 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -37,7 +37,7 @@ service.interceptors.response.use( } const { code, data, msg } = response.data; - if (code === ResultEnum.SUCCESS || code === undefined || code === null || code === 200) { + if (code === ResultEnum.SUCCESS || code === undefined || code === null) { return data ? data : response.data; } diff --git a/src/views/login/index.vue b/src/views/login/index.vue index 392a567..cd8f160 100644 --- a/src/views/login/index.vue +++ b/src/views/login/index.vue @@ -11,8 +11,8 @@

银收客后台管理

- 商户 - 员工 + 商户 + 员工 @@ -94,11 +94,11 @@ const state = reactive({ loginForm: { username: "", password: "", - rememberMe: false, + // rememberMe: false, code: "", uuid: "", merchantName: "", - loginType: "merchant", + loginType: 0, }, loginRules: { username: [{ required: true, trigger: "blur", message: "用户名不能为空" }], @@ -176,12 +176,12 @@ function handleLogin() { if (valid) { state.loading = true; const user = { ...state.loginForm }; - user.password = encrypt(user.password); + // user.password = encrypt(user.password); console.log(user); userStore .login(user) .then(async (res) => { - await userStore.getUserInfo(); + // await userStore.getUserInfo(); const { path, queryParams } = parseRedirect(); router.push({ path: path, query: queryParams }); }) diff --git a/src/views/register/index.vue b/src/views/register/index.vue new file mode 100644 index 0000000..e69de29 diff --git a/src/views/shop/list/components/addShop.vue b/src/views/shop/list/components/addShop.vue new file mode 100644 index 0000000..4dac1cf --- /dev/null +++ b/src/views/shop/list/components/addShop.vue @@ -0,0 +1,523 @@ + + + + + \ No newline at end of file diff --git a/src/views/shop/list/components/detailModal.vue b/src/views/shop/list/components/detailModal.vue new file mode 100644 index 0000000..7f83760 --- /dev/null +++ b/src/views/shop/list/components/detailModal.vue @@ -0,0 +1,141 @@ + + + + + \ No newline at end of file diff --git a/src/views/shop/list/index.vue b/src/views/shop/list/index.vue new file mode 100644 index 0000000..f282cc5 --- /dev/null +++ b/src/views/shop/list/index.vue @@ -0,0 +1,232 @@ + + + + + \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 7afb4fc..f622eb8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,7 +25,7 @@ "allowJs": true, // 类型声明相关配置 - "types": ["node", "vite/client", "element-plus/global"] + "types": ["node", "vite/client", "element-plus/global", "vuemap"] }, "include": ["mock/**/*.ts", "src/**/*.ts", "src/**/*.vue", "vite.config.ts"], diff --git a/vite.config.ts b/vite.config.ts index c13ceba..8cdda06 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -3,6 +3,7 @@ import { type UserConfig, type ConfigEnv, loadEnv, defineConfig } from "vite"; import AutoImport from "unplugin-auto-import/vite"; import Components from "unplugin-vue-components/vite"; +import { VueAmapResolver } from "@vuemap/unplugin-resolver"; import { ElementPlusResolver } from "unplugin-vue-components/resolvers"; import { createSvgIconsPlugin } from "vite-plugin-svg-icons"; @@ -65,7 +66,10 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => { imports: ["vue", "@vueuse/core", "pinia", "vue-router", "vue-i18n"], resolvers: [ // 导入 Element Plus函数,如:ElMessage, ElMessageBox 等 - ElementPlusResolver(), + ElementPlusResolver({ + exclude: /^ElAmap[A-Z]*/, + }), + VueAmapResolver(), ], eslintrc: { enabled: false, @@ -80,7 +84,10 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => { Components({ resolvers: [ // 导入 Element Plus 组件 - ElementPlusResolver(), + ElementPlusResolver({ + exclude: /^ElAmap[A-Z]*/, + }), + VueAmapResolver(), ], // 指定自定义组件位置(默认:src/components) dirs: ["src/components", "src/**/components"],