pointsgoods.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import PersistedState from '../PersistedState'
  2. const initState = {
  3. detailInfo:PersistedState.getStorage('pointsgoods','detailInfo', {}), // 商品详情
  4. commendList:PersistedState.getStorage('pointsgoods','commendList', []), // 推荐商品
  5. mbBody:PersistedState.getStorage('pointsgoods','mbBody', []),
  6. isShowcartInfo:PersistedState.getStorage('pointsgoods','isShowcartInfo', false), // 是否显示购物车
  7. number:PersistedState.getStorage('pointsgoods','number', 0), // 选择商品的数量
  8. type:PersistedState.getStorage('pointsgoods','type', '确定'), // 点击购买和加入购物车, 购买浮层的按钮显示
  9. index:PersistedState.getStorage('pointsgoods','index', 0), // 当前点击的type值
  10. currentProductId:PersistedState.getStorage('pointsgoods','currentProductId', ''), // 当前商品的id
  11. isPreviewPicture:PersistedState.getStorage('pointsgoods','isPreviewPicture', false), // 当前是否是预览大图
  12. }
  13. // initial state
  14. const state = {
  15. ...initState,
  16. initState () {
  17. return initState
  18. }
  19. }
  20. // mutations
  21. const mutations = {
  22. // 保存商品详情, 各个组件数据共享
  23. saveDetailInfo (state, value) {
  24. state.detailInfo = value
  25. PersistedState.setStorage('pointsgoods',state)
  26. },
  27. // 商品详情
  28. saveMbBody (state, value) {
  29. state.mbBody = value
  30. PersistedState.setStorage('pointsgoods',state)
  31. },
  32. // 商品评论
  33. saveCommendList (state, value) {
  34. state.commendList = value
  35. PersistedState.setStorage('pointsgoods',state)
  36. },
  37. // 根据点击时是否显示购物车浮层
  38. saveCartState (state, value) {
  39. state.isShowcartInfo = value
  40. PersistedState.setStorage('pointsgoods',state)
  41. },
  42. // 保存选择的商品的数量
  43. saveNumber (state, number) {
  44. state.number = number
  45. PersistedState.setStorage('pointsgoods',state)
  46. },
  47. // 加入购物车,还是确定的文案设置
  48. changeType (state, value) {
  49. state.type = value
  50. PersistedState.setStorage('pointsgoods',state)
  51. },
  52. // 保存当钱切换的tab值
  53. changeIndex (state, value) {
  54. state.index = value
  55. PersistedState.setStorage('pointsgoods',state)
  56. },
  57. // 设置当前商品的id值
  58. setCurrentProductId (state, value) {
  59. state.currentProductId = value
  60. PersistedState.setStorage('pointsgoods',state)
  61. },
  62. // 改变当前是否是预览大图的值
  63. setisPreviewPicture (state, value) {
  64. state.isPreviewPicture = value
  65. PersistedState.setStorage('pointsgoods',state)
  66. },
  67. }
  68. export default {
  69. state,
  70. mutations
  71. }