已对接登录和下单选择商品
This commit is contained in:
@@ -10,14 +10,20 @@ import {
|
||||
} from '../constants/userInfo'
|
||||
|
||||
export type UserParam = {
|
||||
name?:string,
|
||||
nickName?:string,
|
||||
phone?:string,
|
||||
avatarUrl?:string,
|
||||
city?: string,
|
||||
country?: string,
|
||||
province?: string,
|
||||
gender?: number,
|
||||
language?: string,
|
||||
timestamp?: number
|
||||
}
|
||||
|
||||
export type DataParam = {
|
||||
token?: string
|
||||
sessionkey?: string,
|
||||
session_key?: string,
|
||||
userInfo: UserParam
|
||||
}
|
||||
|
||||
@@ -31,7 +37,7 @@ type Action = {
|
||||
const INIT_USER = {
|
||||
userInfo: Taro.getStorageSync('userInfo')?JSON.parse(Taro.getStorageSync('userInfo')):null,
|
||||
token: Taro.getStorageSync('token')||'',
|
||||
session_key: Taro.getStorageSync('sessionkey')||'',
|
||||
session_key: Taro.getStorageSync('session_key')||'',
|
||||
}
|
||||
|
||||
export default function counter (state = INIT_USER, action: Action) {
|
||||
@@ -41,16 +47,16 @@ export default function counter (state = INIT_USER, action: Action) {
|
||||
Taro.setStorageSync('userInfo',JSON.stringify(data?.userInfo))
|
||||
return {...state,...data}
|
||||
case SET_TOKEN:
|
||||
Taro.setStorageSync('token',JSON.stringify(data?.token))
|
||||
Taro.setStorageSync('token',data?.token)
|
||||
return {...state,...data}
|
||||
case SET_SESSIONKEY:
|
||||
Taro.setStorageSync('sessionkey',JSON.stringify(data?.sessionkey))
|
||||
Taro.setStorageSync('session_key',data?.session_key)
|
||||
return {...state,...data}
|
||||
case CLEAR_TOKEN:
|
||||
Taro.removeStorageSync('token')
|
||||
return {...state, token:''}
|
||||
case CLEAR_SESSIONKEY:
|
||||
Taro.removeStorageSync('sessionkey')
|
||||
Taro.removeStorageSync('session_key')
|
||||
return {...state, session_key:''}
|
||||
case CLEAR_USERINFO:
|
||||
Taro.removeStorageSync('userInfo')
|
||||
|
||||
Reference in New Issue
Block a user