优化登录和首页
This commit is contained in:
@@ -20,50 +20,9 @@ export function login(parameter) {
|
||||
})
|
||||
}
|
||||
|
||||
export function phoneLogin(parameter) {
|
||||
return axios({
|
||||
url: '/sys/phoneLogin',
|
||||
method: 'post',
|
||||
data: parameter
|
||||
})
|
||||
}
|
||||
|
||||
export function getSmsCaptcha(parameter) {
|
||||
return axios({
|
||||
url: api.SendSms,
|
||||
method: 'post',
|
||||
data: parameter
|
||||
})
|
||||
}
|
||||
|
||||
export function getInfo() {
|
||||
return axios({
|
||||
url: '/api/user/info',
|
||||
method: 'get',
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=UTF-8'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function logout() {
|
||||
return axios({
|
||||
url: '/user/logout',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 第三方登录
|
||||
* @param token
|
||||
* @returns {*}
|
||||
*/
|
||||
export function thirdLogin(token) {
|
||||
return axios({
|
||||
url: `/thirdLogin/getLoginUser/${token}`,
|
||||
method: 'get',
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=UTF-8'
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import Vue from 'vue'
|
||||
import { login, logout, phoneLogin, thirdLogin } from "@/api/login"
|
||||
import { ACCESS_TOKEN, USER_NAME,USER_INFO,USER_AUTH,SYS_BUTTON_AUTH,UI_CACHE_DB_DICT_DATA,USER_ID,USER_LOGIN_NAME } from "@/store/mutation-types"
|
||||
import { login, logout } from "@/api/login"
|
||||
import { ACCESS_TOKEN, USER_NAME,USER_INFO,UI_CACHE_DB_DICT_DATA,USER_ID,USER_LOGIN_NAME } from "@/store/mutation-types"
|
||||
import { welcome } from "@/utils/util"
|
||||
import { queryPermissionsByUser } from '@/api/api'
|
||||
import { getAction } from '@/api/manage'
|
||||
@@ -70,16 +70,11 @@ const user = {
|
||||
const result = response.data
|
||||
Vue.ls.set(USER_ID, result.user.id, 7 * 24 * 60 * 60 * 1000);
|
||||
Vue.ls.set(USER_LOGIN_NAME, result.user.loginName, 7 * 24 * 60 * 60 * 1000);
|
||||
//const userInfo = result.userInfo
|
||||
Vue.ls.set(ACCESS_TOKEN, result.token, 1 * 24 * 60 * 60 * 1000)
|
||||
// Vue.ls.set(USER_NAME, userInfo.username, 7 * 24 * 60 * 60 * 1000)
|
||||
Vue.ls.set(USER_INFO, result.user, 7 * 24 * 60 * 60 * 1000)
|
||||
//Vue.ls.set(UI_CACHE_DB_DICT_DATA, result.sysAllDictItems, 7 * 24 * 60 * 60 * 1000)
|
||||
commit('SET_TOKEN', result.token)
|
||||
}
|
||||
commit('SET_INFO', userInfo)
|
||||
//commit('SET_NAME', { username: userInfo.username,realname: userInfo.realname, welcome: welcome() })
|
||||
//commit('SET_AVATAR', userInfo.avatar)
|
||||
resolve(response)
|
||||
}else{
|
||||
reject(response)
|
||||
@@ -89,30 +84,6 @@ const user = {
|
||||
})
|
||||
})
|
||||
},
|
||||
//手机号登录
|
||||
PhoneLogin({ commit }, userInfo) {
|
||||
return new Promise((resolve, reject) => {
|
||||
phoneLogin(userInfo).then(response => {
|
||||
if(response.code =='200'){
|
||||
const result = response.result
|
||||
const userInfo = result.userInfo
|
||||
Vue.ls.set(ACCESS_TOKEN, result.token, 7 * 24 * 60 * 60 * 1000)
|
||||
Vue.ls.set(USER_NAME, userInfo.username, 7 * 24 * 60 * 60 * 1000)
|
||||
Vue.ls.set(USER_INFO, userInfo, 7 * 24 * 60 * 60 * 1000)
|
||||
Vue.ls.set(UI_CACHE_DB_DICT_DATA, result.sysAllDictItems, 7 * 24 * 60 * 60 * 1000)
|
||||
commit('SET_TOKEN', result.token)
|
||||
commit('SET_INFO', userInfo)
|
||||
commit('SET_NAME', { username: userInfo.username,realname: userInfo.realname, welcome: welcome() })
|
||||
commit('SET_AVATAR', userInfo.avatar)
|
||||
resolve(response)
|
||||
}else{
|
||||
reject(response)
|
||||
}
|
||||
}).catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
},
|
||||
// 获取用户信息
|
||||
GetPermissionList({ commit }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -120,24 +91,7 @@ const user = {
|
||||
let params = {pNumber:0,userId: Vue.ls.get(USER_ID)};
|
||||
queryPermissionsByUser(params).then(response => {
|
||||
const menuData = response;
|
||||
// const authData = response.result.auth;
|
||||
// const allAuthData = response.result.allAuth;
|
||||
//Vue.ls.set(USER_AUTH,authData);
|
||||
// sessionStorage.setItem(USER_AUTH,JSON.stringify(authData));
|
||||
// sessionStorage.setItem(SYS_BUTTON_AUTH,JSON.stringify(allAuthData));
|
||||
if (menuData && menuData.length > 0) {
|
||||
//update--begin--autor:qinfeng-----date:20200109------for:JEECG-63 一级菜单的子菜单全部是隐藏路由,则一级菜单不显示------
|
||||
// menuData.forEach((item, index) => {
|
||||
// if (item["children"]) {
|
||||
// let hasChildrenMenu = item["children"].filter((i) => {
|
||||
// return !i.hidden || i.hidden == false
|
||||
// })
|
||||
// if (hasChildrenMenu == null || hasChildrenMenu.length == 0) {
|
||||
// item["hidden"] = true
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
//update--end--autor:qinfeng-----date:20200109------for:JEECG-63 一级菜单的子菜单全部是隐藏路由,则一级菜单不显示------
|
||||
commit('SET_PERMISSIONLIST', menuData)
|
||||
} else {
|
||||
reject('getPermissionList: permissions must be a non-null array !')
|
||||
@@ -158,13 +112,8 @@ const user = {
|
||||
Vue.ls.remove(USER_ID)
|
||||
Vue.ls.remove(USER_LOGIN_NAME)
|
||||
Vue.ls.remove(USER_INFO)
|
||||
//Vue.ls.remove(ACCESS_TOKEN)
|
||||
Vue.ls.remove(UI_CACHE_DB_DICT_DATA)
|
||||
//console.log('logoutToken: '+ logoutToken)
|
||||
logout().then(() => {
|
||||
//let sevice = "http://"+window.location.host+"/";
|
||||
//let serviceUrl = encodeURIComponent(sevice);
|
||||
//window.location.href = window._CONFIG['casPrefixUrl']+"/logout?service="+serviceUrl;
|
||||
resolve()
|
||||
}).catch(() => {
|
||||
resolve()
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<a-row :gutter="24">
|
||||
<a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
|
||||
<chart-card :loading="loading" title="今日累计销售">
|
||||
<a-tooltip title="指标说明" slot="action">
|
||||
<a-tooltip title="统计今日零售和销售单据数据" slot="action">
|
||||
<a-icon type="info-circle-o" />
|
||||
</a-tooltip>
|
||||
<head-info :content="statistics.todaySale"></head-info>
|
||||
@@ -11,7 +11,7 @@
|
||||
</a-col>
|
||||
<a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
|
||||
<chart-card :loading="loading" title="本月累计销售">
|
||||
<a-tooltip title="指标说明" slot="action">
|
||||
<a-tooltip title="统计本月零售和销售单据数据" slot="action">
|
||||
<a-icon type="info-circle-o" />
|
||||
</a-tooltip>
|
||||
<head-info :content="statistics.thisMonthSale"></head-info>
|
||||
@@ -19,7 +19,7 @@
|
||||
</a-col>
|
||||
<a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
|
||||
<chart-card :loading="loading" title="今日累计采购">
|
||||
<a-tooltip title="指标说明" slot="action">
|
||||
<a-tooltip title="统计今日采购单据数据" slot="action">
|
||||
<a-icon type="info-circle-o" />
|
||||
</a-tooltip>
|
||||
<head-info :content="statistics.todayBuy"></head-info>
|
||||
@@ -27,7 +27,7 @@
|
||||
</a-col>
|
||||
<a-col :sm="24" :md="12" :xl="6" :style="{ marginBottom: '24px' }">
|
||||
<chart-card :loading="loading" title="本月累计采购">
|
||||
<a-tooltip title="指标说明" slot="action">
|
||||
<a-tooltip title="统计本月采购单据数据" slot="action">
|
||||
<a-icon type="info-circle-o" />
|
||||
</a-tooltip>
|
||||
<head-info :content="statistics.thisMonthBuy"></head-info>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<a-form-item>
|
||||
<a-input
|
||||
size="large"
|
||||
v-decorator="['username',{initialValue:'', rules: validatorRules.username.rules}]"
|
||||
v-decorator="['loginName',{initialValue:'', rules: validatorRules.loginName.rules}]"
|
||||
type="text"
|
||||
placeholder="请输入帐户名">
|
||||
<a-icon slot="prefix" type="user" :style="{ color: 'rgba(0,0,0,.25)' }"/>
|
||||
@@ -90,7 +90,7 @@
|
||||
smsSendBtn: false,
|
||||
},
|
||||
validatorRules:{
|
||||
username:{rules: [{ required: true, message: '请输入用户名!'},{validator: this.handleUsernameOrEmail}]},
|
||||
loginName:{rules: [{ required: true, message: '请输入用户名!'},{validator: this.handleLoginName}]},
|
||||
password:{rules: [{ required: true, message: '请输入密码!',validator: 'click'}]}
|
||||
},
|
||||
verifiedCode:"",
|
||||
@@ -112,30 +112,9 @@
|
||||
this.getRouterData();
|
||||
},
|
||||
methods: {
|
||||
...mapActions([ "Login", "Logout","PhoneLogin","ThirdLogin" ]),
|
||||
//第三方登录
|
||||
onThirdLogin(source){
|
||||
let url = window._CONFIG['domianURL']+`/thirdLogin/render/${source}`
|
||||
window.open(url, `login ${source}`, 'height=500, width=500, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no')
|
||||
let that = this;
|
||||
let receiveMessage = function(event){
|
||||
var origin = event.origin
|
||||
console.log("origin",origin);
|
||||
|
||||
let token = event.data
|
||||
console.log("event.data",token)
|
||||
that.ThirdLogin(token).then(res=>{
|
||||
if(res.success){
|
||||
that.loginSuccess()
|
||||
}else{
|
||||
that.requestFailed(res);
|
||||
}
|
||||
})
|
||||
}
|
||||
window.addEventListener("message", receiveMessage, false);
|
||||
},
|
||||
...mapActions([ "Login", "Logout" ]),
|
||||
// handler
|
||||
handleUsernameOrEmail (rule, value, callback) {
|
||||
handleLoginName (rule, value, callback) {
|
||||
const regex = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
|
||||
if (regex.test(value)) {
|
||||
this.loginType = 0
|
||||
@@ -144,27 +123,17 @@
|
||||
}
|
||||
callback()
|
||||
},
|
||||
handleTabClick (key) {
|
||||
this.customActiveKey = key
|
||||
// this.form.resetFields()
|
||||
},
|
||||
handleSubmit () {
|
||||
let that = this
|
||||
let loginParams = {};
|
||||
that.loginBtn = true;
|
||||
// 使用账户密码登陆
|
||||
if (that.customActiveKey === 'tab1') {
|
||||
that.form.validateFields([ 'username', 'password','inputCode', 'rememberMe' ], { force: true }, (err, values) => {
|
||||
that.form.validateFields([ 'loginName', 'password', 'rememberMe' ], { force: true }, (err, values) => {
|
||||
if (!err) {
|
||||
loginParams.loginName = values.username
|
||||
// update-begin- --- author:scott ------ date:20190805 ---- for:密码加密逻辑暂时注释掉,有点问题
|
||||
//loginParams.password = md5(values.password)
|
||||
//loginParams.password = encryption(values.password,that.encryptedString.key,that.encryptedString.iv)
|
||||
loginParams.loginName = values.loginName
|
||||
loginParams.password = md5(values.password)
|
||||
//loginParams.remember_me = values.rememberMe
|
||||
// update-begin- --- author:scott ------ date:20190805 ---- for:密码加密逻辑暂时注释掉,有点问题
|
||||
//loginParams.captcha = that.inputCodeContent
|
||||
//loginParams.checkKey = that.currdatetime
|
||||
console.log("登录参数",loginParams)
|
||||
that.Login(loginParams).then((res) => {
|
||||
this.departConfirm(res)
|
||||
@@ -175,28 +144,9 @@
|
||||
that.loginBtn = false;
|
||||
}
|
||||
})
|
||||
// 使用手机号登陆
|
||||
} else {
|
||||
that.form.validateFields([ 'mobile', 'captcha', 'rememberMe' ], { force: true }, (err, values) => {
|
||||
if (!err) {
|
||||
loginParams.mobile = values.mobile
|
||||
loginParams.captcha = values.captcha
|
||||
loginParams.remember_me = values.rememberMe
|
||||
that.PhoneLogin(loginParams).then((res) => {
|
||||
console.log(res.result);
|
||||
this.departConfirm(res)
|
||||
}).catch((err) => {
|
||||
that.requestFailed(err);
|
||||
})
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
loginSuccess () {
|
||||
// update-begin- author:sunjianlei --- date:20190812 --- for: 登录成功后不解除禁用按钮,防止多次点击
|
||||
// this.loginBtn = false
|
||||
// update-end- author:sunjianlei --- date:20190812 --- for: 登录成功后不解除禁用按钮,防止多次点击
|
||||
this.$router.push({ path: "/dashboard/analysis" })
|
||||
this.$notification.success({
|
||||
message: '欢迎',
|
||||
@@ -271,6 +221,7 @@
|
||||
this.encryptedString = encryptedString;
|
||||
}
|
||||
},
|
||||
//加载商品属性
|
||||
initMPropertyShort(){
|
||||
let mPropertyListShort = '';
|
||||
let params = {};
|
||||
|
||||
@@ -78,7 +78,6 @@
|
||||
|
||||
<script>
|
||||
import {mixinDevice} from '@/utils/mixin.js'
|
||||
import {getSmsCaptcha} from '@/api/login'
|
||||
import {getAction, postAction} from '@/api/manage'
|
||||
import {checkOnlyUser} from '@/api/api'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user