Pārlūkot izejas kodu

退出登录功能,解决订单管理列表订单号与详情中的订单号不一致

hzj18279462576@163.com 3 gadi atpakaļ
vecāks
revīzija
5c2fdef224

+ 7 - 6
admin/config/index.js

@@ -6,16 +6,17 @@ const path = require('path')
 
 module.exports = {
   dev: {
-
+    // http://192.168.161.230:8089线下地址
+    // https://chtech.ncjti.edu.cn/hotel/ihotel-api线上地址
     // Paths
     assetsSubDirectory: 'static',
-    assetsPublicPath: '/',
+    assetsPublicPath: '/hotel/manage',
     proxyTable: {
-      '/api': {
-        target: 'http://192.168.161.230:8089',
+      '/hotel/ihotel-api': {
+        target: 'https://chtech.ncjti.edu.cn/hotel/ihotel-api',
         changeOrigin: true,
         pathRewrite: {
-          '^/api': ''
+          '^/hotel/ihotel-api': ''
         }
       }
     },
@@ -58,7 +59,7 @@ module.exports = {
     // Paths
     assetsRoot: path.resolve(__dirname, '../dist'),
     assetsSubDirectory: 'static',
-    assetsPublicPath: '/',
+    assetsPublicPath: '/hotel/manage/',
 
     /**
      * Source Maps

+ 1 - 1
admin/src/api/doorLock.js

@@ -1,5 +1,5 @@
 import http from '../utils/http'
-let resquest = "/api/ihotel/roomDoorLock"
+let resquest = "/hotel/ihotel-api/ihotel/roomDoorLock"
 
 // 根据房间id查询密码锁
 export function roomDoorLockRoomId(roomId) {

+ 1 - 1
admin/src/api/fileServes.js

@@ -1,5 +1,5 @@
 import http from '../utils/http'
-let resquest = "/api/ihotel"
+let resquest = "/hotel/ihotel-api/ihotel"
 
 // 获取上传文件签名
 export function getListAPI(params) {

+ 1 - 1
admin/src/api/hotelAdmin.js

@@ -1,5 +1,5 @@
 import http from '../utils/http'
-let resquest = "/api/ihotel/hotelAdmin"
+let resquest = "/hotel/ihotel-api/ihotel/hotelAdmin"
 
 // 管理员登录
 export function hotelStaffLogin(params) {

+ 1 - 1
admin/src/api/hotelOrder.js

@@ -1,5 +1,5 @@
 import http from '../utils/http'
-let resquest = "/api/ihotel/hotelOrder"
+let resquest = "/hotel/ihotel-api/ihotel/hotelOrder"
 let contentType = { 'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8' }
 //  获取请求令牌
 export function hotelOrderToken(params) {

+ 1 - 1
admin/src/api/hotelStaff.js

@@ -1,5 +1,5 @@
 import http from '../utils/http'
-let resquest = "/api/ihotel/ihotel/hotelStaff"
+let resquest = "/hotel/ihotel-api/ihotel/ihotel/hotelStaff"
 
 // 员工列表
 export function hotelStaffList(params) {

+ 1 - 1
admin/src/api/houseType.js

@@ -1,5 +1,5 @@
 import http from '../utils/http'
-let resquest = "/api/ihotel/roomType"
+let resquest = "/hotel/ihotel-api/ihotel/roomType"
 
 // 房型列表(客户端)
 export function roomTypeList(params) {

+ 1 - 1
admin/src/api/normalUser.js

@@ -1,5 +1,5 @@
 import http from '../utils/http'
-let resquest = "/api/ihotel/hotelUser"
+let resquest = "/hotel/ihotel-api/ihotel/hotelUser"
 
 // 微校授权回调地址
 export function hotelUserWX(params) {

+ 1 - 1
admin/src/api/room.js

@@ -1,5 +1,5 @@
 import http from '../utils/http'
-let resquest = "/api/ihotel/room"
+let resquest = "/hotel/ihotel-api/ihotel/room"
 
 // 房间列表(分页)
 export function roomPage(params) {

+ 1 - 1
admin/src/api/roomRealTimeStatu.js

@@ -1,5 +1,5 @@
 import http from '../utils/http'
-let resquest = "/api/ihotel/roomRealTimeStatu"
+let resquest = "/hotel/ihotel-api/ihotel/roomRealTimeStatu"
 
 //  房态信息
 export function realData(params) {

+ 1 - 1
admin/src/api/roomThirdSetting.js

@@ -1,5 +1,5 @@
 import http from '../utils/http'
-let resquest = "/api/ihotel/roomThirdSetting"
+let resquest = "/hotel/ihotel-api/ihotel/roomThirdSetting"
 
 //  根据房间id查询
 export function settingId(params) {

+ 1 - 1
admin/src/api/systemSetup.js

@@ -1,5 +1,5 @@
 import http from '../utils/http'
-let resquest = "/api/ihotel/systemSetting"
+let resquest = "/hotel/ihotel-api/ihotel/systemSetting"
 
 // 获取系统设置
 export function systemSettingInfo(params) {

+ 1 - 1
admin/src/api/systemnotice.js

@@ -1,5 +1,5 @@
 import http from '../utils/http'
-let resquest = "/api/ihotel/systemNotice"
+let resquest = "/hotel/ihotel-api/ihotel/systemNotice"
 
 // 通知列表
 export function systemnoticeList(params) {

+ 16 - 2
admin/src/layout/components/Navbar.vue

@@ -17,7 +17,7 @@
         </el-avatar>
       </div>
       <div class="name">名字</div>
-      <div class="out">
+      <div class="out" @click="outLogin">
         <IconSvg :W="16" :H="16" name="quit" />
         <div class="title">退出</div>
       </div>
@@ -26,7 +26,7 @@
 </template>
 
 <script>
-import { mapState } from "vuex";
+import { removeToken } from "@/utils/auth";
 import moment from "moment";
 import "moment/locale/zh-cn";
 export default {
@@ -46,6 +46,19 @@ export default {
           console.log();
         });
     },
+    outLogin() {
+      this.$confirm("确认退出登录?")
+        .then((_) => {
+          this.$store.dispatch("user/logout").then(() => {
+            this.$message({
+              message: "退出成功",
+              type: "success",
+            });
+            this.$router.replace({ path: "/login" });
+          });
+        })
+        .catch((_) => {});
+    },
   },
 };
 </script>
@@ -107,6 +120,7 @@ export default {
       display: flex;
       align-items: center;
       padding-right: 18px;
+      cursor: pointer;
 
       .title {
         margin-left: 6px;

+ 16 - 6
admin/src/layout/index.vue

@@ -19,19 +19,29 @@
 <script>
 import NavbarItem from "@/layout/components/NavbarItem";
 import Navbar from "@/layout/components/Navbar";
+import Cookies from "js-cookie";
 export default {
   name: "Layout",
   components: { NavbarItem, Navbar },
   data() {
     return {};
   },
-  created() {},
-  methods: {
-    pathN(data) {
-      this.pathName = data;
-      console.log("接受了");
-    },
+  mounted() {
+    this.API.systemnotice.systemnoticeList({ pageSize: 100 }).then((res) => {
+      let number = 0;
+      res.data.list.forEach((item) => {
+        if (item.readFlag == 0) {
+          number += 1;
+        }
+        item.createTime = item.createTime.replace("T", " ");
+      });
+      this.$store.dispatch("inform/setreadFlag", number);
+      if (number == 0) {
+        this.$store.dispatch("inform/setreadFlag", "");
+      }
+    });
   },
+  methods: {},
 };
 </script>
 

+ 25 - 1
admin/src/router/index.js

@@ -1,7 +1,7 @@
 import Vue from 'vue'
 import Router from 'vue-router'
 import Layout from '@/layout'
-
+import Cookies from 'js-cookie'
 Vue.use(Router)
 
 //不管是超级管理员还是普通用户都可以看到的页面 
@@ -29,36 +29,43 @@ export const asyncRoutes = [
             {
                 path: 'home',
                 name: 'Home',
+                meta: { isAuth: true, title: '主页' },
                 component: () => import('@/views/home')
             },
             {
                 path: 'order',
                 name: 'Order',
+                meta: { isAuth: true, title: '订单管理' },
                 component: () => import('@/views/order')
             },
             {
                 path: 'staff',
                 name: 'Staff',
+                meta: { isAuth: true, title: '员工管理' },
                 component: () => import('@/views/staff')
             },
             {
                 path: 'account',
                 name: 'Account',
+                meta: { isAuth: true, title: '账号管理' },
                 component: () => import('@/views/account')
             },
             {
                 path: 'stat',
                 name: 'Stat',
+                meta: { isAuth: true, title: '统计报表' },
                 component: () => import('@/views/stat')
             },
             {
                 path: 'system',
                 name: 'System',
+                meta: { isAuth: true, title: '系统设置' },
                 component: () => import('@/views/system')
             },
             {
                 path: 'inform',
                 name: 'Inform',
+                meta: { isAuth: true, title: '系统通知' },
                 component: () => import('@/views/inform')
             }
         ]
@@ -81,3 +88,20 @@ export function resetRouter() {
 }
 
 export default router
+
+//全局前置路由守卫————初始化的时候被调用、每次路由切换之前被调用
+router.beforeEach((to, from, next) => {
+    //如果路由需要跳转
+    if (to.meta.isAuth) {
+        //判断 如果cook是否存在,可以进去
+        if (Cookies.get('cook')) {
+            next()  //放行
+        } else {
+            // alert('登录身份失效,请重新登录')
+            next({ path: "/login" });
+        }
+    } else {
+        // 否则,放行
+        next()
+    }
+})

+ 0 - 9
admin/src/store/modules/inform.js

@@ -1,8 +1,3 @@
-import Cookies from 'js-cookie'
-import { login, logout, getInfo } from '@/api/acl/user'
-import { getToken, setToken, removeToken } from '@/utils/auth'
-import { resetRouter } from '@/router'
-import api from '@/api/api'
 
 const state = {
     readFlag: ""
@@ -14,10 +9,6 @@ const mutations = {
     SET_readFlag: (state, number) => {
         state.readFlag = number
     },
-
-    SET_ROLES: (state, roles) => {
-        state.roles = roles
-    }
 }
 
 const actions = {

+ 5 - 13
admin/src/store/modules/user.js

@@ -83,24 +83,16 @@ const actions = {
 
     // user logout
     logout({ commit, state }) {
-        return new Promise((resolve, reject) => {
-            logout(state.token)
-                .then(() => {
-                    removeToken() // must remove  token  first
-                    resetRouter()
-                    commit('RESET_STATE')
-                    resolve()
-                })
-                .catch((error) => {
-                    reject(error)
-                })
-        })
+        removeToken() // must remove  token  first
+        // resetRouter()
+        commit('RESET_STATE')
+
     },
 
     // remove token
     resetToken({ commit }) {
         return new Promise((resolve) => {
-            removeToken() // must remove  token  first
+            // removeToken() // must remove  token  first
             commit('RESET_STATE')
             resolve()
         })

+ 3 - 0
admin/src/utils/request.js

@@ -27,11 +27,14 @@ service.interceptors.request.use(config => {
         config.headers['admin-token'] = token; //如果要求携带在请求头中
     }
 
+
     return config
 }, error => {
     Promise.reject(error)
 })
 
+
+
 // 3.响应拦截器
 service.interceptors.response.use(response => {
     //接收到响应数据并成功后的一些共有的处理,关闭loading等

+ 2 - 2
admin/src/views/home/index.vue

@@ -747,7 +747,7 @@ export default {
                 if (res.success) {
                   this.$message({
                     message: "关房成功",
-                    type: "success",
+                    // type: "success",
                   });
                   this.roomList(this.Data);
                   this.room = false;
@@ -968,7 +968,7 @@ export default {
         lockId: this.doorLockList.doorId,
       };
       console.log(arr);
-      this.API.roomThirdSetting.Update(arr).then((res) => {
+      this.API.roomThirdSetting.Updata(arr).then((res) => {
         if (res.success) {
           this.$message({
             message: "修改成功",

+ 21 - 19
admin/src/views/inform/index.vue

@@ -135,7 +135,7 @@ export default {
       className: ["active", "", ""],
       inquireValue: "",
       data: [], // 当前页面显示的数据
-      Data: [], // 分页器显示的总数据
+      Data: [], // 显示的总数据
       tableData: [], // 请求的总数据
       currentPage: 1,
       infoShow: false,
@@ -153,27 +153,29 @@ export default {
     this.dataList();
   },
   methods: {
-    dataList() {
-      this.API.systemnotice.systemnoticeList().then((res) => {
-        console.log(res);
-        this.tableData = res.data.list;
-        let number = 0;
-        this.tableData.forEach((item) => {
-          if (item.readFlag == 0) {
-            number += 1;
-            this.$store.dispatch("inform/setreadFlag", number);
-          } else {
+    dataList(currentPage) {
+      this.API.systemnotice
+        .systemnoticeList({ pageSize: 100, order: "desc" })
+        .then((res) => {
+          console.log(res);
+          this.tableData = res.data.list;
+          let number = 0;
+          this.tableData.forEach((item) => {
+            if (item.readFlag == 0) {
+              number += 1;
+            }
+            item.createTime = item.createTime.replace("T", " ");
+          });
+          this.$store.dispatch("inform/setreadFlag", number);
+          if (number == 0) {
             this.$store.dispatch("inform/setreadFlag", "");
           }
-          item.createTime = item.createTime.replace("T", " ");
+          this.Data = this.tableData;
+          this.handleCurrentChange(currentPage ? currentPage : 1);
         });
-        this.Data = this.tableData;
-        this.handleCurrentChange(1);
-      });
     },
     // 查询
     inquire() {
-      console.log(111);
       this.Data = this.tableData.filter((item, index) => {
         return item.createTime.includes(this.inquireValue);
       });
@@ -183,7 +185,6 @@ export default {
     read($event, index) {
       this.className = this.className.map((item) => (item = ""));
       this.className[index] = "active";
-
       if ($event.target.innerText == "全部") {
         this.Data = this.tableData;
       } else if ($event.target.innerText == "已读") {
@@ -208,7 +209,7 @@ export default {
       if (row.readFlag == 0) {
         this.API.systemnotice.systemnoticeRead([row.id]).then((res) => {
           console.log(res);
-          this.dataList();
+          this.dataList(this.currentPage);
         });
       }
       this.infoShow = true;
@@ -222,7 +223,7 @@ export default {
         }
       });
       console.log(ids);
-      if (ids) {
+      if (ids.length) {
         this.API.systemnotice.systemnoticeRead(ids).then((res) => {
           console.log(res);
           this.dataList();
@@ -236,6 +237,7 @@ export default {
     },
 
     handleCurrentChange(val) {
+      console.log(this.Data);
       this.currentPage = this.val;
       this.data = this.Data.slice((val - 1) * 8, val * 8);
       // console.log(`当前页: ${val}`);

+ 5 - 0
admin/src/views/login/index.vue

@@ -131,10 +131,15 @@ export default {
               password: rsaPassWord,
             })
             .then(() => {
+              this.$message({
+                message: "登录成功",
+                type: "success",
+              });
               this.$router.push({ path: this.redirect || "/home" });
               this.loading = false;
             })
             .catch(() => {
+              this.$message.error("登录失败,用户名或密码错误");
               this.loading = false;
             });
         }

+ 12 - 10
admin/src/views/order/index.vue

@@ -173,17 +173,17 @@
                   <div class="info">
                     <div class="user">
                       <div class="name">姓名</div>
-                      <el-input :value="row.order.userName"></el-input>
+                      <el-input :value="order.userName"></el-input>
                     </div>
                     <div class="user">
                       <div class="name">联系方式</div>
-                      <el-input :value="row.order.userPhone"></el-input>
+                      <el-input :value="order.userPhone"></el-input>
                     </div>
                   </div>
                   <div class="info">
                     <div class="user">
                       <div class="name">订单号</div>
-                      <el-input :value="row.order.orderNo"></el-input>
+                      <el-input :value="order.orderNo"></el-input>
                     </div>
                     <div class="user">
                       <div class="name">预付款金额(元)</div>
@@ -193,11 +193,11 @@
                   <div class="info">
                     <div class="user">
                       <div class="name">入住时间</div>
-                      <el-input :value="row.order.realStartTime"></el-input>
+                      <el-input :value="order.realStartTime"></el-input>
                     </div>
                     <div class="user">
                       <div class="name">离住时间</div>
-                      <el-input :value="row.order.realEndTime"></el-input>
+                      <el-input :value="order.realEndTime"></el-input>
                     </div>
                   </div>
                   <div class="info">
@@ -207,14 +207,14 @@
                     </div>
                     <div class="user">
                       <div class="name">支付时间</div>
-                      <el-input :value="row.order.payTime"></el-input>
+                      <el-input :value="order.payTime"></el-input>
                     </div>
                   </div>
 
                   <!-- 水费区域 -->
                   <div class="rate">水费明细</div>
                   <div class="water">
-                    表计:101 楼层:{{ row.order.roomNo }} 抄表时间:2022-07-27
+                    表计:101 楼层:{{ order.roomNo }} 抄表时间:2022-07-27
                     15:15:15
                   </div>
                   <el-table
@@ -273,7 +273,7 @@
                   <!-- 电费区域 -->
                   <div class="rate">电费明细</div>
                   <div class="water">
-                    表计:101 楼层:{{ row.order.roomNo }} 抄表时间:2022-07-27
+                    表计:101 楼层:{{ order.roomNo }} 抄表时间:2022-07-27
                     15:15:15
                   </div>
                   <el-table
@@ -410,6 +410,7 @@ export default {
       dialogVisible: false,
       waterTable: [],
       electricTable: [],
+      order: [], // 用户信息
       // 当前页
       curPage: 1,
       // 每页条数
@@ -488,7 +489,8 @@ export default {
 
     //详情按钮回调
     handleEdit(row) {
-      // console.log(row.orderBill);
+      console.log(row);
+      this.order = row.order;
       this.waterTable = [];
       this.electricTable = [];
       if (row.orderBill) {
@@ -528,7 +530,7 @@ export default {
       // console.log(row.order.id);
       this.$confirm("确认删除?")
         .then(async () => {
-          let res = await this.API.hotelOrder.hotelOrderUserDeleteByManage(
+          let res = await this.API.hotelOrder.hotelOrderAdminDelete(
             row.order.id
           );
           // console.log(res);