您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

buyPage.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* eslint-disable no-restricted-syntax */
  2. /* eslint-disable guard-for-in */
  3. import axios from 'axios';
  4. import _ from 'lodash';
  5. export default {
  6. namespaced: true,
  7. state: {
  8. regions: [],
  9. detailedRegion: [],
  10. },
  11. mutations: {
  12. setRegions(state, regions) {
  13. state.regions = regions;
  14. },
  15. clearDetailed(state) {
  16. state.detailedRegion = [];
  17. },
  18. addDetailed(state, detailed) {
  19. state.detailedRegion.push(detailed);
  20. },
  21. },
  22. getters: {},
  23. actions: {
  24. getRegions({
  25. commit,
  26. dispatch,
  27. }) {
  28. commit('clearDetailed');
  29. axios.get(
  30. 'https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/regions/list/ZA/',
  31. )
  32. .then((result) => {
  33. commit('setRegions', result.data);
  34. if (result.data) {
  35. for (const i in result.data) {
  36. const region = result.data[i];
  37. dispatch('getDetailedRegion', region);
  38. }
  39. }
  40. })
  41. .catch(console.error);
  42. },
  43. getDetailedRegion({
  44. commit,
  45. }, region) {
  46. if (region) {
  47. axios
  48. .get(`https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/${
  49. region.regionCode}/`)
  50. .then(result => commit('addDetailed', {
  51. id: region.id,
  52. regionCode: region.regionCode,
  53. regionName: region.regionName,
  54. resorts: result.data,
  55. }))
  56. .catch(console.error);
  57. }
  58. },
  59. },
  60. };