智慧农业大数据平台
shuishen
2022-07-29 7210f462c6e4cf0c26ae43c4949f34fbf6b07372
登录相关
7 files modified
4 files added
12 files deleted
3819 ■■■■■ changed files
package-lock.json 170 ●●●● patch | view | raw | blame | history
package.json 4 ●●● patch | view | raw | blame | history
src/main.js 2 ●●●●● patch | view | raw | blame | history
src/permission.js 24 ●●●●● patch | view | raw | blame | history
src/router/axios.js 46 ●●●● patch | view | raw | blame | history
src/router/page/index.js 23 ●●●● patch | view | raw | blame | history
src/store/getters.js 93 ●●●●● patch | view | raw | blame | history
src/store/index.js 14 ●●●● patch | view | raw | blame | history
src/store/modules/mobile.js 1245 ●●●●● patch | view | raw | blame | history
src/store/modules/mobilePosition copy.js 163 ●●●●● patch | view | raw | blame | history
src/store/modules/mobilePosition.js 323 ●●●●● patch | view | raw | blame | history
src/store/modules/mobilePositionLID.js 57 ●●●●● patch | view | raw | blame | history
src/store/modules/mobilePositionLID1.js 251 ●●●●● patch | view | raw | blame | history
src/store/modules/mobiles/urlParameter.js 109 ●●●●● patch | view | raw | blame | history
src/store/modules/navigation.js 23 ●●●●● patch | view | raw | blame | history
src/store/modules/pc/leftNavsData.js 132 ●●●●● patch | view | raw | blame | history
src/store/modules/popupParams copy.js 397 ●●●●● patch | view | raw | blame | history
src/store/modules/popupParams.js 459 ●●●●● patch | view | raw | blame | history
src/store/modules/search.js 48 ●●●●● patch | view | raw | blame | history
src/store/modules/user.js 18 ●●●●● patch | view | raw | blame | history
src/store/modules/viewer.js 48 ●●●●● patch | view | raw | blame | history
src/utils/auth.js 11 ●●●●● patch | view | raw | blame | history
src/views/login/index.vue 159 ●●●●● patch | view | raw | blame | history
package-lock.json
@@ -1945,63 +1945,6 @@
          "integrity": "sha1-/q7SVZc9LndVW4PbwIhRpsY1IPo=",
          "dev": true
        },
        "ansi-styles": {
          "version": "4.3.0",
          "resolved": "https://registry.npmmirror.com/ansi-styles/-/ansi-styles-4.3.0.tgz",
          "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
          "dev": true,
          "optional": true,
          "requires": {
            "color-convert": "^2.0.1"
          }
        },
        "chalk": {
          "version": "4.1.2",
          "resolved": "https://registry.npmmirror.com/chalk/-/chalk-4.1.2.tgz",
          "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
          "dev": true,
          "optional": true,
          "requires": {
            "ansi-styles": "^4.1.0",
            "supports-color": "^7.1.0"
          }
        },
        "color-convert": {
          "version": "2.0.1",
          "resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz",
          "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
          "dev": true,
          "optional": true,
          "requires": {
            "color-name": "~1.1.4"
          }
        },
        "color-name": {
          "version": "1.1.4",
          "resolved": "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz",
          "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
          "dev": true,
          "optional": true
        },
        "has-flag": {
          "version": "4.0.0",
          "resolved": "https://registry.npmmirror.com/has-flag/-/has-flag-4.0.0.tgz",
          "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
          "dev": true,
          "optional": true
        },
        "loader-utils": {
          "version": "2.0.2",
          "resolved": "https://registry.npmmirror.com/loader-utils/-/loader-utils-2.0.2.tgz",
          "integrity": "sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A==",
          "dev": true,
          "optional": true,
          "requires": {
            "big.js": "^5.2.2",
            "emojis-list": "^3.0.0",
            "json5": "^2.1.2"
          }
        },
        "ssri": {
          "version": "8.0.1",
          "resolved": "https://registry.nlark.com/ssri/download/ssri-8.0.1.tgz?cache=0&sync_timestamp=1621364647836&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fssri%2Fdownload%2Fssri-8.0.1.tgz",
@@ -2009,28 +1952,6 @@
          "dev": true,
          "requires": {
            "minipass": "^3.1.1"
          }
        },
        "supports-color": {
          "version": "7.2.0",
          "resolved": "https://registry.npmmirror.com/supports-color/-/supports-color-7.2.0.tgz",
          "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
          "dev": true,
          "optional": true,
          "requires": {
            "has-flag": "^4.0.0"
          }
        },
        "vue-loader-v16": {
          "version": "npm:vue-loader@16.8.3",
          "resolved": "https://registry.npmmirror.com/vue-loader/-/vue-loader-16.8.3.tgz",
          "integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==",
          "dev": true,
          "optional": true,
          "requires": {
            "chalk": "^4.1.0",
            "hash-sum": "^2.0.0",
            "loader-utils": "^2.0.0"
          }
        }
      }
