1234567891011121314151617181920212223242526272829303132333435363738394041 |
- export default{
- //开启命名空间
- namespaced:true,
- //数据
- state:()=>({
- // orders:JSON.parse(uni.getStorageSync('orders')||'[]'),
- orders:[
- {
- }
- ],
- //重定向Object对象
- redirectInfo:null,
- }),
- //方法
- mutations:{
- //更新收货地址
- putOrder(state,order){
- state.orders=[...state.orders,order]
- this.commit('m_user/saveOrderToStorage')
- },
- //持久化储存orders
- saveOrderToStorage(state){
- uni.setStorageSync('orders',JSON.stringify(state.orders))
- },
- updateRedirectInfo(state,info){
- state.redirectInfo=info
- console.log(state.redirectInfo);
- },
- },
- getters:{
- //收货地址
- getOrdersByType(state,type){
- return state.orders.filter(order=>order.orderType===type)
- }
- }
- }
|