customer.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import ajax from '../../util/ajax'
  2. import api from '../../util/api'
  3. export default {
  4. namespaced: true,
  5. state: {
  6. customer: {},
  7. customers: {},
  8. },
  9. mutations: {
  10. updateInfo (state, payload) {
  11. state.customer = payload || {}
  12. },
  13. updateList (state, payload) {
  14. state.customers = payload || {}
  15. }
  16. },
  17. actions: {
  18. GetCustomerByTel ({ commit }, { tel }) {
  19. return new Promise((resolve, reject) => {
  20. ajax(api.customerManager.getByTel.url, {
  21. method: api.customerManager.getByTel.method,
  22. urlData: {
  23. tel
  24. }
  25. }).then(res => {
  26. commit('updateInfo', res)
  27. resolve(res)
  28. }).catch(reject)
  29. })
  30. },
  31. GetCustomerList ({ commit }, payload) {
  32. return new Promise((resolve, reject) => {
  33. ajax(api.customerManager.getCustomerList.url, {
  34. method: api.customerManager.getCustomerList.method,
  35. queryData: {
  36. ...payload
  37. }
  38. }).then(res => {
  39. commit('updateList', res)
  40. resolve(res)
  41. }).catch(reject)
  42. })
  43. },
  44. SetCustomerListNull ({ commit }) {
  45. commit('updateList', {})
  46. },
  47. SetCustomerInfoNull ({ commit }) {
  48. commit('updateInfo', {})
  49. }
  50. }
  51. }