117 lines
3.1 KiB
TypeScript
117 lines
3.1 KiB
TypeScript
import { createStore } from "redux"
|
|
// 设置数据
|
|
const baseState = {
|
|
// msg: '嘻嘻嘻嘻嘻嘻',
|
|
// num: 10,
|
|
// shuju: {
|
|
// name: '小白',
|
|
// hobby: '吃饭',
|
|
// val: ''
|
|
// },
|
|
belongArray: [],
|
|
refunArray: [],
|
|
correctionArray: [],
|
|
contractArray: [],
|
|
contractTotal: 0,
|
|
refunTotal: 0,
|
|
correctionTotal: 0,
|
|
couponModal: false,
|
|
projName: '',
|
|
projStatus: '',
|
|
newRefun: false,
|
|
newCorrection: false,
|
|
packNum: {
|
|
ALL: 0,
|
|
MATERIAL: 0,
|
|
},
|
|
phoneModal: false,
|
|
appGoodsListData: {},
|
|
replaceArray: [],
|
|
replaceTotal: 0,
|
|
newReplace: false,
|
|
activityModal: false, //活动弹窗
|
|
activityImgShow: true, //活动图片是否展示
|
|
// 坐标
|
|
centerPoint: { x: 0, y: 0 },
|
|
}
|
|
|
|
// 创建仓库
|
|
const reducer = (state = baseState, action: any) => {
|
|
const nstate: any = JSON.parse(JSON.stringify(state))
|
|
// if (action.type == "numadd") {
|
|
// nstate.num++
|
|
// // console.log('123');
|
|
// }
|
|
// if (action.type == 'new') {
|
|
// nstate.shuju.val = action.val
|
|
// console.log(nstate.shuju.val);
|
|
// }
|
|
// redux 要求 state必须深拷贝一次 才能返回
|
|
if (action.type == 'uparray') {
|
|
nstate.belongArray = action.val
|
|
}
|
|
if (action.type == 'upRefunArray') {
|
|
nstate.refunArray = action.val
|
|
}
|
|
if (action.type == 'upRefunTotal') {
|
|
nstate.refunTotal = action.val
|
|
}
|
|
if (action.type == 'upCorrectionArray') {
|
|
nstate.correctionArray = action.val
|
|
}
|
|
if (action.type == 'upReplaceArray') {
|
|
nstate.replaceArray = action.val
|
|
}
|
|
if (action.type == 'upContractArray') {
|
|
nstate.contractArray = action.val
|
|
}
|
|
if (action.type == 'upContractTotal') {
|
|
nstate.contractTotal = action.val
|
|
}
|
|
if (action.type == 'upCorrectionTotal') {
|
|
nstate.correctionTotal = action.val
|
|
}
|
|
if (action.type == 'upReplaceTotal') {
|
|
nstate.replaceTotal = action.val
|
|
}
|
|
if (action.type == 'changeCouponModal') {
|
|
nstate.couponModal = action.val
|
|
}
|
|
if (action.type == 'upProjName') {
|
|
nstate.projName = action.val
|
|
}
|
|
if (action.type == 'upProjStatus') {
|
|
nstate.projStatus = action.val
|
|
}
|
|
if (action.type == 'newRefun') {
|
|
nstate.newRefun = action.val
|
|
}
|
|
if (action.type == 'newCorrection') {
|
|
nstate.newCorrection = action.val
|
|
}
|
|
if (action.type == 'upPackNum') {
|
|
nstate.packNum = action.val
|
|
}
|
|
if (action.type == 'changePhoneModal') {
|
|
nstate.phoneModal = action.val
|
|
}
|
|
if (action.type == 'upAppGoodsListData') {
|
|
nstate.appGoodsListData = action.val
|
|
}
|
|
if (action.type == 'newReplace') {
|
|
nstate.newReplace = action.val
|
|
}
|
|
if (action.type == 'setActivityModal') {
|
|
nstate.activityModal = action.val
|
|
}
|
|
if (action.type == 'upCenterPoint') {
|
|
nstate.centerPoint = action.val
|
|
}
|
|
if (action.type == 'setActivityImgShow') {
|
|
nstate.activityImgShow = action.val
|
|
}
|
|
return nstate
|
|
}
|
|
const store = createStore(reducer)
|
|
export default store
|