user.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import {
  2. LOGIN,
  3. MINUS
  4. } from '../constants/user'
  5. // landlord: 'landlord',
  6. // customer:'customer'
  7. // adminuser
  8. const INITIAL_STATE = {
  9. phone:false
  10. // role: 'adminuser',
  11. // role: 'landlord',
  12. // role:''
  13. // role: 'customer'
  14. }
  15. export const login = () => {
  16. return {
  17. type: LOGIN
  18. }
  19. }
  20. // 异步的action
  21. export function asyncLogina() {
  22. console.log('asyncLogin22')
  23. return dispatch => {
  24. dispatch({
  25. type: 'LOGIN',
  26. data: '333'
  27. })
  28. }
  29. }
  30. export default function user(state = INITIAL_STATE, action) {
  31. console.log(state, 'state33')
  32. switch (action.type) {
  33. case 'LOGIN': {
  34. if (action.user.shopKeeperList.length > 0) {
  35. return {
  36. ...state,
  37. ...action.user,
  38. // role: 'landlord',
  39. role: 'customer',
  40. }
  41. } else {
  42. return {
  43. ...state,
  44. ...action.user,
  45. role: 'customer',
  46. }
  47. }
  48. }
  49. case 'phone': {
  50. return state
  51. }
  52. default:
  53. return state
  54. }
  55. }