article.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // import { commuLike } from '@/apis/commu.js'
  2. export default {
  3. namespaced: true,
  4. state: {
  5. lists: {},
  6. index: {}
  7. },
  8. mutations: {
  9. UPDATA(state, payload) {
  10. state.lists = payload
  11. },
  12. LIKE(state, payload) {
  13. state.lists[payload.listsIndex][payload.commuIndex].like = !state.lists[payload.listsIndex][payload.commuIndex].like
  14. // commuLike({
  15. // type: 0,
  16. // id: state.lists[payload.listsIndex][payload.commuIndex].id,
  17. // status: state.lists[payload.listsIndex][payload.commuIndex].like ? 1 : 0
  18. // })
  19. },
  20. COLLECTION(state, payload) {
  21. state.lists[payload.listsIndex][payload.commuIndex].collection = !state.lists[payload.listsIndex][payload.commuIndex].collection
  22. // commuLike({
  23. // type: 1,
  24. // id: state.lists[payload.listsIndex][payload.commuIndex].id,
  25. // status: state.lists[payload.listsIndex][payload.commuIndex].collection ? 1 : 0,
  26. // })
  27. },
  28. ADDINDEX(state, payload) {
  29. state.index = payload
  30. },
  31. LIKEINDEX(state) {
  32. state.index.like = !state.index.like
  33. commuLike({ type: 0, id: state.index.id, status: state.index.like ? 1 : 0 })
  34. },
  35. COLLECTIONINDEX(state) {
  36. state.index.collection = !state.index.collection
  37. commuLike({ type: 1, id: state.index.id, status: state.index.collection ? 1 : 0 })
  38. },
  39. }
  40. }