修复部分bug
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
//公共数据,什么都可往里面传,可用于临时传参
|
||||
import Taro from '@tarojs/taro'
|
||||
import {
|
||||
SET_COMMON,
|
||||
CLEAR_COMMON
|
||||
SET_SHOPCOUNT,
|
||||
CLEAR_SHOPCOUNT
|
||||
} from '../constants/common'
|
||||
|
||||
export type DataParam = {
|
||||
common: any
|
||||
shopCount: number
|
||||
}
|
||||
|
||||
type Action = {
|
||||
@@ -17,18 +17,18 @@ type Action = {
|
||||
|
||||
|
||||
const INIT = {
|
||||
common: Taro.getStorageSync('common')?JSON.parse(Taro.getStorageSync('common')):null,
|
||||
shopCount: Taro.getStorageSync('shopCount')?JSON.parse(Taro.getStorageSync('shopCount')):null,
|
||||
}
|
||||
|
||||
export default function counter (state = INIT, action: Action) {
|
||||
const {type, data} = action
|
||||
switch (type) {
|
||||
case SET_COMMON:
|
||||
Taro.setStorageSync('common',JSON.stringify(data))
|
||||
case SET_SHOPCOUNT:
|
||||
Taro.setStorageSync('shopCount',JSON.stringify(data))
|
||||
return {...state,...data}
|
||||
case CLEAR_COMMON:
|
||||
Taro.removeStorageSync('common')
|
||||
return {...state, common: null}
|
||||
case CLEAR_SHOPCOUNT:
|
||||
Taro.removeStorageSync('shopCount')
|
||||
return {...state, shopCount: null}
|
||||
default:
|
||||
return state
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user