@@ -7950,6 +7871,11 @@
      "integrity": "sha1-J8dlOb4U2L0Sghmi1zGwkzeQTnk=",
      "dev": true
    },
    "js-md5": {
      "version": "0.7.3",
      "resolved": "https://registry.npmjs.org/js-md5/-/js-md5-0.7.3.tgz",
      "integrity": "sha512-ZC41vPSTLKGwIRjqDh8DfXoCrdQIyBgspJVPXHBGu4nZlAEvG3nf+jO9avM9RmLiGakg7vz974ms99nEV0tmTQ=="
    },
    "js-message": {
      "version": "1.0.7",
      "resolved": "https://registry.npm.taobao.org/js-message/download/js-message-1.0.7.tgz?cache=0&sync_timestamp=1605128905632&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fjs-message%2Fdownload%2Fjs-message-1.0.7.tgz",
@@ -9061,6 +8987,11 @@
        "gauge": "~2.7.3",
        "set-blocking": "~2.0.0"
      }
    },
    "nprogress": {
      "version": "0.2.0",
      "resolved": "https://registry.npmjs.org/nprogress/-/nprogress-0.2.0.tgz",
      "integrity": "sha512-I19aIingLgR1fmhftnbWWO3dXc0hSxqHQHQb3H8m+K3TnEn/iSeTZZOyvKXWqQESMwuUVnatlCnZdLBZZt2VSA=="
    },
    "nth-check": {
      "version": "1.0.2",
@@ -13031,6 +12962,87 @@
        }
      }
    },
    "vue-loader-v16": {
      "version": "npm:vue-loader@16.8.3",
      "resolved": "https://registry.npmjs.org/vue-loader/-/vue-loader-16.8.3.tgz",
      "integrity": "sha512-7vKN45IxsKxe5GcVCbc2qFU5aWzyiLrYJyUuMz4BQLKctCj/fmCa0w6fGiiQ2cLFetNcek1ppGJQDCup0c1hpA==",
      "dev": true,
      "optional": true,
      "requires": {
        "chalk": "^4.1.0",
        "hash-sum": "^2.0.0",
        "loader-utils": "^2.0.0"
      },
      "dependencies": {
        "ansi-styles": {
          "version": "4.3.0",
          "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
          "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
          "dev": true,
          "optional": true,
          "requires": {
            "color-convert": "^2.0.1"
          }
        },
        "chalk": {
          "version": "4.1.2",
          "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
          "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
          "dev": true,
          "optional": true,
          "requires": {
            "ansi-styles": "^4.1.0",
            "supports-color": "^7.1.0"
          }
        },
        "color-convert": {
          "version": "2.0.1",
          "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
          "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
          "dev": true,
          "optional": true,
          "requires": {
            "color-name": "~1.1.4"
          }
        },
        "color-name": {
          "version": "1.1.4",
          "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
          "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
          "dev": true,
          "optional": true
        },
        "has-flag": {
          "version": "4.0.0",
          "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
          "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
          "dev": true,
          "optional": true
        },
        "loader-utils": {
          "version": "2.0.2",
          "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.2.tgz",
          "integrity": "sha512-TM57VeHptv569d/GKh6TAYdzKblwDNiumOdkFnejjD0XwTH87K90w3O7AiJRqdQoXygvi1VQTJTLGhJl7WqA7A==",
          "dev": true,
          "optional": true,
          "requires": {
            "big.js": "^5.2.2",
            "emojis-list": "^3.0.0",
            "json5": "^2.1.2"
          }
        },
        "supports-color": {
          "version": "7.2.0",
          "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
          "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
          "dev": true,
          "optional": true,
          "requires": {
            "has-flag": "^4.0.0"
          }
        }
      }
    },
    "vue-router": {
      "version": "3.5.2",
      "resolved": "https://registry.nlark.com/vue-router/download/vue-router-3.5.2.tgz?cache=0&sync_timestamp=1628495505697&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fvue-router%2Fdownload%2Fvue-router-3.5.2.tgz",
package.json
@@ -32,7 +32,9 @@
        "vue-axios": "^3.3.7",
        "vue-jsonp": "^2.0.0",
        "vue-router": "^3.5.2",
        "vuex": "^3.6.2"
        "vuex": "^3.6.2",
        "js-md5": "^0.7.3",
        "nprogress": "^0.2.0"
    },
    "devDependencies": {
        "@amap/amap-jsapi-loader": "^1.0.1",
src/main.js
@@ -13,6 +13,8 @@
import axios from './router/axios'
import VueAxios from 'vue-axios'
import './permission'
// 全局组件自动注册
import './components/autoRegister'
src/permission.js
New file
@@ -0,0 +1,24 @@
import router from '@/router/page/index'
import {
    getToken
} from './utils/auth'
router.beforeEach((to, from, next) => {
    const meta = to.meta || {}
    if (getToken()) {
        if (to.path === '/login') { // 如果登录成功访问登录页跳转到主页
            next({
                path: '/'
            })
        } else {
            next()
        }
    } else {
        // 判断是否需要认证,没有登录访问去登录页
        if (meta.isAuth === false) {
            next()
        } else {
            next('/login')
        }
    }
})
src/router/axios.js
@@ -6,28 +6,12 @@
 * isToken是否需要token
 */
import axios from 'axios'
const httpName = window.location.protocol + '//' + window.location.hostname
const url = httpName + '/apis'
// setTimeout(() => {
//   console.log(window.location);
//   console.log(url);
// }, 3000);
window.$apiUrls = 'http://182.106.212.58:8013/api'
// window.$apiUrls = 'http://192.168.0.114:89'
const service = axios.create({
    //   baseURL: 'http://192.168.0.107:83',
import router from '@/router/page/index.js'
import { Message } from 'element-ui'
import * as auth from '@/utils/auth'
    // baseURL: "http://localhost:82",
    // baseURL: "http://192.168.0.107:82",
    // baseURL: "http://192.168.0.107:80",
    // baseURL: "http://192.168.0.110:82", //唐
    // baseURL: "http://171.34.197.243:790", //正常接口
    baseURL: window.$apiUrls, // 2
    // baseURL: "http://171.34.197.243:82", //3
    // baseURL: "http://171.34.197.243:82/api", //验收
    // baseURL: "https://6e78efa6.cpolar.io/apis", //https接口
    // baseURL: url, //https接口
    // baseURL: 'http://s16s652780.51mypc.cn/api',
const service = axios.create({
    baseURL: 'http://182.106.212.58:8013/api', // 2
    timeout: 600000 // request timeout
})
@@ -42,6 +26,11 @@
// http request拦截
service.interceptors.request.use(
    (config) => {
        const token = auth.getToken()
        // 添加token
        token && (config.headers.token = token)
        return config
    },
    (error) => {
@@ -52,9 +41,22 @@
// http response 拦截
service.interceptors.response.use(
    (res) => {
        return res
        const code = res.data.code
        if (code === -1) {
            sessionStorage.removeItem('token')
            router.push('/login')
        } else {
            return res
        }
    },
    (error) => {
        Message({
            message: error.message,
            type: 'error',
            duration: 5 * 1000
        })
        return Promise.reject(new Error(error))
    }
)
src/router/page/index.js
@@ -2,7 +2,7 @@
 * @Author: Morpheus
 * @Date: 2021-04-30 14:12:09
 * @Last Modified by: Morpheus
 * @Last Modified time: 2022-07-14 18:28:34
 * @Last Modified time: 2022-07-29 09:15:23
 */
import Vue from 'vue'
@@ -19,6 +19,15 @@
    {
        path: '/',
        redirect: '/lyout'
    },
    {
        path: '/login',
        name: 'login',
        component: resolve => require(['../../views/login/index.vue'], resolve),
        meta: {
            title: '登录页',
            isAuth: false
        }
    },
    {
        path: '/lyout',
@@ -77,7 +86,8 @@
            import(/* webpackChunkName: "page" */ '@/components/error-page/403'),
        name: '403',
        meta: {
            title: '403页面'
            title: '403页面',
            isAuth: false
        }
    },
    {
@@ -86,7 +96,8 @@
            import(/* webpackChunkName: "page" */ '@/components/error-page/404'),
        name: '404',
        meta: {
            title: '404页面'
            title: '404页面',
            isAuth: false
        }
    },
@@ -96,12 +107,14 @@
            import(/* webpackChunkName: "page" */ '@/components/error-page/500'),
        name: '500',
        meta: {
            title: '500页面'
            title: '500页面',
            isAuth: false
        }
    },
    {
        path: '*',
        redirect: '/404'
        redirect: '/404',
        isAuth: false
    }
]
src/store/getters.js
@@ -1,97 +1,4 @@
// 手机端
const mobile = {
    // mviewer: (state) => state.mobile.mviewer,
    pinchFlag: (state) => state.mobile.pinchFlag,
    zoomRange: (state) => state.mobile.zoomRange,
    mBigPopup: (state) => state.mobile.mBigPopup,
    popupOurOpenData: (state) => state.mobile.popupOurOpenData,
    popupTableName: (state) => state.mobile.popupTableName,
    mBigPopupAfter: (state) => state.mobile.mBigPopupAfter,
    iconHide: (state) => state.mobile.iconHide,
    MobileWindowsHide: (state) => state.mobile.MobileWindowsHide, // 随地图移动窗口
    MobileWindowChangeData: (state) => state.mobile.MobileWindowChangeData, // 随地图移动窗口
    // popupsDom: (state) => state.mobile.popupsDom,
    query: (state) => state.mobile.query,
    openmobileGoTo: (state) => state.mobile.openmobileGoTo, // 测试
    ccDataState: (state) => state.mobile.ccDataState, // 测试
    openmobilePanorama: (state) => state.mobile.openmobilePanorama,
    MobileWindowsHideFixed: (state) => state.mobile.MobileWindowsHideFixed, // 固定窗口
    MobileWindowChangeDataFixed: (state) =>
        state.mobile.MobileWindowChangeDataFixed, // 固定窗口
    startPointFn: (state) => state.mobile.startPointFn, // 默认起始点位置
    dimension: (state) => state.mobile.dimension, // 维度
    dimensionData: (state) => state.mobile.dimensionData, // 维度镜头数据
    perspectiveControl: (state) => state.mobile.perspectiveControl, /// 视角控制:高度、角度  ()=>{}
    audioState: (state) => state.mobile.audioState, // 文字转语音状态
    // areaLayer: (state) => state.mobile.areaLayer, //
    // areaLayerSelect: (state) => state.mobile.select, //
    isOpenDrawALine: (state) => state.mobile.isOpenDrawALine, // 是否开启路线
    isendPosition: (state) => state.mobile.isendPosition, // 路线导航终点数据改变
    endPosition: (state) => state.mobile.endPosition, // 路线导航终点数据
    routerS: (state) => state.mobile.routerS, // 所有路径
    choiceRouterS: (state) => state.mobile.choiceRouterS, // 当前选择路径
    showActivity: (state) => state.mobile.showActivity, // 显影活动弹窗
    showActivityData: (state) => state.mobile.showActivityData, // 活动弹窗数据
    isOpenDrawALineMany: (state) => state.mobile.isOpenDrawALineMany, // 显影活动弹窗
    seeRight: (state) => state.mobile.seeRight, // 右侧控制栏显影
    urlParameterData: (state) => state.mobile.urlParameterData // url参数
}
const navigation = {
    campusNavFlag: (state) => state.navigation.campusNavFlag,
    comeName: (state) => state.navigation.comeName,
    getToName: (state) => state.navigation.getToName
}
const search = {
    orgNavBarFlag: (state) => state.search.orgNavBarFlag,
    orgNavBarTitle: (state) => state.search.orgNavBarTitle,
    orgNavBarList: (state) => state.search.orgNavBarList,
    arcNavBarFlag: (state) => state.search.arcNavBarFlag,
    arcNavBarTitle: (state) => state.search.arcNavBarTitle,
    arcNavBarCode: (state) => state.search.arcNavBarCode,
    searchPopupFlag: (state) => state.search.searchPopupFlag,
    searchPopupList: (state) => state.search.searchPopupList
}
const getters = {
    ...mobile,
    ...navigation,
    ...search,
    viewerExist: (state) => state.viewer.viewerExist,
    calenderShow: (state) => state.viewer.calenderShow,
    twoOrThree: (state) => state.viewer.twoOrThree,
    popupBgUrl: (state) => state.popupParams.popupBgUrl,
    pupupQRUrl: (state) => state.popupParams.pupupQRUrl,
    pointPosition: (state) => state.popupParams.pointPosition,
    terminus: (state) => state.popupParams.terminus,
    startingPoint: (state) => state.popupParams.startingPoint,
    stateName: (state) => state.popupParams.stateName,
    siteName: (state) => state.popupParams.siteName,
    telephone: (state) => state.popupParams.telephone,
    introduceText: (state) => state.popupParams.introduceText,
    panoramaUrl: (state) => state.popupParams.panoramaUrl,
    panoramaPopup: (state) => state.popupParams.panoramaPopup,
    monitorUrl: (state) => state.popupParams.monitorUrl,
    monitorPopup: (state) => state.popupParams.monitorPopup,
    detailsPopup: (state) => state.popupParams.detailsPopup,
    popupImgAtlas: (state) => state.popupParams.popupImgAtlas,
    teachList: (state) => state.popupParams.teachList,
    liveList: (state) => state.popupParams.liveList,
    addTagPopup: (state) => state.popupParams.addTagPopup,
    addTagPosition: (state) => state.popupParams.addTagPosition,
    addSignList: (state) => state.popupParams.addSignList,
    nowlabelLayerData: (state) => state.popupParams.nowlabelLayerData, // 自定义标签数据
    labelLayerDataShow: (state) => state.popupParams.labelLayerDataShow, // 自定义标签弹窗显示
    closeMapClick: (state) => state.popupParams.closeMapClick, // 关闭地图点击,防止新增标签误触
    addIconsLayerIconPopup: (state) => state.popupParams.addIconsLayerIconPopup, // 自定义标签编辑窗口
    addIconsLayerIconPosition: (state) => state.popupParams.addIconsLayerIconPosition // 自定义标签编辑窗口
}
export default getters
src/store/index.js
@@ -1,24 +1,14 @@
import Vue from 'vue'
import Vuex from 'vuex'
import viewer from './modules/viewer'
import popupParams from './modules/popupParams'
import navigation from './modules/navigation'
import search from './modules/search'
import mobile from './modules/mobile'
import mobilePosition from './modules/mobilePosition'
import user from './modules/user'
import getters from './getters'
Vue.use(Vuex)
const store = new Vuex.Store({
    modules: {
        mobile,
        mobilePosition,
        viewer,
        popupParams,
        navigation,
        search
        user
    },
    getters
})
src/store/modules/mobile.js
File was deleted
src/store/modules/mobilePosition copy.js
File was deleted
src/store/modules/mobilePosition.js
File was deleted
src/store/modules/mobilePositionLID.js
File was deleted
src/store/modules/mobilePositionLID1.js
File was deleted
src/store/modules/mobiles/urlParameter.js
File was deleted
src/store/modules/navigation.js
File was deleted
src/store/modules/pc/leftNavsData.js
File was deleted
src/store/modules/popupParams copy.js
File was deleted
src/store/modules/popupParams.js
File was deleted
src/store/modules/search.js
File was deleted
src/store/modules/user.js
New file
@@ -0,0 +1,18 @@
import * as auth from '@/utils/auth'
const user = {
    state: {
        user: null
    },
    mutations: {
        setUser (state, user) {
            state.user = user
            auth.setToken(user.access_token)
        }
    },
    actions: {
    }
}
export default user
src/store/modules/viewer.js
File was deleted
src/utils/auth.js
New file
@@ -0,0 +1,11 @@
export const getToken = () => {
    return window.sessionStorage.getItem('token')
}
export const setToken = token => {
    return window.sessionStorage.setItem('token', token)
}
export const removeToken = () => {
    return window.sessionStorage.removeItem('token')
}
src/views/login/index.vue
New file
@@ -0,0 +1,159 @@
<template>
    <div class="auth-page">
        <div class="container">
            <h1 class="text-xs-center">南城县智慧农业综合监管平台</h1>
            <div class="loginbody">
                <el-form :model="user" ref="formName" status-icon :rules="rules">
                    <!-- 用户账号 -->
                    <el-form-item prop="username">
                        <el-input
                            v-model="user.username"
                            prefix-icon="el-icon-user"
                            placeholder="用户账号"
                            autocomplete="off"
                        ></el-input>
                    </el-form-item>
                    <!-- 用户密码 -->
                    <el-form-item prop="password">
                        <el-input
                            type="password"
                            v-model="user.password"
                            prefix-icon="el-icon-lock"
                            placeholder="用户密码"
                            autocomplete="off"
                        ></el-input>
                    </el-form-item>
                    <!-- 登录按钮 -->
                    <el-form-item>
                        <el-button type="primary" @click.enter="onLogin(user)">登&nbsp;录</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </div>
    </div>
</template>
<script>
import nprogress from 'nprogress'
import md5 from 'js-md5'
import axios from 'axios'
export default {
    name: 'AppRegister',
    data () {
        return {
            user: {
                username: '',
                password: ''
            },
            rules: {
                username: [
                    { required: true, message: '请输入用户账号', trigger: 'blur' },
                    { min: 3, max: 10, message: '用户账号长度在3~10个字符之间', trigger: 'blur' }
                ],
                password: [
                    { required: true, message: '请输入用户密码', trigger: 'blur' },
                    { min: 3, max: 10, message: '用户密码长度在3~10个字符之间', trigger: 'blur' }
                ]
            },
            errors: null,
            newAxios: null
        }
    },
    created () {
        var that = this
        this.newAxios = axios.create({
            baseURL: 'http://182.106.212.58:8013/api',
            timeout: 600000,
            headers: {
                Authorization: 'Basic c2FiZXI6c2FiZXJfc2VjcmV0',
                'Tenant-Id': '000000'
            }
        })
        document.onkeydown = e => {
            const _key = window.event.keyCode
            if (_key === 13) {
                that.onLogin(that.user)
            }
        }
    },
    methods: {
        onLogin ({ username, password }) {
            this.$refs.formName.validate((valid) => {
                if (valid) {
                    nprogress.start()
                    this.newAxios({
                        method: 'POST',
                        url: '/blade-auth/oauth/token',
                        params: {
                            username: username,
                            password: md5(password),
                            tenantId: '000000'
                        }
                    }).then(res => {
                        if (res.data.access_token) {
                            this.$store.commit('setUser', res.data)
                            this.$router.push({ path: '/' })
                        } else {
                            this.$message({
                                type: 'warning',
                                message: '用户名或密码不正确,请重新输入'
                            })
                        }
                        nprogress.done()
                    })
                }
            })
        }
    }
}
</script>
<style scoped lang="scss">
.auth-page {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #0099cc;
    .container {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        margin: auto;
        width: 480px;
        height: 320px;
        background: #fff;
        border-radius: 10px;
        h1 {
            margin: 0;
            height: 80px;
            line-height: 80px;
            text-align: center;
        }
        .loginbody {
            position: absolute;
            top: 120px;
            left: 0;
            right: 0;
            bottom: 0;
            width: 72%;
            margin: auto;
            .el-form-item {
                text-align: center;
            }
        }
    }
}
</style>