Преглед изворни кода

新增许可证校验功能

cfort пре 2 година
родитељ
комит
914ed32646

+ 254 - 253
src/api/oauth2/oauth2.js

@@ -12,31 +12,29 @@
 import { OAUTH2_URL } from '@/api/baseUrl'
 import request from '@/utils/request'
 import requestState from '@/constants/state'
-import {
-  Message
-} from 'element-ui'
+import { Message } from 'element-ui'
 
 import qs from 'qs'
 
-var AccessToken = function(data) {
-  if (!(this instanceof AccessToken)) {
-    return new AccessToken(data)
-  }
-  this.data = data
+var AccessToken = function (data) {
+    if (!(this instanceof AccessToken)) {
+        return new AccessToken(data)
+    }
+    this.data = data
 }
 /**
  * 对返回结果的一层封装,如果遇见IBPS平台返回的错误,将返回一个错误
  * 参见:IBPS返回码说明
  */
-var wrapper = function(callback) {
-  return function(err, data, res) {
-    callback = callback || function() {}
-    if (err) {
-      err.name = 'IBPSAPI' + err.name
-      return callback(err, data, res)
+var wrapper = function (callback) {
+    return function (err, data, res) {
+        callback = callback || function () {}
+        if (err) {
+            err.name = 'IBPSAPI' + err.name
+            return callback(err, data, res)
+        }
+        callback(null, data, res)
     }
-    callback(null, data, res)
-  }
 }
 
 /*!
@@ -47,26 +45,30 @@ var wrapper = function(callback) {
  * token.isValid();
  * ```
  */
-AccessToken.prototype.isValid = function() {
-  return !!this.data.access_token && (new Date().getTime()) < (this.data.create_at + this.data.expires_in * 1000)
+AccessToken.prototype.isValid = function () {
+    return !!this.data.access_token && (new Date().getTime()) < (this.data.create_at + this.data.expires_in * 1000)
 }
 
 /*!
  * 处理token,更新过期时间
  */
-var processToken = function(that, callback) {
-  var createAt = new Date().getTime()
+var processToken = function (that, callback) {
+    var createAt = new Date().getTime()
 
-  return function(err, data, res) {
-    if (err) {
-      return callback(err, data, res)
+    return function (err, data, res) {
+        if (err) {
+            return callback(err, data, res)
+        }
+        data.create_at = createAt
+        // 20231106修改,将licence信息增加到接口返回数据
+        if (res.variables && res.variables.licJson) {
+            data.licJson = JSON.parse(res.variables.licJson)
+        }
+        // 存储token
+        that.saveToken(data.uid, data, function (err) {
+            callback(err, new AccessToken(data))
+        })
     }
-    data.create_at = createAt
-    // 存储token
-    that.saveToken(data.uid, data, function(err) {
-      callback(err, new AccessToken(data))
-    })
-  }
 }
 
 /**
@@ -87,23 +89,23 @@ var processToken = function(that, callback) {
  * @param {Function} getToken 用于获取token的方法
  * @param {Function} saveToken 用于保存token的方法
  */
-var OAuth = function(clientId, clientSecret, getToken, saveToken) {
-  this.clientId = clientId
-  this.clientSecret = clientSecret
-  this.statistic =''
-  // token的获取和存储
-  this.store = {}
-  this.getToken = getToken || function(uid, callback) {
-    callback(null, this.store[uid])
-  }
-  if (!saveToken && process.env.NODE_ENV === 'production') {
-    console.warn('Please dont save oauth token into memory under production')
-  }
-  this.saveToken = saveToken || function(uid, token, callback) {
-    this.store[uid] = token
-    callback(null)
-  }
-  this.defaults = {}
+var OAuth = function (clientId, clientSecret, getToken, saveToken) {
+    this.clientId = clientId
+    this.clientSecret = clientSecret
+    this.statistic = ''
+    // token的获取和存储
+    this.store = {}
+    this.getToken = getToken || function (uid, callback) {
+        callback(null, this.store[uid])
+    }
+    if (!saveToken && process.env.NODE_ENV === 'production') {
+        console.warn('Please dont save oauth token into memory under production')
+    }
+    this.saveToken = saveToken || function (uid, token, callback) {
+        this.store[uid] = token
+        callback(null)
+    }
+    this.defaults = {}
 }
 
 /*!
@@ -113,38 +115,37 @@ var OAuth = function(clientId, clientSecret, getToken, saveToken) {
  * @param {Object} opts urllib选项
  * @param {Function} callback 回调函数
  */
-OAuth.prototype.request = function(opts, callback) {
-  const options = {}
-  Object.assign(options, this.defaults)
-  if (typeof opts === 'function') {
-    callback = opts
-    opts = {}
-  }
-  for (const key in opts) {
-    if (key !== 'headers') {
-      options[key] = opts[key]
-    } else {
-      if (opts.headers) {
-        options.headers = options.headers || {}
-        Object.assign(options.headers, opts.headers)
-      }
+OAuth.prototype.request = function (opts, callback) {
+    const options = {}
+    Object.assign(options, this.defaults)
+    if (typeof opts === 'function') {
+        callback = opts
+        opts = {}
     }
-  }
-
-  request(options).then(response => {
-    const { state } = response
-    if (state === requestState.UNSUPORT ||
-      state === requestState.WARNING) {
-      const err = new Error(response.message)
-      err.state = state
-      err.cause = response.cause
-      callback(err)
-    } else {
-      callback(null, response.data, response)
+    for (const key in opts) {
+        if (key !== 'headers') {
+            options[key] = opts[key]
+        } else {
+            if (opts.headers) {
+                options.headers = options.headers || {}
+                Object.assign(options.headers, opts.headers)
+            }
+        }
     }
-  }).catch(error => {
-    callback(error)
-  })
+
+    request(options).then(response => {
+        const { state } = response
+        if (state === requestState.UNSUPORT || state === requestState.WARNING) {
+            const err = new Error(response.message)
+            err.state = state
+            err.cause = response.cause
+            callback(err)
+        } else {
+            callback(null, response.data, response)
+        }
+    }).catch(error => {
+        callback(error)
+    })
 }
 
 /**
@@ -153,17 +154,17 @@ OAuth.prototype.request = function(opts, callback) {
  * @param {String} state 开发者可提供的数据
  * @param {String} scope 作用范围,值为snsapi_userinfo和snsapi_base,前者用于弹出,后者用于跳转
  */
-OAuth.prototype.getAuthorizeURL = function(redirect, state, scope) {
-  const url = OAUTH2_URL() + ''
-  const info = {
-    clientId: this.clientId,
-    redirect_uri: redirect,
-    response_type: 'code',
-    scope: scope || 'snsapi_base',
-    state: state || ''
-  }
+OAuth.prototype.getAuthorizeURL = function (redirect, state, scope) {
+    const url = OAUTH2_URL() + ''
+    const info = {
+        clientId: this.clientId,
+        redirect_uri: redirect,
+        response_type: 'code',
+        scope: scope || 'snsapi_base',
+        state: state || ''
+    }
 
-  return url + '?' + qs.stringify(info) + '#ibps_redirect'
+    return url + '?' + qs.stringify(info) + '#ibps_redirect'
 }
 
 /**
@@ -172,17 +173,17 @@ OAuth.prototype.getAuthorizeURL = function(redirect, state, scope) {
  * @param {String} state 开发者可提供的数据
  * @param {String} scope 作用范围,值为snsapi_login,前者用于弹出,后者用于跳转
  */
-OAuth.prototype.getAuthorizeURLForWebsite = function(redirect, state, scope) {
-  const url = OAUTH2_URL() + '/qrconnect'
-  const info = {
-    clientId: this.clientId,
-    redirect_uri: redirect,
-    response_type: 'code',
-    scope: scope || 'snsapi_login',
-    state: state || ''
-  }
+OAuth.prototype.getAuthorizeURLForWebsite = function (redirect, state, scope) {
+    const url = OAUTH2_URL() + '/qrconnect'
+    const info = {
+        clientId: this.clientId,
+        redirect_uri: redirect,
+        response_type: 'code',
+        scope: scope || 'snsapi_login',
+        state: state || ''
+    }
 
-  return url + '?' + qs.stringify(info) + '#ibps_redirect'
+    return url + '?' + qs.stringify(info) + '#ibps_redirect'
 }
 
 /**
@@ -212,18 +213,18 @@ OAuth.prototype.getAuthorizeURLForWebsite = function(redirect, state, scope) {
  * @param {String} code 授权获取到的code
  * @param {Function} callback 回调函数
  */
-OAuth.prototype.getAccessTokenByCode = function(code, callback) {
-  const args = {
-    url: OAUTH2_URL() + '/authentication/apply',
-    data: {
-      client_id: this.clientId,
-      client_secret: this.clientSecret,
-      authorize_code: code,
-      grant_type: 'authorization_code'
-    },
-    method: 'post'
-  }
-  this.request(args, wrapper(processToken(this, callback)))
+OAuth.prototype.getAccessTokenByCode = function (code, callback) {
+    const args = {
+        url: OAUTH2_URL() + '/authentication/apply',
+        data: {
+            client_id: this.clientId,
+            client_secret: this.clientSecret,
+            authorize_code: code,
+            grant_type: 'authorization_code'
+        },
+        method: 'post'
+    }
+    this.request(args, wrapper(processToken(this, callback)))
 }
 /**
  * 密码授权模式
@@ -255,19 +256,19 @@ OAuth.prototype.getAccessTokenByCode = function(code, callback) {
  * @param {String} password  密码
  * @param {Function} callback 回调函数
  */
-OAuth.prototype.getAccessTokenByPassword = function({ username, password }, callback) {
-  const args = {
-    url: OAUTH2_URL() + '/authentication/apply',
-    data: {
-      client_id: this.clientId,
-      client_secret: this.clientSecret,
-      username: username,
-      password: password,
-      grant_type: 'password_credentials'
-    },
-    method: 'post'
-  }
-  this.request(args, wrapper(processToken(this, callback)))
+OAuth.prototype.getAccessTokenByPassword = function ({ username, password }, callback) {
+    const args = {
+        url: OAUTH2_URL() + '/authentication/apply',
+        data: {
+            client_id: this.clientId,
+            client_secret: this.clientSecret,
+            username: username,
+            password: password,
+            grant_type: 'password_credentials'
+        },
+        method: 'post'
+    }
+    this.request(args, wrapper(processToken(this, callback)))
 }
 
 /**
@@ -296,19 +297,19 @@ OAuth.prototype.getAccessTokenByPassword = function({ username, password }, call
  * @param {String} refreshToken 刷新tonken
  * @param {Function} callback 回调函数
  */
-OAuth.prototype.refreshAccessToken = function(refreshToken, callback) {
-  const args = {
-    url: OAUTH2_URL() + '/authentication/apply',
-    data: {
-      client_id: this.clientId,
-      client_secret: this.clientSecret,
-      grant_type: 'refresh_token',
-      refresh_token: refreshToken
-    },
-    method: 'post'
+OAuth.prototype.refreshAccessToken = function (refreshToken, callback) {
+    const args = {
+        url: OAUTH2_URL() + '/authentication/apply',
+        data: {
+            client_id: this.clientId,
+            client_secret: this.clientSecret,
+            grant_type: 'refresh_token',
+            refresh_token: refreshToken
+        },
+        method: 'post'
 
-  }
-  this.request(args, wrapper(processToken(this, callback)))
+    }
+    this.request(args, wrapper(processToken(this, callback)))
 }
 /**
  * 获取用户信息 【私有方法】
@@ -316,16 +317,16 @@ OAuth.prototype.refreshAccessToken = function(refreshToken, callback) {
  * @param {*} accessToken
  * @param {*} callback
  */
-OAuth.prototype._getUser = function(options, accessToken, callback) {
-  const args = {
-    url: OAUTH2_URL() + '/user/context',
-    data: {
-      access_token: accessToken,
-      uid: options.uid,
-      lang: options.lang || 'zh_CN'
+OAuth.prototype._getUser = function (options, accessToken, callback) {
+    const args = {
+        url: OAUTH2_URL() + '/user/context',
+        data: {
+            access_token: accessToken,
+            uid: options.uid,
+            lang: options.lang || 'zh_CN'
+        }
     }
-  }
-  this.request(args, wrapper(callback))
+    this.request(args, wrapper(callback))
 }
 
 /**
@@ -369,43 +370,43 @@ OAuth.prototype._getUser = function(options, accessToken, callback) {
  * @param {Object|String} options 传入uid或者参见Options
  * @param {Function} callback 回调函数
  */
-OAuth.prototype.getUser = function(options, callback) {
-  if (typeof options !== 'object') {
-    options = {
-      uid: options
-    }
-  }
-  const that = this
-  this.getToken(options.uid, function(err, data) {
-    if (err) {
-      return callback(err)
-    }
-    // 没有token数据
-    if (!data) {
-      const message = 'No token for ' + options.uid + ', please authorize first.'
-      Message({
-        message: `${message}`,
-        type: 'error',
-        showClose: true,
-        dangerouslyUseHTMLString: true,
-        duration: 5 * 1000
-      })
-      const error = new Error(message)
-      err.state = 'NoOAuthTokenError'
-      return callback(error)
+OAuth.prototype.getUser = function (options, callback) {
+    if (typeof options !== 'object') {
+        options = {
+            uid: options
+        }
     }
-    const token = new AccessToken(data)
-    if (token.isValid()) {
-      that._getUser(options, token.data.access_token, callback)
-    } else {
-      that.refreshAccessToken(token.data.refresh_token, function(err, token) {
+    const that = this
+    this.getToken(options.uid, function (err, data) {
         if (err) {
-          return callback(err)
+            return callback(err)
         }
-        that._getUser(options, token.data.access_token, callback)
-      })
-    }
-  })
+        // 没有token数据
+        if (!data) {
+            const message = 'No token for ' + options.uid + ', please authorize first.'
+            Message({
+                message: `${message}`,
+                type: 'error',
+                showClose: true,
+                dangerouslyUseHTMLString: true,
+                duration: 5 * 1000
+            })
+            const error = new Error(message)
+            err.state = 'NoOAuthTokenError'
+            return callback(error)
+        }
+        const token = new AccessToken(data)
+        if (token.isValid()) {
+            that._getUser(options, token.data.access_token, callback)
+        } else {
+            that.refreshAccessToken(token.data.refresh_token, function (err, token) {
+                if (err) {
+                    return callback(err)
+                }
+                that._getUser(options, token.data.access_token, callback)
+            })
+        }
+    })
 }
 
 /**
@@ -418,16 +419,16 @@ OAuth.prototype.getUser = function(options, callback) {
  * @param {String} accessToken 待校验的access token
  * @param {Function} callback 回调函数
  */
-OAuth.prototype.verifyToken = function(uid, accessToken, callback) {
-  const args = {
-    url: OAUTH2_URL() + '/authentication/verify',
-    params: {
-      access_token: accessToken,
-      uid: uid
-    },
-    method: 'post'
-  }
-  this.request(args, wrapper(callback))
+OAuth.prototype.verifyToken = function (uid, accessToken, callback) {
+    const args = {
+        url: OAUTH2_URL() + '/authentication/verify',
+        params: {
+            access_token: accessToken,
+            uid: uid
+        },
+        method: 'post'
+    }
+    this.request(args, wrapper(callback))
 }
 
 /**
@@ -441,13 +442,13 @@ OAuth.prototype.verifyToken = function(uid, accessToken, callback) {
  *     password : 密码
  * @param {Function} callback 回调函数
  */
-OAuth.prototype.userLogin = function(data, callback) {
-  const args = {
-    url: OAUTH2_URL() + '/user/login/apply',
-    data: data,
-    method: 'post'
-  }
-  this.request(args, wrapper(callback))
+OAuth.prototype.userLogin = function (data, callback) {
+    const args = {
+        url: OAUTH2_URL() + '/user/login/apply',
+        data: data,
+        method: 'post'
+    }
+    this.request(args, wrapper(callback))
 }
 
 /**
@@ -460,21 +461,21 @@ OAuth.prototype.userLogin = function(data, callback) {
  * @param {Objcct} options
  * @param {Function} callback 回调函数
  */
-OAuth.prototype.authorize = function(data, callback) {
-  const url = OAUTH2_URL() + '/authorize/apply'
-  if (typeof data !== 'object') {
-    data = {
-      login_state: data
+OAuth.prototype.authorize = function (data, callback) {
+    const url = OAUTH2_URL() + '/authorize/apply'
+    if (typeof data !== 'object') {
+        data = {
+            login_state: data
+        }
     }
-  }
-  data.client_id = this.clientId
+    data.client_id = this.clientId
 
-  const args = {
-    url,
-    data: data,
-    method: 'post'
-  }
-  this.request(args, wrapper(callback))
+    const args = {
+        url,
+        data: data,
+        method: 'post'
+    }
+    this.request(args, wrapper(callback))
 }
 
 /**
@@ -507,25 +508,25 @@ OAuth.prototype.authorize = function(data, callback) {
  * @param {Object|String} options 授权获取到的code
  * @param {Function} callback 回调函数
  */
-OAuth.prototype.getUserByCode = function(options, callback) {
-  const that = this
+OAuth.prototype.getUserByCode = function (options, callback) {
+    const that = this
 
-  let lang
-  let code
-  if (typeof options === 'string') {
-    code = options
-  } else {
-    lang = options.lang
-    code = options.code
-  }
-
-  this.getAccessTokenByCode(code, function(err, result) {
-    if (err) {
-      return callback(err)
+    let lang
+    let code
+    if (typeof options === 'string') {
+        code = options
+    } else {
+        lang = options.lang
+        code = options.code
     }
-    const uid = result.data.uid
-    that.getUser({ uid: uid, lang: lang }, callback)
-  })
+
+    this.getAccessTokenByCode(code, function (err, result) {
+        if (err) {
+            return callback(err)
+        }
+        const uid = result.data.uid
+        that.getUser({ uid: uid, lang: lang }, callback)
+    })
 }
 
 /**
@@ -533,38 +534,38 @@ OAuth.prototype.getUserByCode = function(options, callback) {
  * @param {*} options
  * @param {*} callback
  */
-OAuth.prototype.getLoginCode = function(options, callback) {
-  const that = this
-  /**
-   * 用户登录
-   */
-  this.userLogin(options, function(err, data,res) {
-    if (err) {
-      return callback(err)
-    }
-    that.statistic = res.variables.statistic //判斷是否有统计权限
-    // 没有token数据
-    if (!data) {
-      const message = '没有传回用户信息'
-      Message({
-        message: `${message}`,
-        type: 'error',
-        showClose: true,
-        dangerouslyUseHTMLString: true,
-        duration: 5 * 1000
-      })
-      const error = new Error(message)
-      err.state = 'NoOAuthTokenError'
-      return callback(error)
-    }
+OAuth.prototype.getLoginCode = function (options, callback) {
+    const that = this
+    /**
+     * 用户登录
+     */
+    this.userLogin(options, function (err, data, res) {
+        if (err) {
+            return callback(err)
+        }
+        that.statistic = res.variables.statistic // 判斷是否有统计权限
+        // 没有token数据
+        if (!data) {
+            const message = '没有传回用户信息'
+            Message({
+                message: `${message}`,
+                type: 'error',
+                showClose: true,
+                dangerouslyUseHTMLString: true,
+                duration: 5 * 1000
+            })
+            const error = new Error(message)
+            err.state = 'NoOAuthTokenError'
+            return callback(error)
+        }
 
-    that.authorize(data, function(err1, data1) {
-      if (err1) {
-        return callback(err1)
-      }
-      that.getAccessTokenByCode(data1, callback)
+        that.authorize(data, function (err1, data1) {
+            if (err1) {
+                return callback(err1)
+            }
+            that.getAccessTokenByCode(data1, callback)
+        })
     })
-  })
 }
 
 export default OAuth

+ 19 - 1
src/layout/header-aside/components/header-message/index.vue

@@ -144,7 +144,25 @@ export default {
         //     this.isControl=true
         //     this.loadData()
         // }, 1000)
-        // Watermark.set('线上试用版本','深圳市金源信通')
+        const { licence = {} } = this.$store.getters
+        const { isTrialVersion, notAfter, needRemind, customerInfo } = licence
+        const now = Date.now()
+        if (isTrialVersion) {
+            // 超出试用期限后登出
+            if (now > notAfter) {
+                this.$store.dispatch('ibps/account/logout', {
+                    vm: this
+                })
+                return
+            }
+            if (needRemind) {
+                this.$confirm('系统试用期即将结束,请联系开发方购买永久版或申请新的试用许可证!', '提示', {
+                    type: 'warning'
+                })
+            }
+            const limitDate = new Date(notAfter).toLocaleDateString('zh-CN')
+            Watermark.set(`${customerInfo}试用版本`, `试用日期截止至${limitDate}`)
+        }
         this.loadData()
         Bus.$on('getMessageCount', (count) => {
             this.messageCount = count

+ 3 - 1
src/store/getters.js

@@ -37,5 +37,7 @@ export default {
     // 获取所有部门信息
     deptList: state => state.ibps.param && state.ibps.param.deptList ? state.ibps.param.deptList : [],
     // 获取用户最高层级
-    level: state => state.ibps.param && state.ibps.param.level ? state.ibps.param.level : []
+    level: state => state.ibps.param && state.ibps.param.level ? state.ibps.param.level : [],
+    // 获取认证信息
+    licence: state => state.ibps.licence ? state.ibps.licence.licJson : {}
 }

+ 269 - 289
src/store/modules/ibps/modules/account.js

@@ -6,297 +6,277 @@ import { frameInRoutes } from '@/router/routes'
 import { getToken, updateToken, removeToken, removeRefreshToken, setUuid, removeUuid, removeTenantId } from '@/utils/auth'
 
 export default {
-  namespaced: true,
-  actions: {
-    /**
-     * @description 获取验证码
-     * @param {*} payload
-     * @param {*} payload
-     */
-    getCaptcha({ dispatch }, { params } = {}) {
-      return new Promise((resolve, reject) => {
-        getValidCode(params).then(response => {
-          resolve(response)
-        }).catch(error => {
-          reject(error)
-        })
-      })
-    },
-    /**
-     *  @description 是否开启注册
-     *
-     */
-    getRegisterOpen() {
-      return new Promise((resolve, reject) => {
-        getRegisterOpen().then(response => {
-          resolve(response)
-        }).catch(error => {
-          reject(error)
-        })
-      })
-    },
-    /**
-     * @description 登录
-     * @param {Object} context
-     * @param {Object} payload username {String} 用户账号
-     * @param {Object} payload password {String} 密码
-     * @param {Object} payload route {Object} 登录成功后定向的路由对象 任何 vue-router 支持的格式
-     */
-    login({ dispatch }, {
-      form
-    } = {}) {
-      return new Promise(async(resolve, reject) => {
-        // 开始请求登录接口
-        login(form).then(async response => {
-          const data = response.data
-           dispatch('updataTokenInfo', data)
-          // 设置 vuex 用户信息
-           dispatch('ibps/user/setAccount', form.username, { root: true })
+    namespaced: true,
+    actions: {
+        /**
+         * @description 获取验证码
+         * @param {*} payload
+         * @param {*} payload
+         */
+        getCaptcha ({ dispatch }, { params } = {}) {
+            return new Promise((resolve, reject) => {
+                getValidCode(params).then(response => {
+                    resolve(response)
+                }).catch(error => {
+                    reject(error)
+                })
+            })
+        },
+        /**
+         *  @description 是否开启注册
+         *
+         */
+        getRegisterOpen () {
+            return new Promise((resolve, reject) => {
+                getRegisterOpen().then(response => {
+                    resolve(response)
+                }).catch(error => {
+                    reject(error)
+                })
+            })
+        },
+        /**
+         * @description 登录
+         * @param {Object} context
+         * @param {Object} payload username {String} 用户账号
+         * @param {Object} payload password {String} 密码
+         * @param {Object} payload route {Object} 登录成功后定向的路由对象 任何 vue-router 支持的格式
+         */
+        login ({ dispatch }, { form } = {}) {
+            return new Promise(async (resolve, reject) => {
+                // 开始请求登录接口
+                login(form).then(async response => {
+                    const { data = {} } = response
+                    const tokenInfo = JSON.parse(JSON.stringify(data))
+                    tokenInfo.licJson = undefined
+                    const licenceData = data.licJson || {}
+                    const { isTrialVersion, notAfter, reminderDays, notBefore } = licenceData
+                    const now = Date.now()
+                    // 判定是否超时
+                    licenceData.overtime = isTrialVersion && (notBefore > now || notAfter < now)
+                    // 判定是否提醒
+                    licenceData.needRemind = isTrialVersion && notBefore < now && notAfter > now && now + reminderDays * 86400000 > notAfter
 
-          // 结束
-          resolve(data)
-        }).catch(err => {
-          console.error('err: ', err)
-          reject(err)
-        })
-      })
-    },
-    /**
-     * 更新token 用户信息
-     * @param {*} param0
-     * @param {*} data
-     */
-    updataTokenInfo({
-      commit,
-      dispatch
-    }, data) {
-      // 设置 cookie 一定要存 uuid 和 token 两个 cookie
-      // 整个系统依赖这两个数据进行校验和存储
-      // uuid 是用户身份唯一标识 用户注册的时候确定 并且不可改变 不可重复
-      // token 代表用户当前登录状态 建议在网络请求中携带 token
-      // 如有必要 token 需要定时更新,默认保存一天
-      updateToken(data)
-      setUuid(data.uid)
-    },
-    /**
-     * 忘记密码
-     * @param {*} param context 上下文
-     * @param {*} form 表单
-     */
-    resetPasswd({
-      commit,
-      dispatch
-    }, form) {
-      return new Promise(async(resolve, reject) => {
-        // 开始请求重置密码接口
-        resetPasswd(form).then(response => {
-          resolve()
-        }).catch(err => {
-          console.error('err: ', err)
-          reject(err)
-        })
-      })
-    },
-    /**
-     * 企业租户用户忘记密码
-     * @param {*} param context 上下文
-     * @param {*} form 表单
-     */
-    resetTenantPasswd({
-      commit,
-      dispatch
-    }, form) {
-      return new Promise(async(resolve, reject) => {
-        // 开始请求重置密码接口
-        resetTenantPasswd(form).then(response => {
-          resolve()
-        }).catch(err => {
-          console.error('err: ', err)
-          reject(err)
-        })
-      })
-    },
-    /**
-     * 注册帐号
-     * @param {*} param context 上下文
-     * @param {*} form 表单
-     */
-    register({
-      commit,
-      dispatch
-    }, form) {
-      return new Promise(async(resolve, reject) => {
-        // 开始请求注册接口
-        register(form).then(response => {
-          resolve()
-        }).catch(err => {
-          console.error('err: ', err)
-          reject(err)
-        })
-      })
-    },
-    /**
-     * @description 注销用户并返回登录页面
-     * @param {Object} param context 上下文
-     * @param {Object} param vm {Object} vue 实例
-     * @param {Object} param confirm {Boolean} 是否需要确认
-     */
-    logout({
-      commit,
-      dispatch
-    }, {
-      vm,
-      confirm = false
-    }) {
-      // 判断是否需要确认
-      if (confirm) {
-        commit('ibps/gray/set', true, {
-          root: true
-        })
-        MessageBox.confirm(vm.$t('logout.message'), vm.$t('logout.title'), {
-          confirmButtonText: vm.$t('logout.confirmButtonText'),
-          cancelButtonText: vm.$t('logout.cancelButtonText'),
-          type: 'warning'
-        }).then(() => {
-          commit('ibps/gray/set', false, {
-            root: true
-          })
-          dispatch('logoff', { vm })
-        })
-          .catch(() => {
-            commit('ibps/gray/set', false, {
-              root: true
+                    // 更新token
+                    dispatch('updataTokenInfo', tokenInfo)
+                    // 设置 vuex 用户信息
+                    dispatch('ibps/user/setAccount', form.username, { root: true })
+                    // 设置认证信息
+                    dispatch('ibps/licence/setLicence', licenceData, { root: true })
+                    localStorage.setItem('licence', JSON.stringify(licenceData))
+                    // 结束
+                    resolve({ ...tokenInfo, licenceData })
+                }).catch(err => {
+                    console.error('err: ', err)
+                    reject(err)
+                })
+            })
+        },
+        /**
+         * 更新token 用户信息
+         * @param {*} param0
+         * @param {*} data
+         */
+        updataTokenInfo ({ commit, dispatch }, data) {
+            // 设置 cookie 一定要存 uuid 和 token 两个 cookie
+            // 整个系统依赖这两个数据进行校验和存储
+            // uuid 是用户身份唯一标识 用户注册的时候确定 并且不可改变 不可重复
+            // token 代表用户当前登录状态 建议在网络请求中携带 token
+            // 如有必要 token 需要定时更新,默认保存一天
+            updateToken(data)
+            setUuid(data.uid)
+        },
+        /**
+         * 忘记密码
+         * @param {*} param context 上下文
+         * @param {*} form 表单
+         */
+        resetPasswd ({ commit, dispatch }, form) {
+            return new Promise(async (resolve, reject) => {
+                // 开始请求重置密码接口
+                resetPasswd(form).then(response => {
+                    resolve()
+                }).catch(err => {
+                    console.error('err: ', err)
+                    reject(err)
+                })
+            })
+        },
+        /**
+         * 企业租户用户忘记密码
+         * @param {*} param context 上下文
+         * @param {*} form 表单
+         */
+        resetTenantPasswd ({ commit, dispatch }, form) {
+            return new Promise(async (resolve, reject) => {
+                // 开始请求重置密码接口
+                resetTenantPasswd(form).then(response => {
+                    resolve()
+                }).catch(err => {
+                    console.error('err: ', err)
+                    reject(err)
+                })
+            })
+        },
+        /**
+         * 注册帐号
+         * @param {*} param context 上下文
+         * @param {*} form 表单
+         */
+        register ({ commit, dispatch }, form) {
+            return new Promise(async (resolve, reject) => {
+                // 开始请求注册接口
+                register(form).then(response => {
+                    resolve()
+                }).catch(err => {
+                    console.error('err: ', err)
+                    reject(err)
+                })
             })
-          })
-      } else {
-        dispatch('logoff', { vm })
-      }
-    },
-    /**
-     * 注销,包含后台登出和前台清除token
-     */
-    logoff({ dispatch }, { vm }) {
-      const token = getToken()
-      // 如果token过期直接登出
-      if (token === null || token === '') {
-        dispatch('fedLogout').then(() => {
-          vm.$router.push({
-            name: 'login'
-          })
-        }).catch(() => {})
-        return
-      }
-      // 后台登出
-      logout(token).then(() => {
-        dispatch('fedLogout').then(() => {
-          vm.$router.push({
-            name: 'login'
-          })
-        }).catch(() => {})
-      }).catch(() => {
-        dispatch('fedLogout').then(() => {
-          vm.$router.push({
-            name: 'login'
-          })
-        }).catch(() => {})
-      })
-    },
-    /**
-     * 前台登出
-     */
-   fedLogout({
-      commit,
-      dispatch
-    }, vm) {
-      return new Promise(async(resolve, reject) => {
-        // 重置路由
-        // resetRouter()
-        // 删除一系列cookie
-        removeToken()
-        removeUuid()
-        removeRefreshToken()
-        removeTenantId()
-        // 删除用户信息
-        dispatch('ibps/user/setAccount', null, { root: true })
-        dispatch('ibps/user/set', null, { root: true })
-        // 删除菜单
-        dispatch('ibps/menu/menusSet', null, { root: true })
-        resolve(vm)
-      })
-    },
-    /**
-     * 刷新token
-     * @param {*} param0
-     * @param {*} token
-     */
-    refreshToken({
-      commit,
-      dispatch
-    }) {
-      return new Promise(async(resolve, reject) => {
-        await refreshAccessToken().then(response => {
-          const data = response.data
-          // 更新token信息
-          updateToken(data)
-          resolve(data)
-        }).catch(err => {
-          console.error('refreshAccessToken-err: ', err)
-          removeRefreshToken()
-          reject(err)
-        })
-      })
-    },
-    /**
-     * 加载登录后的信息
-     * @param {*} param0
-     * @param {*} param1
-     */
-    loadInfo({
-      commit,
-      dispatch
-    }, {
-      addRouters = [],
-      menus
-    }) {
-      return new Promise(async resolve => {
-        const routes = [...frameInRoutes, ...addRouters]
-        // 处理路由 得到每一级的路由设置
-        await commit('ibps/page/init', routes, {
-          root: true
-        })
-        // 初始化菜单搜索功能
-        await commit('ibps/search/init', menus, {
-          root: true
-        })
+        },
+        /**
+         * @description 注销用户并返回登录页面
+         * @param {Object} param context 上下文
+         * @param {Object} param vm {Object} vue 实例
+         * @param {Object} param confirm {Boolean} 是否需要确认
+         */
+        logout ({ commit, dispatch }, { vm, confirm = false }) {
+            // 判断是否需要确认
+            if (confirm) {
+                commit('ibps/gray/set', true, {
+                    root: true
+                })
+                MessageBox.confirm(vm.$t('logout.message'), vm.$t('logout.title'), {
+                    confirmButtonText: vm.$t('logout.confirmButtonText'),
+                    cancelButtonText: vm.$t('logout.cancelButtonText'),
+                    type: 'warning'
+                }).then(() => {
+                    commit('ibps/gray/set', false, {
+                        root: true
+                    })
+                    dispatch('logoff', { vm })
+                }).catch(() => {
+                    commit('ibps/gray/set', false, {
+                        root: true
+                    })
+                })
+            } else {
+                dispatch('logoff', { vm })
+            }
+        },
+        /**
+         * 注销,包含后台登出和前台清除token
+         */
+        logoff ({ dispatch }, { vm }) {
+            const token = getToken()
+            // 如果token过期直接登出
+            if (token === null || token === '') {
+                dispatch('fedLogout').then(() => {
+                    vm.$router.push({
+                        name: 'login'
+                    })
+                }).catch(() => { })
+                return
+            }
+            // 后台登出
+            logout(token).then(() => {
+                dispatch('fedLogout').then(() => {
+                    vm.$router.push({
+                        name: 'login'
+                    })
+                }).catch(() => { })
+            }).catch(() => {
+                dispatch('fedLogout').then(() => {
+                    vm.$router.push({
+                        name: 'login'
+                    })
+                }).catch(() => { })
+            })
+        },
+        /**
+         * 前台登出
+         */
+        fedLogout ({ commit, dispatch }, vm) {
+            return new Promise(async (resolve, reject) => {
+                // 重置路由
+                // resetRouter()
+                // 删除一系列cookie
+                removeToken()
+                removeUuid()
+                removeRefreshToken()
+                removeTenantId()
+                // 删除用户信息
+                dispatch('ibps/user/setAccount', null, { root: true })
+                dispatch('ibps/user/set', null, { root: true })
+                // 删除菜单
+                dispatch('ibps/menu/menusSet', null, { root: true })
+                resolve(vm)
+            })
+        },
+        /**
+         * 刷新token
+         * @param {*} param0
+         * @param {*} token
+         */
+        refreshToken ({ commit, dispatch }) {
+            return new Promise(async (resolve, reject) => {
+                await refreshAccessToken().then(response => {
+                    const data = response.data
+                    // 更新token信息
+                    updateToken(data)
+                    resolve(data)
+                }).catch(err => {
+                    console.error('refreshAccessToken-err: ', err)
+                    removeRefreshToken()
+                    reject(err)
+                })
+            })
+        },
+        /**
+         * 加载登录后的信息
+         * @param {*} param0
+         * @param {*} param1
+         */
+        loadInfo ({ commit, dispatch }, { addRouters = [], menus }) {
+            return new Promise(async resolve => {
+                const routes = [...frameInRoutes, ...addRouters]
+                // 处理路由 得到每一级的路由设置
+                await commit('ibps/page/init', routes, {
+                    root: true
+                })
+                // 初始化菜单搜索功能
+                await commit('ibps/search/init', menus, {
+                    root: true
+                })
 
-        await dispatch('load')
-      })
-    },
-    /**
-     * @description 用户登录后从持久化数据加载一系列的设置
-     * @param {Object} context
-     */
-    load({ dispatch }) {
-      return new Promise(async resolve => {
-        // DB -> store 加载用户名
-        await dispatch('ibps/user/get', null, { root: true })
-        // DB -> store 加载主题
-        await dispatch('ibps/theme/load', null, { root: true })
-        // DB -> store 加载页面过渡效果设置
-        await dispatch('ibps/transition/load', null, { root: true })
-        // DB -> store 持久化数据加载上次退出时的多页列表
-        await dispatch('ibps/page/openedLoad', null, { root: true })
-        // DB -> store  持久化数据加载侧边栏配置
-        await dispatch('ibps/menu/asideLoad', null, { root: true })
-        // DB -> store 持久化数据加载全局尺寸
-        await dispatch('ibps/size/load', null, { root: true })
-        // DB -> store 持久化数据加载全局国际化
-        await dispatch('ibps/language/load', null, { root: true })
-        // DB -> store 持久化数据加载颜色设置
-        await dispatch('ibps/color/load', null, { root: true })
-        // end
-        resolve()
-      })
+                await dispatch('load')
+            })
+        },
+        /**
+         * @description 用户登录后从持久化数据加载一系列的设置
+         * @param {Object} context
+         */
+        load ({ dispatch }) {
+            return new Promise(async resolve => {
+                // DB -> store 加载用户名
+                await dispatch('ibps/user/get', null, { root: true })
+                // DB -> store 加载主题
+                await dispatch('ibps/theme/load', null, { root: true })
+                // DB -> store 加载页面过渡效果设置
+                await dispatch('ibps/transition/load', null, { root: true })
+                // DB -> store 持久化数据加载上次退出时的多页列表
+                await dispatch('ibps/page/openedLoad', null, { root: true })
+                // DB -> store  持久化数据加载侧边栏配置
+                await dispatch('ibps/menu/asideLoad', null, { root: true })
+                // DB -> store 持久化数据加载全局尺寸
+                await dispatch('ibps/size/load', null, { root: true })
+                // DB -> store 持久化数据加载全局国际化
+                await dispatch('ibps/language/load', null, { root: true })
+                // DB -> store 持久化数据加载颜色设置
+                await dispatch('ibps/color/load', null, { root: true })
+                // end
+                resolve()
+            })
+        }
     }
-  }
 }

+ 17 - 0
src/store/modules/ibps/modules/licence.js

@@ -0,0 +1,17 @@
+export default {
+    namespaced: true,
+    state: {
+        licJson: {}
+    },
+    mutations: {
+        updateLicJson (state, data) {
+            state.licJson = data
+        }
+    },
+    actions: {
+        setLicence ({ commit }, data) {
+            console.log(data)
+            commit('updateLicJson', data)
+        }
+    }
+}

+ 15 - 20
src/store/modules/ibps/modules/user.js

@@ -2,6 +2,7 @@ import { getUserInfo, switchUser, exitSwitchUser, getRegisterOpen } from '@/api/
 import { getToken, getUuid } from '@/utils/auth'
 import Utils from '@/utils/util'
 import common from '@/utils/common'
+import router from '@/router'
 
 export default {
     namespaced: true,
@@ -57,6 +58,8 @@ export default {
                 await dispatch('getAccount')
                 // 获取切换用户账号
                 await dispatch('getSwitchAccount')
+                // 存储许可证信息
+                await dispatch('ibps/licence/setLicence', JSON.parse(localStorage.getItem('licence')), { root: true })
 
                 // 获取注册用户账号
                 dispatch('getRegister').then((r) => {
@@ -145,10 +148,7 @@ export default {
                 resolve()
             })
         },
-        setAccount ({
-            state,
-            dispatch
-        }, account) {
+        setAccount ({ state, dispatch }, account) {
             return new Promise(async resolve => {
                 // store 赋值
                 state.account = account
@@ -218,10 +218,7 @@ export default {
          * @param {*} param0
          * @param {*} switchAccount
          */
-        setSwitchAccount ({
-            state,
-            dispatch
-        }, switchAccount) {
+        setSwitchAccount ({ state, dispatch }, switchAccount) {
             return new Promise(async resolve => {
                 // store 赋值
                 state.switchAccount = switchAccount
@@ -241,10 +238,7 @@ export default {
          * @param {*} param0
          * @param {*} username
          */
-        switchUser ({
-            state,
-            dispatch
-        }, username) {
+        switchUser ({ state, dispatch }, username) {
             return new Promise(async (resolve, reject) => {
                 const switchAccount = state.account
                 let token = getToken()
@@ -262,6 +256,7 @@ export default {
                     token: token
                 }).then(async response => {
                     const data = response.data
+                    await router.push({ name: 'dashboard' })
                     // 更新token信息
                     await dispatch('ibps/account/updataTokenInfo', data, { root: true })
                     // 更新用户信息
@@ -272,6 +267,9 @@ export default {
                     // await dispatch('ibps/system/set', null, { root: true })
                     //  清除菜单
                     await dispatch('ibps/menu/menusSet', null, { root: true })
+                    // 刷新页面重新获取信息
+                    location.reload()
+                    // await dispatch('load')
                     // 重置路由
                     // resetUrlRouter('/dashboard')
                     resolve(data)
@@ -285,10 +283,7 @@ export default {
          * 退出切换
          * @param {*} param0
          */
-        exitSwitchUser ({
-            state,
-            dispatch
-        }) {
+        exitSwitchUser ({ state, dispatch }) {
             return new Promise(async (resolve, reject) => {
                 const switchAccount = state.switchAccount
                 let token = getToken()
@@ -305,6 +300,7 @@ export default {
                     token: token
                 }).then(async response => {
                     const data = response.data
+                    await router.push({ name: 'dashboard' })
                     // 更新token信息
                     await dispatch('ibps/account/updataTokenInfo', data, { root: true })
                     // 更新用户信息
@@ -315,7 +311,8 @@ export default {
                     // await dispatch('ibps/system/set', null, { root: true })
                     //  清除菜单
                     await dispatch('ibps/menu/menusSet', null, { root: true })
-
+                    // 刷新页面重新获取信息
+                    location.reload()
                     // 重置路由
                     // resetUrlRouter('/')
                     resolve(data)
@@ -325,9 +322,7 @@ export default {
                 })
             })
         },
-        getRegister ({
-            state
-        }) {
+        getRegister ({ state }) {
             return new Promise(async (resolve, reject) => {
                 await getRegisterOpen().then(async response => {
                     const regOpen = response.data

+ 0 - 1
src/views/platform/cat/type/manage.vue

@@ -78,7 +78,6 @@ import FixHeight from '@/mixins/height'
 import ImportXml from './import-xml'
 import Sort from './sort'
 import Edit from './edit'
-import curdPost from '@/business/platform/form/utils/custom/joinCURD.js' // 增删改查规则
 
 export default {
     components: {

+ 134 - 0
src/views/system/auth/update.vue

@@ -0,0 +1,134 @@
+<template>
+    <el-dialog
+        :title="title"
+        :visible.sync="dialogVisible"
+        :close-on-click-modal="false"
+        :close-on-press-escape="false"
+        append-to-body
+        class="licence-dialog"
+        @close="closeDialog"
+    >
+        <el-form
+            ref="updateLicence"
+            v-loading="dialogLoading"
+            :model="formModel"
+            :rules="rules"
+            :element-loading-text="$t('common.loading')"
+            :label-width="formLabelWidth"
+            @submit.native.prevent
+        >
+            <el-form-item prop="licenceKey">
+                <el-input
+                    ref="input"
+                    v-model="formModel.licenceKey"
+                    type="textarea"
+                    rows="8"
+                    maxlength="4000"
+                    show-word-limit
+                    required
+                    placeholder="请填写开发方提供的许可证"
+                />
+            </el-form-item>
+        </el-form>
+        <div slot="footer" class="el-dialog--center">
+            <ibps-toolbar
+                :actions="toolbars"
+                @action-event="handleActionEvent"
+            />
+        </div>
+    </el-dialog>
+</template>
+
+<script>
+
+export default {
+    props: {
+        visible: {
+            type: Boolean,
+            default: false
+        },
+        title: {
+            type: String,
+            default: '更新许可证'
+        },
+        categoryKey: String
+    },
+    data () {
+        return {
+            formName: 'updateLicence',
+            formLabelWidth: '0px',
+            dialogVisible: this.visible,
+            dialogLoading: false,
+            formModel: {
+                licenceKey: ''
+            },
+            rules: {
+                licenceKey: [
+                    {
+                        required: true,
+                        message: this.$t('validate.required')
+                    }
+                ]
+            },
+            toolbars: [
+                { key: 'save', label: '更新' },
+                { key: 'cancel' }
+            ]
+        }
+    },
+    watch: {
+        visible: {
+            handler: function (val, oldVal) {
+                this.dialogVisible = this.visible
+            },
+            immediate: true
+        }
+    },
+    methods: {
+        handleActionEvent ({ key }) {
+            switch (key) {
+                case 'save':
+                    this.handleSave()
+                    break
+                case 'cancel':
+                    this.closeDialog()
+                    break
+                default:
+                    break
+            }
+        },
+        // 保存数据
+        handleSave () {
+            this.$refs[this.formName].validate(valid => {
+                if (valid) {
+                    this.saveData()
+                } else {
+                    this.$message.warning('请填写开发方提供的许可证信息!')
+                }
+            })
+        },
+        // 提交保存数据
+        saveData () {
+            this.$message.success('更新许可证成功,请重新登录!')
+            this.closeDialog()
+        },
+        // 关闭当前窗口
+        closeDialog () {
+            this.$emit('close', false)
+            this.$refs[this.formName].resetFields()
+        }
+    }
+}
+</script>
+<style lang="scss" scoped>
+    .licence-dialog {
+        ::v-deep .el-dialog {
+            margin-top: calc((100vh - 288px) / 2.5) !important;
+            .el-dialog__body {
+                .el-form {
+                    padding: 10px;
+                }
+            }
+        }
+    }
+</style>

+ 259 - 292
src/views/system/login/user-login.vue

@@ -9,7 +9,7 @@
         label-width="80"
         @submit.native.prevent
     >
-        <br/>
+        <br>
         <el-form-item label="账号" prop="username">
             <el-input
                 v-model="loginForm.username"
@@ -17,8 +17,8 @@
                 tabindex="1"
                 auto-complete="on"
                 prefix-icon="ibps-icon-user"
-                @keyup.enter.native="handleLogin"
                 style="width:75%;"
+                @keyup.enter.native="handleLogin"
             />
         </el-form-item>
         <el-tooltip
@@ -45,7 +45,7 @@
                         :class="passwordType === 'password' ? 'ibps-icon-eye-slash' : 'ibps-icon-eye'"
                         class="el-input__icon"
                         @click="showPassword"
-                    ></i>
+                    />
                 </el-input>
             </el-form-item>
         </el-tooltip>
@@ -64,7 +64,7 @@
                 </el-col>
                 <el-col :span="9">
                     <div class="login-code">
-                        <span v-if="code.type === 'text'" class="login-code-img" @click="refreshCode">{{ code.value}}</span>
+                        <span v-if="code.type === 'text'" class="login-code-img" @click="refreshCode">{{ code.value }}</span>
                         <img v-else :src="code.src" class="login-code-img" @click="refreshCode">
                     </div>
                 </el-col>
@@ -107,321 +107,290 @@
         </el-form-item>
 
         <el-button
-                :loading="loading"
-                type="primary"
-                class="login-submit"
-                @click.native.prevent="handleLogin"
-            >{{ $t('login.logIn') }}</el-button>
+            :loading="loading"
+            type="primary"
+            class="login-submit"
+            @click.native.prevent="handleLogin"
+        >{{ $t('login.logIn') }}</el-button>
+        <update-licence :visible="licenceFormVisible" @close="visible => licenceFormVisible = visible" />
     </el-form>
 </template>
 
 <script>
-    import { mapActions } from 'vuex'
-    import Utils from '@/utils/util'
-    import I18n from '@/utils/i18n'
-    import { SZG_getServerCertificate, SZG_genRandom, SZG_signData } from '@/api/oauth2/ca'
-    // import './xtxsync'
-    const loginForm = process.env.NODE_ENV === 'development'
-        ? {
-            username: 'jinyuan',
-            password: 'szjbd168',
-            captcha: '',
-            remember: true,
-            requestId: ''
-        } : {
-            username: '',
-            password: '',
-            captcha: '',
-            remember: true,
-            requestId: ''
-        }
+import { mapActions } from 'vuex'
+import Utils from '@/utils/util'
+import I18n from '@/utils/i18n'
+const loginForm = process.env.NODE_ENV === 'development'
+    ? {
+        username: 'jinyuan',
+        password: 'szjbd168',
+        captcha: '',
+        remember: true,
+        requestId: ''
+    } : {
+        username: '',
+        password: '',
+        captcha: '',
+        remember: true,
+        requestId: ''
+    }
 
-    const validateUsername = (rule, value, callback) => {
-        if (Utils.isEmpty(value)) {
-            return callback(new Error(I18n.t('login.usernameCorrect')))
-        }
-        callback()
+const validateUsername = (rule, value, callback) => {
+    if (Utils.isEmpty(value)) {
+        return callback(new Error(I18n.t('login.usernameCorrect')))
     }
-    const validateMobile = (rule, value, callback) => {
-        if (Utils.isEmpty(value)) {
-            return callback(new Error(I18n.t('手机号不能为空')))
+    callback()
+}
+const validateMobile = (rule, value, callback) => {
+    if (Utils.isEmpty(value)) {
+        return callback(new Error(I18n.t('手机号不能为空')))
+    } else {
+        const isPhone = /^1(3|4|5|6|7|8|9)\d{9}$/
+        if (value.length === 11) {
+            if (!isPhone.test(value)) {
+                return callback(new Error(I18n.t('请输入正确手机号')))
+            } else {
+                callback()
+            }
         } else {
-            const isPhone = /^1(3|4|5|6|7|8|9)\d{9}$/
-            if (value.length === 11) {
-                if (!isPhone.test(value)) {
-                    return callback(new Error(I18n.t('请输入正确手机号')))
-                } else {
-                    callback()
-                }
+            if (!isPhone.test(value)) {
+                return callback(new Error(I18n.t('请输入正确手机号')))
             } else {
-                if (!isPhone.test(value)) {
-                    return callback(new Error(I18n.t('请输入正确手机号')))
-                } else {
-                    return callback(new Error(I18n.t('请输入正确手机号长度')))
-                }
+                return callback(new Error(I18n.t('请输入正确手机号长度')))
             }
         }
     }
-    const validateCode = (rule, value, callback) => {
-        callback()
-        // if (this.code.value !== value) {
-        //   this.loginForm.captcha = ''
-        //   this.loadValidCode(false)
-        //   callback(new Error(I18n.t('login.codeCorrect')))
-        // } else {
-        //   callback()
-        // }
-    }
-
-    export default {
-        name: 'login-form',
-        data () {
-            return {
-                demoVar: '123',
-                enabledValidCode: false,
-                loginForm,
-                isRegOpen: false,
-                isTenantOpen: false,
-                validateMobile: validateMobile,
-                code: {
-                    src: '',
-                    value: '',
-                    len: 5,
-                    type: 'src'
-                },
-                loginRules: {
-                    username: [
-                        {
-                            required: true,
-                            trigger: 'blur',
-                            message: this.$t('login.usernameCorrect'),
-                            validator: validateUsername
-                        }
-                    ],
-                    password: [
-                        {
-                            required: true,
-                            message: this.$t('login.password'),
-                            trigger: 'blur'
-                        },
-                        {
-                            min: 1,
-                            message: this.$t('login.passwordCorrect'),
-                            trigger: 'blur'
-                        }
-                    ],
-                    captcha: [
-                        {
-                            required: true,
-                            message: this.$t('login.code'),
-                            trigger: 'blur'
-                        },
-                        {
-                            required: true,
-                            trigger: 'blur',
-                            validator: validateCode
-                        }
-                    ]
+}
+const validateCode = (rule, value, callback) => {
+    callback()
+    // if (this.code.value !== value) {
+    //   this.loginForm.captcha = ''
+    //   this.loadValidCode(false)
+    //   callback(new Error(I18n.t('login.codeCorrect')))
+    // } else {
+    //   callback()
+    // }
+}
 
-                },
-                passwordType: 'password',
-                capsTooltip: false,
-                loading: false
-            }
-        },
-        watch: {
-            isRegOpen: {
-                handler: function (val, oldVal) {
-                    if (val) {
-                        this.loginRules.username = [{
-                            required: true,
-                            trigger: 'blur',
-                            validator: validateMobile
-                        }]
-                    } else {
-                        this.loginRules.username = [{
-                            required: true,
-                            trigger: 'blur',
-                            validator: validateUsername
-                        }]
-                    }
-                },
-                immediate: true
-            }
-        },
-        created () {
-            this.initValidCode()
-            this.loadValidCode(true)
-            this.isRegisterOpen()
-        },
-        mounted () {
-            // 注销退出清空验证码
-            this.loginForm.captcha = ''
-            // 注销退出清空请求ID
-            this.loginForm.requestId = ''
-        },
-        methods: {
-            ...mapActions({
-                'login': 'ibps/account/login',
-                'getCaptcha': 'ibps/account/getCaptcha',
-                'getRegisterOpen': 'ibps/account/getRegisterOpen',
-                'getRegisterTenantOpen': 'ibps/saas/getRegisterTenantOpen'
-            }),
-            initValidCode () {
-                if (this.enabledValidCode) {
-                    this.loginRules.captcha[0]['required'] = true
-                    this.loginRules.captcha[1]['required'] = true
-                } else {
-                    this.loginRules.captcha[0]['required'] = false
-                    this.loginRules.captcha[1]['required'] = false
-                }
+export default {
+    name: 'login-form',
+    components: {
+        updateLicence: () => import('@/views/system/auth/update')
+    },
+    data () {
+        return {
+            enabledValidCode: false,
+            loginForm,
+            isRegOpen: false,
+            isTenantOpen: false,
+            validateMobile: validateMobile,
+            code: {
+                src: '',
+                value: '',
+                len: 5,
+                type: 'src'
             },
-            isRegisterOpen () {
-                this.getRegisterOpen().then((data) => {
-                    this.isRegOpen = data.data
-                }).catch((e) => { })
-                this.getRegisterTenantOpen().then((data) => {
-                    this.isTenantOpen = data.data
-                }).catch((e) => { })
-            },
-            // 获取验证码
-            loadValidCode (isBackfill) {
-                this.getCaptcha({ params: { requestId: this.loginForm.requestId } }).then((data) => {
-                    // 返回状态501,说明系统没有开启验证码
-                    if (data.state === 501) {
-                        this.enabledValidCode = false
-                    } else {
-                        this.enabledValidCode = true
-                        this.code.src = data.data
-                        this.loginForm.requestId = data.variables.requestId
+            loginRules: {
+                username: [
+                    {
+                        required: true,
+                        trigger: 'blur',
+                        message: this.$t('login.usernameCorrect'),
+                        validator: validateUsername
                     }
-                    this.initValidCode()
-                    if (isBackfill) {
-                        this.loginForm.code = this.code.value
+                ],
+                password: [
+                    {
+                        required: true,
+                        message: this.$t('login.password'),
+                        trigger: 'blur'
+                    },
+                    {
+                        min: 1,
+                        message: this.$t('login.passwordCorrect'),
+                        trigger: 'blur'
                     }
-                }).catch((e) => {
+                ],
+                captcha: [
+                    {
+                        required: true,
+                        message: this.$t('login.code'),
+                        trigger: 'blur'
+                    },
+                    {
+                        required: true,
+                        trigger: 'blur',
+                        validator: validateCode
+                    }
+                ]
 
-                })
             },
-            refreshCode () {
-                this.loadValidCode()
+            passwordType: 'password',
+            capsTooltip: false,
+            loading: false,
+            licenceFormVisible: false
+        }
+    },
+    watch: {
+        isRegOpen: {
+            handler: function (val, oldVal) {
+                if (val) {
+                    this.loginRules.username = [{
+                        required: true,
+                        trigger: 'blur',
+                        validator: validateMobile
+                    }]
+                } else {
+                    this.loginRules.username = [{
+                        required: true,
+                        trigger: 'blur',
+                        validator: validateUsername
+                    }]
+                }
             },
-            checkCapslock ({ shiftKey, key } = {}) {
-                if (key && key.length === 1) {
-                    if ((shiftKey && (key >= 'a' && key <= 'z')) || (!shiftKey && (key >= 'A' && key <= 'Z'))) {
-                        this.capsTooltip = true
-                    } else {
-                        this.capsTooltip = false
-                    }
+            immediate: true
+        }
+    },
+    created () {
+        this.initValidCode()
+        this.loadValidCode(true)
+        this.isRegisterOpen()
+    },
+    mounted () {
+        // 注销退出清空验证码
+        this.loginForm.captcha = ''
+        // 注销退出清空请求ID
+        this.loginForm.requestId = ''
+    },
+    methods: {
+        ...mapActions({
+            'login': 'ibps/account/login',
+            'getCaptcha': 'ibps/account/getCaptcha',
+            'getRegisterOpen': 'ibps/account/getRegisterOpen',
+            'getRegisterTenantOpen': 'ibps/saas/getRegisterTenantOpen'
+        }),
+        initValidCode () {
+            if (this.enabledValidCode) {
+                this.loginRules.captcha[0]['required'] = true
+                this.loginRules.captcha[1]['required'] = true
+            } else {
+                this.loginRules.captcha[0]['required'] = false
+                this.loginRules.captcha[1]['required'] = false
+            }
+        },
+        isRegisterOpen () {
+            this.getRegisterOpen().then((data) => {
+                this.isRegOpen = data.data
+            }).catch((e) => { })
+            this.getRegisterTenantOpen().then((data) => {
+                this.isTenantOpen = data.data
+            }).catch((e) => { })
+        },
+        // 获取验证码
+        loadValidCode (isBackfill) {
+            this.getCaptcha({ params: { requestId: this.loginForm.requestId }}).then((data) => {
+                // 返回状态501,说明系统没有开启验证码
+                if (data.state === 501) {
+                    this.enabledValidCode = false
+                } else {
+                    this.enabledValidCode = true
+                    this.code.src = data.data
+                    this.loginForm.requestId = data.variables.requestId
                 }
-                if (key === 'CapsLock' && this.capsTooltip === true) {
-                    this.capsTooltip = false
+                this.initValidCode()
+                if (isBackfill) {
+                    this.loginForm.code = this.code.value
                 }
-            },
-            showPassword () {
-                this.passwordType === '' ? (this.passwordType = 'password') : (this.passwordType = '')
-            },
-            forget () {
-                this.$router.replace('/forget')
-            },
-            tenantForget () {
-                this.$router.replace('/tenantForget')
-            },
-            register () {
-                this.$router.replace('/register')
-            },
-            tenantRegister () {
-                this.$router.replace('/tenantRegister')
-            },
-            handleLogin () {
-                this.$refs.loginForm.validate(valid => {
-                    if (valid) {
-                        this.loading = true
-                        const loading = this.$loading({
-                            lock: true,
-                            text: this.$t('common.loading'),
-                            background: 'rgba(0, 0, 0, 0.7)'
-                        })
-                        this.login({
-                            form: this.loginForm
-                        }).then((data) => {
-                            localStorage.setItem('statistic', data.statistic)
-                            // 更新路由 尝试去获取 cookie 里保存的需要重定向的页面完整地址
-                            const redirect = this.$route.query.redirect
-
-                            if (redirect && redirect !== '/refresh') {
-                              if(data && (data.statistic === 'isMaster' ||data.statistic === 'isCharger')){
-                                    // 重定向到开始路径
-                                    this.$router.replace('/dashboard')
-                                } else {
-                                    this.$router.replace('/')
-                                }
-                            } else {
-                               if(data && (data.statistic === 'isMaster' ||data.statistic === 'isCharger')){
-                                    // 重定向到开始路径
-                                    this.$router.replace('/dashboard')
-                                } else {
-                                    this.$router.replace('/')
-                                }
-                            }
+            }).catch((e) => {
 
-                            // 延迟10秒关闭遮盖层
-                            setTimeout(() => {
-                                this.loading = false
-                                loading.close()
-                            }, 1000)
-                        }).catch((err) => {
-                            // 验证码错误自动清空&密码输入错误3次后触发验证码填写模块
-                            if (err && err.state === 6020104) {
-                                this.loginForm.captcha = ''
-                                this.enabledValidCode = true
-                                this.refreshCode()
-                            }
-                            // 有错误状态开启验证码需要刷新验证码
-                            if (err && err.state && this.enabledValidCode) {
-                                this.loginForm.captcha = ''
-                                this.refreshCode()
-                            }
+            })
+        },
+        refreshCode () {
+            this.loadValidCode()
+        },
+        checkCapslock ({ shiftKey, key } = {}) {
+            if (key && key.length === 1) {
+                if ((shiftKey && (key >= 'a' && key <= 'z')) || (!shiftKey && (key >= 'A' && key <= 'Z'))) {
+                    this.capsTooltip = true
+                } else {
+                    this.capsTooltip = false
+                }
+            }
+            if (key === 'CapsLock' && this.capsTooltip === true) {
+                this.capsTooltip = false
+            }
+        },
+        showPassword () {
+            this.passwordType === '' ? (this.passwordType = 'password') : (this.passwordType = '')
+        },
+        forget () {
+            this.$router.replace('/forget')
+        },
+        tenantForget () {
+            this.$router.replace('/tenantForget')
+        },
+        register () {
+            this.$router.replace('/register')
+        },
+        tenantRegister () {
+            this.$router.replace('/tenantRegister')
+        },
+        handleLogin () {
+            this.$refs.loginForm.validate(valid => {
+                if (!valid) {
+                    this.$message.closeAll()
+                    this.$message({
+                        message: this.$t('common.dialog.saveError'),
+                        type: 'warning'
+                    })
+                    return false
+                }
+                this.loading = true
+                const loading = this.$loading({
+                    lock: true,
+                    text: this.$t('common.loading'),
+                    background: 'rgba(0, 0, 0, 0.7)'
+                })
+                this.login({ form: this.loginForm }).then(data => {
+                    localStorage.setItem('statistic', data.statistic)
+                    // 更新路由 尝试去获取 cookie 里保存的需要重定向的页面完整地址
+                    const redirect = this.$route.query.redirect
+                    const { overtime } = data.licenceData
+                    if (overtime) {
+                        this.$message.error('许可证不在使用期限!请更新')
+                        // 许可证过期,前台登出
+                        this.$store.dispatch('ibps/account/fedLogout').then(() => {
+                            this.licenceFormVisible = true
                             this.loading = false
                             loading.close()
                         })
                     } else {
-                        this.$message.closeAll()
-                        this.$message({
-                            message: this.$t('common.dialog.saveError'),
-                            type: 'warning'
-                        })
-                        return false
+                        this.$router.replace('/')
+                        // 延迟1秒关闭遮盖层
+                        setTimeout(() => {
+                            this.loading = false
+                            loading.close()
+                        }, 1000)
                     }
+                }).catch((err) => {
+                    // 验证码错误自动清空&密码输入错误5次后触发验证码填写模块
+                    if (err && err.state === 6020104) {
+                        this.loginForm.captcha = ''
+                        this.enabledValidCode = true
+                        this.refreshCode()
+                    }
+                    // 有错误状态开启验证码需要刷新验证码
+                    if (err && err.state && this.enabledValidCode) {
+                        this.loginForm.captcha = ''
+                        this.refreshCode()
+                    }
+                    this.loading = false
+                    loading.close()
                 })
-            },
-            // ca认证
-            caAuth () {
-                SZG_getServerCertificate().then(res1 => {
-                    let data1 = res1.variables && res1.variables.data
-                    console.log(data1)
-                    SZG_genRandom().then(res2 => {
-                        let data2 = res2.variables && res2.variables.data
-                        console.log(data2)
-                        if (data2) {
-                            SZG_signData({ inData: data2 }).then(res3 => {
-                                let data3 = res3.variables && res3.variables.data
-                                console.log(res3, data3)
-                            })
-                        }
-                    })
-                }).catch(err => {
-                    console.log('获取服务器证书失败!')
-                })
-                // 获取用户列表,并截取用户姓名显示到登录框中
-                this.loginForm.username = xtxsync.SOF_GetUserList()
-            },
-            // 验签
-            caVerify () {
-                xtxsync.SOF_VerifySignedData()
-            }
+            })
         }
     }
+}
 </script>
 
 <style lang="less" scoped>
@@ -429,8 +398,6 @@
         margin-bottom: 22px !important;
     }
 
-
-
     /deep/ .el-form-item--small .el-form-item__error{
         padding-top: 0px;
         line-height: 14px;