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

timeshare.js 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /* eslint-disable guard-for-in */
  2. /* eslint-disable no-restricted-syntax */
  3. import axios from 'axios';
  4. import MyData from '../../../assets/myData';
  5. import MaritalStatus from '../../../assets/staticData/maritalStatus';
  6. export default {
  7. namespaced: true,
  8. state: {
  9. resorts: [],
  10. regions: [],
  11. detailedRegion: [],
  12. seasons: [],
  13. resortBedrooms: [],
  14. maxSleep: [],
  15. bankedEntities: [],
  16. agencies: [],
  17. agents: [],
  18. maritalStatus: MaritalStatus,
  19. sellItem: {
  20. referedByAgent: false,
  21. agent: undefined,
  22. agency: undefined,
  23. otherResort: false,
  24. otherResortName: undefined,
  25. resort: undefined,
  26. region: undefined,
  27. season: undefined,
  28. module: undefined,
  29. unitNumber: undefined,
  30. bedrooms: undefined,
  31. maxSleep: undefined,
  32. weekNumber: undefined,
  33. levyAmount: undefined,
  34. currentYearBanked: false,
  35. bankedWith: undefined,
  36. leviesPaidInFull: false,
  37. weekPlacedForRental: false,
  38. originalPurchasePrice: undefined,
  39. originalPurchaseDate: undefined,
  40. arrivalDate: undefined,
  41. departureDate: undefined,
  42. sellingPrice: undefined,
  43. agentCommission: undefined,
  44. mandate: undefined,
  45. status: undefined,
  46. owner: {
  47. name: undefined,
  48. surname: undefined,
  49. idNumber: undefined,
  50. companyRegNumber: undefined,
  51. maritalStatus: undefined,
  52. emailAddress: undefined,
  53. cellNumber: undefined,
  54. landlineNumber: undefined,
  55. address: {
  56. streetNumber: undefined,
  57. streetName: undefined,
  58. suburb: undefined,
  59. city: undefined,
  60. province: undefined,
  61. postalCode: undefined,
  62. },
  63. bankingDetails: {
  64. bank: undefined,
  65. accountNumber: undefined,
  66. accountHolder: undefined,
  67. },
  68. },
  69. },
  70. },
  71. mutations: {
  72. setUnitConfigurationList(state, list) {
  73. state.unitConfigurationList = list;
  74. },
  75. setAgency(state, agencies) {
  76. state.agencies = agencies;
  77. },
  78. setAgent(state, agents) {
  79. state.agents = agents;
  80. },
  81. setSeason(state, seasons) {
  82. state.seasons = seasons;
  83. },
  84. setResortBedrooms(state, resortBedrooms) {
  85. state.resortBedrooms = resortBedrooms;
  86. },
  87. setMaxSleep(state, maxSleep) {
  88. state.maxSleep = maxSleep;
  89. },
  90. setBankedEntities(state, bankedEntities) {
  91. state.bankedEntities = bankedEntities;
  92. },
  93. addResort(state, resorts) {
  94. state.resorts = resorts;
  95. },
  96. addRegion(state, regions) {
  97. state.regions = regions;
  98. },
  99. addDetailedRegion(state, detailedRegion) {
  100. state.detailedRegion.push(detailedRegion);
  101. },
  102. },
  103. getters: {
  104. },
  105. actions: {
  106. initTimeshare({
  107. commit,
  108. dispatch,
  109. }) {
  110. commit('setResortBedrooms', MyData.resortBedrooms);
  111. commit('setMaxSleep', MyData.maxBedrooms);
  112. commit('setBankedEntities', MyData.bankedEntities);
  113. dispatch('getSeasons');
  114. dispatch('getAgents');
  115. dispatch('getAgencies');
  116. dispatch('getResorts');
  117. dispatch('getRegions');
  118. },
  119. getSeasons({
  120. commit,
  121. }) {
  122. axios
  123. .get('/api/season')
  124. .then(result => commit('setSeason', result.data))
  125. .catch(console.error);
  126. },
  127. getAgencies({
  128. commit,
  129. }) {
  130. console.log(123);
  131. axios
  132. .get('/api/agency')
  133. .then(result => commit('setAgency', result.data))
  134. .catch(console.error);
  135. },
  136. getAgents({
  137. commit,
  138. }) {
  139. axios
  140. .get('/api/agent')
  141. .then(result => commit('setAgent', result.data))
  142. .catch(console.error);
  143. },
  144. getResorts({
  145. commit,
  146. }) {
  147. axios
  148. .get('https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/list/')
  149. .then(result => commit('addResort', result.data))
  150. .catch(console.error);
  151. },
  152. getRegions({
  153. dispatch,
  154. commit,
  155. }) {
  156. axios
  157. .get('https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/regions/list/ZA')
  158. .then((result) => {
  159. commit('addRegion', result.data);
  160. dispatch('getDetailedRegion', result.data);
  161. })
  162. .catch(console.error);
  163. },
  164. getDetailedRegion({
  165. commit,
  166. }, data) {
  167. if (data) {
  168. for (const r in Object.keys(data)) {
  169. const region = data[r];
  170. if (region !== undefined) {
  171. axios
  172. .get(
  173. `https://www.tradeunipoint.com/unibackend/seam/resource/rest/products/resorts/${
  174. region.regionCode
  175. }/`,
  176. )
  177. .then(result => commit('addDetailedRegion', {
  178. region,
  179. children: result.data,
  180. }))
  181. .catch(console.error);
  182. }
  183. }
  184. }
  185. },
  186. },
  187. };