1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- import PersistedState from '../PersistedState'
- const initState = {
- detailInfo:PersistedState.getStorage('pointsgoods','detailInfo', {}), // 商品详情
- commendList:PersistedState.getStorage('pointsgoods','commendList', []), // 推荐商品
- mbBody:PersistedState.getStorage('pointsgoods','mbBody', []),
- isShowcartInfo:PersistedState.getStorage('pointsgoods','isShowcartInfo', false), // 是否显示购物车
- number:PersistedState.getStorage('pointsgoods','number', 0), // 选择商品的数量
- type:PersistedState.getStorage('pointsgoods','type', '确定'), // 点击购买和加入购物车, 购买浮层的按钮显示
- index:PersistedState.getStorage('pointsgoods','index', 0), // 当前点击的type值
- currentProductId:PersistedState.getStorage('pointsgoods','currentProductId', ''), // 当前商品的id
- isPreviewPicture:PersistedState.getStorage('pointsgoods','isPreviewPicture', false), // 当前是否是预览大图
- }
- // initial state
- const state = {
- ...initState,
- initState () {
- return initState
- }
- }
- // mutations
- const mutations = {
- // 保存商品详情, 各个组件数据共享
- saveDetailInfo (state, value) {
- state.detailInfo = value
- PersistedState.setStorage('pointsgoods',state)
- },
- // 商品详情
- saveMbBody (state, value) {
- state.mbBody = value
- PersistedState.setStorage('pointsgoods',state)
- },
- // 商品评论
- saveCommendList (state, value) {
- state.commendList = value
- PersistedState.setStorage('pointsgoods',state)
- },
- // 根据点击时是否显示购物车浮层
- saveCartState (state, value) {
- state.isShowcartInfo = value
- PersistedState.setStorage('pointsgoods',state)
- },
- // 保存选择的商品的数量
- saveNumber (state, number) {
- state.number = number
- PersistedState.setStorage('pointsgoods',state)
- },
- // 加入购物车,还是确定的文案设置
- changeType (state, value) {
- state.type = value
- PersistedState.setStorage('pointsgoods',state)
- },
- // 保存当钱切换的tab值
- changeIndex (state, value) {
- state.index = value
- PersistedState.setStorage('pointsgoods',state)
- },
- // 设置当前商品的id值
- setCurrentProductId (state, value) {
- state.currentProductId = value
- PersistedState.setStorage('pointsgoods',state)
- },
- // 改变当前是否是预览大图的值
- setisPreviewPicture (state, value) {
- state.isPreviewPicture = value
- PersistedState.setStorage('pointsgoods',state)
- },
- }
- export default {
- state,
- mutations
- }
|