✨ feat(登录登出): 已完成用户使用账号密码登录登出
This commit is contained in:
@@ -19,7 +19,7 @@ const INIT = {
|
||||
shopCount: Taro.getStorageSync(STORAGE_SHOPCOUNT)?JSON.parse(Taro.getStorageSync(STORAGE_SHOPCOUNT)).shopCount:0,
|
||||
}
|
||||
|
||||
export default function counter (state = INIT, action: Action) {
|
||||
export default (state = INIT, action: Action) => {
|
||||
const {type, data} = action
|
||||
switch (type) {
|
||||
case SET_SHOPCOUNT:
|
||||
@@ -31,4 +31,4 @@ export default function counter (state = INIT, action: Action) {
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { DataParam as userInfoParam } from './userInfo';
|
||||
import { DataParam as commonDataParam } from './commonData';
|
||||
import { TabBarData as tabbarDataParam } from './tabBar';
|
||||
type Params = {
|
||||
userInfo: userInfoParam
|
||||
userInfoData: userInfoParam
|
||||
commonData: commonDataParam
|
||||
tabBarData: tabbarDataParam
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { combineReducers } from 'redux'
|
||||
import userInfo from './userInfo'
|
||||
import userInfoData from './userInfo'
|
||||
import commonData from './commonData'
|
||||
import tabBarReducer from './tabBar'
|
||||
|
||||
export type Reducers = {
|
||||
userInfo: typeof userInfo
|
||||
userInfoData: typeof userInfoData
|
||||
commonData: typeof commonData
|
||||
tabBarData: typeof tabBarReducer
|
||||
}
|
||||
@@ -12,7 +12,7 @@ export type Reducers = {
|
||||
export type ReducersKey = keyof Reducers
|
||||
|
||||
export default combineReducers<Reducers>({
|
||||
userInfo,
|
||||
userInfoData,
|
||||
commonData,
|
||||
tabBarData: tabBarReducer,
|
||||
})
|
||||
|
||||
+55
-68
@@ -1,31 +1,18 @@
|
||||
|
||||
import Taro from '@tarojs/taro'
|
||||
import {
|
||||
SET_USERINFO,
|
||||
SET_ADMINUSERINFO,
|
||||
SET_TOKEN,
|
||||
SET_SESSIONKEY,
|
||||
SET_SORTCODE,
|
||||
CLEAR_TOKEN,
|
||||
CLEAR_USERINFO,
|
||||
CLEAR_SESSIONKEY,
|
||||
CLEAR_ADMINUSERINFO,
|
||||
CLEAR_SORTCODE,
|
||||
LOGIN_STATUS
|
||||
} from '../constants/userInfo'
|
||||
import { UserInfoActionType } from '../constants/userInfo'
|
||||
|
||||
export type UserParam = {
|
||||
nickName?:string,
|
||||
phone?:string,
|
||||
avatarUrl?:string,
|
||||
city?: string,
|
||||
country?: string,
|
||||
province?: string,
|
||||
gender?: number,
|
||||
language?: string,
|
||||
timestamp?: number,
|
||||
physical_warehouse?: number,
|
||||
physical_warehouse_name?: string,
|
||||
department_code?: string
|
||||
department_id?: string
|
||||
department_name?: string
|
||||
physical_warehouse?: number
|
||||
physical_warehouse_name?: string
|
||||
token?: string
|
||||
user_code?: number
|
||||
user_id?: string
|
||||
user_name?: number
|
||||
avatar_url?: string
|
||||
}
|
||||
|
||||
export type UserAdminParam = {
|
||||
@@ -38,8 +25,8 @@ export type UserAdminParam = {
|
||||
user_id?: number,
|
||||
user_name?: string,
|
||||
wechat_user_open_id?: number
|
||||
is_authorize_name?: false|true,
|
||||
is_authorize_phone?: false|true,
|
||||
is_authorize_name?: boolean,
|
||||
is_authorize_phone?: boolean,
|
||||
phone?:string,
|
||||
authentication_status?:number,
|
||||
authentication_status_name: string,
|
||||
@@ -64,11 +51,11 @@ export type DataParam = {
|
||||
userInfo: UserParam,
|
||||
adminUserInfo: UserAdminParam,
|
||||
sort_code: SortCodeParam
|
||||
logingStatus?: false //登录状态 true 正在登录
|
||||
logingStatus?: boolean //登录状态 true 正在登录
|
||||
}
|
||||
|
||||
type Action = {
|
||||
type?: string,
|
||||
export type UserInfoAction = {
|
||||
type: UserInfoActionType
|
||||
data?: DataParam
|
||||
}
|
||||
|
||||
@@ -82,42 +69,42 @@ const INIT_USER = {
|
||||
logingStatus: false
|
||||
}
|
||||
|
||||
export default function counter (state = INIT_USER, action: Action) {
|
||||
const {type, data} = action
|
||||
switch (type) {
|
||||
case SET_USERINFO:
|
||||
Taro.setStorageSync('userInfo',JSON.stringify(data?.userInfo))
|
||||
return {...state,...data}
|
||||
case SET_ADMINUSERINFO:
|
||||
Taro.setStorageSync('adminUserInfo',JSON.stringify(data?.adminUserInfo))
|
||||
return {...state,...data}
|
||||
case SET_TOKEN:
|
||||
Taro.setStorageSync('token',data?.token)
|
||||
return {...state,...data}
|
||||
case SET_SESSIONKEY:
|
||||
Taro.setStorageSync('session_key',data?.session_key)
|
||||
return {...state,...data}
|
||||
case SET_SORTCODE:
|
||||
Taro.setStorageSync('sort_code',JSON.stringify(data?.sort_code))
|
||||
return {...state,...data}
|
||||
case CLEAR_TOKEN:
|
||||
Taro.removeStorageSync('token')
|
||||
return {...state, token:''}
|
||||
case CLEAR_SESSIONKEY:
|
||||
Taro.removeStorageSync('session_key')
|
||||
return {...state, session_key:''}
|
||||
case CLEAR_USERINFO:
|
||||
Taro.removeStorageSync('userInfo')
|
||||
return {...state, userInfo: null}
|
||||
case CLEAR_ADMINUSERINFO:
|
||||
Taro.removeStorageSync('adminUserInfo')
|
||||
return {...state, adminUserInfo: null}
|
||||
case CLEAR_SORTCODE:
|
||||
Taro.removeStorageSync('sort_code')
|
||||
return {...state, sortCode: null}
|
||||
case LOGIN_STATUS:
|
||||
return {...state, ...data}
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
export default (state = INIT_USER, action: UserInfoAction) => {
|
||||
const { type, data } = action
|
||||
switch (type) {
|
||||
case UserInfoActionType.SET_USERINFO:
|
||||
Taro.setStorageSync('userInfo', JSON.stringify(data?.userInfo))
|
||||
return { ...state, ...data }
|
||||
case UserInfoActionType.SET_ADMINUSERINFO:
|
||||
Taro.setStorageSync('adminUserInfo', JSON.stringify(data?.adminUserInfo))
|
||||
return { ...state, ...data }
|
||||
case UserInfoActionType.SET_TOKEN:
|
||||
Taro.setStorageSync('token', data?.token)
|
||||
return { ...state, ...data }
|
||||
case UserInfoActionType.SET_SESSIONKEY:
|
||||
Taro.setStorageSync('session_key', data?.session_key)
|
||||
return { ...state, ...data }
|
||||
case UserInfoActionType.SET_SORTCODE:
|
||||
Taro.setStorageSync('sort_code', JSON.stringify(data?.sort_code))
|
||||
return { ...state, ...data }
|
||||
case UserInfoActionType.CLEAR_TOKEN:
|
||||
Taro.removeStorageSync('token')
|
||||
return { ...state, token: '' }
|
||||
case UserInfoActionType.CLEAR_SESSIONKEY:
|
||||
Taro.removeStorageSync('session_key')
|
||||
return { ...state, session_key: '' }
|
||||
case UserInfoActionType.CLEAR_USERINFO:
|
||||
Taro.removeStorageSync('userInfo')
|
||||
return { ...state, userInfo: null }
|
||||
case UserInfoActionType.CLEAR_ADMINUSERINFO:
|
||||
Taro.removeStorageSync('adminUserInfo')
|
||||
return { ...state, adminUserInfo: null }
|
||||
case UserInfoActionType.CLEAR_SORTCODE:
|
||||
Taro.removeStorageSync('sort_code')
|
||||
return { ...state, sortCode: null }
|
||||
case UserInfoActionType.LOGIN_STATUS:
|
||||
return { ...state, ...data }
|
||||
default:
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user