Commit 4a50ff55 by Denglingling

1、完善自动登录;2、完善pc端配置菜单权限,APP显示动态菜单;

(cherry picked from commit b1e53680)
parent 2335cdd0
...@@ -18,7 +18,7 @@ import FillUnitPricePage from './containers/equipConsu/module/FillUnitPricePage' ...@@ -18,7 +18,7 @@ import FillUnitPricePage from './containers/equipConsu/module/FillUnitPricePage'
import QuickOrderPage from './containers/quickOrder/QuickOrderPage'; import QuickOrderPage from './containers/quickOrder/QuickOrderPage';
import TransOrderPage from './containers/transOrder/TransOrderPage'; import TransOrderPage from './containers/transOrder/TransOrderPage';
import TransSearchPage from './containers/transOrder/module/TransSearchPage'; import TransSearchPage from './containers/transOrder/module/TransSearchPage';
// import HistoricalOrderPage from './containers/historicalOrder/HistoricalOrderPage'; import HistoricalOrderPage from './containers/historicalOrder/HistoricalOrderPage';
import LineOrderPage from './containers/historicalOrder/module/LineOrderPage'; import LineOrderPage from './containers/historicalOrder/module/LineOrderPage';
import SubSuccPage from './containers/common/SubSuccPage'; import SubSuccPage from './containers/common/SubSuccPage';
...@@ -35,7 +35,7 @@ const Router = createAppContainer(createStackNavigator({ ...@@ -35,7 +35,7 @@ const Router = createAppContainer(createStackNavigator({
QuickOrderPage: {screen: QuickOrderPage}, QuickOrderPage: {screen: QuickOrderPage},
TransOrderPage: {screen: TransOrderPage}, TransOrderPage: {screen: TransOrderPage},
TransSearchPage: {screen: TransSearchPage}, TransSearchPage: {screen: TransSearchPage},
// HistoricalOrderPage: {screen: HistoricalOrderPage}, HistoricalOrderPage: {screen: HistoricalOrderPage},
LineOrderPage: {screen: LineOrderPage}, LineOrderPage: {screen: LineOrderPage},
SubSuccPage: {screen: SubSuccPage} SubSuccPage: {screen: SubSuccPage}
}, { }, {
......
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
AUTO_LOGIN_FAILURE, AUTO_LOGIN_FAILURE,
SET_DOMAIN_CONFIGURATE SET_DOMAIN_CONFIGURATE
} from '../base/ActionTypes'; } from '../base/ActionTypes';
import { PostRequest,GetRequest } from '../network/RequestUtils'; import { PostRequest } from '../network/RequestUtils';
import { show } from '../utils/Utils'; import { show } from '../utils/Utils';
export function requestLogin(params) { export function requestLogin(params) {
...@@ -15,16 +15,17 @@ export function requestLogin(params) { ...@@ -15,16 +15,17 @@ export function requestLogin(params) {
dispatch(logining()); dispatch(logining());
let {global_domain_config} = getState().login let {global_domain_config} = getState().login
PostRequest(global_domain_config, '/access_token/password/search?app_code=MOBILE', params).then((res) => { PostRequest(global_domain_config, '/access_token/password/search?app_code=MOBILE', params).then((res) => {
// console.log('res-------', res)
if(res.error_code === 0){ if(res.error_code === 0){
// if(res.functions && res.functions.length) { if(res.functions && res.functions.length) {
// show('登录成功');
// dispatch(loginSuccess(res, params.data.user_name, params.data.user_password));
// } else {
// show(`当前用户没有菜单权限,\n请联系管理员配置!`)
// dispatch(loginFailure())
// }
show('登录成功'); show('登录成功');
dispatch(loginSuccess(res, params.data.user_name, params.data.user_password)); dispatch(loginSuccess(res, params.data.user_name, params.data.user_password));
} else {
show(`当前用户没有菜单权限,\n请联系管理员配置!`)
dispatch(loginFailure())
}
// show('登录成功');
// dispatch(loginSuccess(res, params.data.user_name, params.data.user_password));
}else { }else {
let error_msg = res.error_msg || res.message let error_msg = res.error_msg || res.message
if(res.error_code == -3) { if(res.error_code == -3) {
...@@ -87,13 +88,13 @@ export function autoLogin(params) { ...@@ -87,13 +88,13 @@ export function autoLogin(params) {
PostRequest(global_domain_config, '/access_token/password/search?app_code=MOBILE', params).then((res) => { PostRequest(global_domain_config, '/access_token/password/search?app_code=MOBILE', params).then((res) => {
if(res.error_code === 0){ if(res.error_code === 0){
// console.warn('auto------',res); // console.warn('auto------',res);
// if(res.functions && res.functions.length) { if(res.functions && res.functions.length) {
// dispatch(autoLoginSuccess(res)); dispatch(autoLoginSuccess(res));
// } else { } else {
// show(`当前用户没有菜单权限,\n请联系管理员配置!`) show(`当前用户没有菜单权限,\n请联系管理员配置!`)
// dispatch(autoLoginFailure()) dispatch(autoLoginFailure())
// } }
dispatch(autoLoginSuccess(res)) // dispatch(autoLoginSuccess(res))
}else { }else {
console.warn(res.error_msg); console.warn(res.error_msg);
show(res.error_msg); show(res.error_msg);
......
...@@ -8,7 +8,6 @@ import { ...@@ -8,7 +8,6 @@ import {
TouchableOpacity, TouchableOpacity,
Clipboard Clipboard
} from 'react-native'; } from 'react-native';
import { connect } from 'react-redux';
import HeadBackItem from './HeadBackItem'; import HeadBackItem from './HeadBackItem';
import { import {
promary_color, promary_color,
......
...@@ -48,8 +48,6 @@ class LoginPage extends Component{ ...@@ -48,8 +48,6 @@ class LoginPage extends Component{
} }
componentDidMount() { componentDidMount() {
// this.subAutoLogin()
SplashScreen.hide() //关闭启动屏幕 SplashScreen.hide() //关闭启动屏幕
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
this.getLocalUserName() this.getLocalUserName()
...@@ -86,14 +84,19 @@ class LoginPage extends Component{ ...@@ -86,14 +84,19 @@ class LoginPage extends Component{
} }
// 获取当前用户名 ??? // 获取当前用户名
getLocalUserName() { getLocalUserName() {
let {username} = this.props let { username, password } = this.props
if(username) { if(username) {
this.setState({ this.setState({
username username
}) })
} }
if(password) {
this.setState({
password
})
}
} }
// 判断是否打开域名弹窗 // 判断是否打开域名弹窗
...@@ -135,18 +138,15 @@ class LoginPage extends Component{ ...@@ -135,18 +138,15 @@ class LoginPage extends Component{
// this.enterHomePage() // this.enterHomePage()
let {username, password, isSubLoding} = this.state let {username, password, isSubLoding} = this.state
// let {global_domain_config} = this.props // let {global_domain_config} = this.props
// if(global_domain_config.includes("obs.uat.guke.tech")) { // if(global_domain_config.includes("obs.uat.guke.tech")) {
// show('请修改正确域名') // show('请修改正确域名')
// return // return
// } // }
if (!isSubLoding) { if (!isSubLoding) {
if (isEmpty(username)) { if(!this.judgeRequireIsEmpty()) {
show('请输入用户名')
return
}
if(isEmpty(password)) {
show('请输入密码')
return return
} }
let params = { let params = {
...@@ -162,25 +162,36 @@ class LoginPage extends Component{ ...@@ -162,25 +162,36 @@ class LoginPage extends Component{
// 自动登录 // 自动登录
subAutoLogin() { subAutoLogin() {
let {username, password, autoLogin} = this.props // let { autoLogin } = this.props
this.setState({ // let { username, password } = this.state
username, // if(!this.judgeRequireIsEmpty()) {
password // return
}) // }
// let params = {
// data:{
// grant_type: "PASSWORD",
// user_name: username,
// user_password: password
// }
// }
// autoLogin(params)
}
// 判断用户名、密码是否填写
judgeRequireIsEmpty() {
let flag = true
let {username, password} = this.state
if (isEmpty(username)) { if (isEmpty(username)) {
return show('请输入用户名')
flag = false
return flag
} }
if(isEmpty(password)) { if(isEmpty(password)) {
return show('请输入密码')
} flag = false
let params = { return flag
data:{
grant_type: "PASSWORD",
user_name: username,
user_password: password
}
} }
autoLogin(params) return flag
} }
// 用户名改变 // 用户名改变
......
...@@ -159,6 +159,60 @@ export function cloneObject(obj) { ...@@ -159,6 +159,60 @@ export function cloneObject(obj) {
return JSON.parse(JSON.stringify(obj)) return JSON.parse(JSON.stringify(obj))
} }
/**
* 引用数组升序排序
* @param {Array} arr 原数组
* @param {String} typeName 排序字段名
*/
export function ascArray(arr, typeName) {
if(!arr.length) {
return
}
arr.sort((obj1, obj2) => {
return obj1[typeName] - obj2[typeName]
})
return arr
}
/**
* 引用数组降序排序
* @param {Array} arr 原数组
* @param {String} typeName 排序字段名
*/
export function descArray(arr, typeName) {
if(!arr.length) {
return
}
arr.sort((obj1, obj2) => {
return obj2[typeName] - obj1[typeName]
})
return arr
}
/**
* 引用数组每一个对象,指定字段名及子项指定字段,的排序字段,都进行排序
* 如:arr= [{id:2, name: 'xiaomi', child: [{ id:8, name: 'caiyan', child: [] }, { id:6, name: 'change', child: [] }, { id:1, name: 'wangsan', child: [] }]
* @param {Array} arr 原数组 如:arr
* @param {String} speciField 指定字段 如:'child'
* @param {String} typeName 排序字段名 如:'id'
* @param {String} sortType 排序方式 默认 'asc', 降序'desc'
*/
export function referenceArrSort(arr, speciField, typeName, sortType) {
if(!arr.length) {
return
}
if(sortType == 'desc') {
descArray(arr, typeName)
} else {
ascArray(arr, typeName)
}
arr = arr.map(item => {
if(item[speciField] && item[speciField].length) {
referenceArrSort(item[speciField], speciField, typeName, sortType )
}
return item
})
return arr
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment