修复部分bug

This commit is contained in:
2022-07-07 20:32:59 +08:00
parent d3a7fd9913
commit 3637447ab6
22 changed files with 262 additions and 318 deletions
+9 -9
View File
@@ -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
}