user.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import axios from '~/plugins/axios'
  2. export const actions = {
  3. // 获取浏览记录
  4. loadHistory ({ commit }, params = {}) {
  5. commit('history/REQUEST_HISTORY')
  6. return axios.get('/trade/history/goods/list', {params})
  7. .then(response => {
  8. commit('history/GET_HISTORY_SUCCESS', response.data)
  9. }, err => {
  10. commit('history/GET_HISTORY_FAILURE', err)
  11. })
  12. },
  13. // 删除一条历史记录
  14. deleteHistory ({ commit }, params = {}) {
  15. commit('history/REQUEST_DELETE')
  16. return axios.post(`/trade/history/goods/setDelete?id=${params.id}`, {})
  17. .then(response => {
  18. commit('history/GET_DELETE_SUCCESS', response.data)
  19. }, err => {
  20. commit('history/GET_DELETE_FAILURE', err)
  21. })
  22. },
  23. // 获取购物车数量
  24. CarCount ({ commit }, params = {}) {
  25. commit('history/REQUEST_CARTCOUNT')
  26. return axios.get(`/trade/cart/count`, {params})
  27. .then(response => {
  28. commit('history/GET_CARTCOUNT_SUCCESS', response.data)
  29. }, err => {
  30. commit('history/GET_CARTCOUNT_FAILURE', err)
  31. })
  32. },
  33. // 获取购买信息
  34. getBuyInfo ({ commit }, params) {
  35. commit('buy/REQUEST_BUY')
  36. return axios.post(`/trade/order/buyNow`, params)
  37. .then(response => {
  38. commit('buy/GET_BUY_SUCCESS', response.data)
  39. }, err => {
  40. commit('buy/GET_BUY_FAILURE', err)
  41. })
  42. },
  43. // 加入购物车
  44. addCar ({ commit }, params) {
  45. commit('car/REQUEST_CAR')
  46. return axios.post(`/trade/cart/add`, params)
  47. .then(response => {
  48. commit('car/GET_CAR_SUCCESS', response.data)
  49. }, err => {
  50. commit('car/GET_CAR_FAILURE', err)
  51. })
  52. },
  53. // 获取修改邮箱地址
  54. updateUserEmail ({ commit }, params = {}) {
  55. commit('updateUser/REQUEST_USER_EMAIL')
  56. return axios.get(`/mEmail/page`, params)
  57. .then(response => {
  58. commit('updateUser/GET_USER_EMAIL_SUCCESS', response.data)
  59. }, err => {
  60. commit('updateUser/GET_USER_EMAIL_FAILURE', err)
  61. })
  62. },
  63. // 获取修改手机号地址
  64. updateUserMobile ({ commit }, params = {}) {
  65. commit('updateUser/REQUEST_USER_MOBILE')
  66. return axios.get(`/mPhone/page`, params)
  67. .then(response => {
  68. commit('updateUser/GET_USER_MOBILE_SUCCESS', response.data)
  69. }, err => {
  70. commit('updateUser/GET_USER_MOBILE_FAILURE', err)
  71. })
  72. }
  73. }