Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.50 KB | None | 0 0
  1. <template>
  2. <div>
  3. <div class="registration-confirm registration__step" v-if="step === 0">
  4. <div class="registration-confirm__inner">
  5. <h2 class="registration__heading">Подтверждение данных</h2>
  6. <div class="registration__select-game">
  7. <div class="registration__select-item">Индивидуальное участие</div>
  8. <div class="registration__select-item">{{ distanceType.nameRus }}</div>
  9. <div class="registration__select-item">{{ fullDistanceCost }} ₽</div>
  10. </div>
  11. <hr class="registration__divider" />
  12. <div class="registration__confirm-info">
  13. <div class="registration__confirm-col">
  14. <p
  15. class="registration__confirm-value"
  16. >{{ lastNameRus }} {{ firstNameRus }} {{ middleNameRus }}</p>
  17. <p class="registration__confirm-value">{{ birthDate | moment('DD.MM.YYYY')}}</p>
  18. <p class="registration__confirm-value">{{ genderId === 1 ? 'Мужской' : 'Женский' }} пол</p>
  19. <p
  20. class="registration__confirm-value"
  21. >{{ findCountry(countryId) }} {{ findRegion(regionId) }} {{ findLocality(localityId) }}</p>
  22. </div>
  23. <div class="registration__confirm-col">
  24. <p class="registration__confirm-value">{{ email }}</p>
  25. <p class="registration__confirm-value">{{ phoneNumber }}</p>
  26. <p
  27. class="registration__confirm-value"
  28. v-if="event.sport.id != 20"
  29. >{{ emergencyPhone + ' (доп)'}}</p>
  30. </div>
  31. </div>
  32. </div>
  33. <div class="registration__nav-btn">
  34. <button
  35. class="btn btn--main btn--size-lg registration__btn"
  36. :class="{ 'sending': sendingSubmit }"
  37. :disabled="sendingSubmit"
  38. type="button"
  39. @click="submit"
  40. v-if="fullDistanceCost != 0"
  41. >Подтвердить и оплатить</button>
  42. <button
  43. class="btn btn--main btn--size-lg registration__btn"
  44. :class="{ 'sending': sendingSubmit }"
  45. :disabled="sendingSubmit"
  46. type="button"
  47. @click="submit"
  48. v-else
  49. >Подтвердить</button>
  50. <slot name="btns"></slot>
  51. <p
  52. class="field-text__help text--red"
  53. v-if="emailExists && !loggedIn"
  54. >Данный email уже используется. Войдите в личный кабинет или измените данные.</p>
  55. <!---->
  56. </div>
  57. </div>
  58. <div v-if="step === 1">
  59. <paymentPage>
  60. <template slot="paymentPage">
  61. <iframe v-if="paymentPage != null" :src="paymentPage" width="100%" height="1000" ></iframe>
  62. </template>
  63. </paymentPage>
  64. </div>
  65. </div>
  66. </template>
  67.  
  68. <script>
  69. import { mapPersonalDataFields } from "@/store";
  70. import axios from "axios";
  71. import ConfirmData from "@/mixins/confirm-data";
  72. import GeoData from "@/mixins/geo-data";
  73. import PaymentPage from "@/views/paymentPage"
  74. export default {
  75. props: {
  76. promocodeInfo: {
  77. type: Object,
  78. default: () => {
  79. return null;
  80. }
  81. }
  82. },
  83. name: "confirm",
  84. data() {
  85. return {
  86. step: 0,
  87. paymentPage: null,
  88. emailExists: false,
  89. emailGenerated: false,
  90. errors: [],
  91. body: {
  92. participationTypeId: null,
  93. selfRegistration: null,
  94. distanceId: null,
  95. clothingSizeId: null,
  96. startingNumber: null,
  97. lastNameRus: null,
  98. firstNameRus: null,
  99. middleNameRus: null,
  100. genderId: null,
  101. birthDate: null,
  102. countryId: null,
  103. regionId: null,
  104. localityId: null,
  105. email: null,
  106. phoneNumber: null,
  107. emergencyPhone: null,
  108. sportClubId: null,
  109. isBeneficiary: null,
  110. publicOffer: null,
  111. competitionClause: null,
  112. promocodeId: null,
  113. plainningTime: null
  114. },
  115. submitted: false,
  116. sendingSubmit: false,
  117. sendingPayment: false,
  118. errorDuringPayment: false,
  119. formNotValid: false
  120. };
  121. },
  122. components: {
  123. PaymentPage
  124. },
  125. mixins: [GeoData, ConfirmData],
  126. mounted() {
  127. this.emailExists = false;
  128. this.emailGenerated = false;
  129. this.$store.commit("SET_NEED_TO_LOG_IN_DURING_REGISTRATION", false);
  130. },
  131. computed: {
  132. promocodeId() {
  133. if (this.promocodeInfo) {
  134. return this.promocodeInfo.id;
  135. } else {
  136. return null;
  137. }
  138. },
  139. distanceCost() {
  140. let distance = this.distances.find(
  141. item => item.id == this.chosenDistance
  142. );
  143. return this.isBeneficiary
  144. ? distance.distanceCost / 2
  145. : distance.distanceCost;
  146. },
  147. participationType() {
  148. return this.$store.getters["part/participationType"];
  149. },
  150. self() {
  151. return this.$store.getters["part/self"];
  152. },
  153. event() {
  154. return this.$store.getters.event;
  155. },
  156. fullDistanceCost() {
  157. let distance = this.distances.find(
  158. item => item.id == this.chosenDistance
  159. );
  160. var diff = new Date(Date.now()).getFullYear() - new Date(this.birthDate).getFullYear();
  161. if (this.promocodeInfo) {
  162. if (this.promocodeInfo.discountType === "Percent") {
  163. return (
  164. (distance.distanceCost *
  165. (100 - this.promocodeInfo.promocodePercent)) /
  166. 100
  167. );
  168. } else return distance.distanceCost - this.promocodeInfo.promocodeSum;
  169. } else {
  170. return (diff >= 65 && this.genderId == 1) || (diff >= 50 && this.genderId != 1)
  171. ? distance.distanceCost / 2
  172. : distance.distanceCost;
  173. }
  174. },
  175. ...mapPersonalDataFields({
  176. firstNameRus: "rows[0].firstNameRus",
  177. lastNameRus: "rows[0].lastNameRus",
  178. middleNameRus: "rows[0].middleNameRus",
  179. birthDate: "rows[0].birthDate",
  180. genderId: "rows[0].genderId",
  181. email: "rows[0].email",
  182. countryId: "rows[0].countryId",
  183. regionId: "rows[0].regionId",
  184. localityId: "rows[0].localityId",
  185. phoneNumber: "rows[0].phoneNumber",
  186. clothingSizeId: "rows[0].clothingSizeId",
  187. participationTypeId: "rows[0].participationTypeId",
  188. selfRegistration: "rows[0].selfRegistration",
  189. distanceId: "rows[0].distanceId",
  190. startingNumber: "rows[0].startingNumber",
  191. emergencyPhone: "rows[0].emergencyPhone",
  192. sportClubId: "rows[0].sportClubId",
  193. isBeneficiary: "rows[0].isBeneficiary",
  194. publicOffer: "rows[0].publicOffer",
  195. competitionClause: "rows[0].competitionClause",
  196.  
  197. firstNameRusCopy: "rows[0].firstNameRus",
  198. lastNameRusCopy: "rows[0].lastNameRus",
  199. middleNameRusCopy: "rows[0].middleNameRus",
  200. birthDateCopy: "rows[0].birthDate",
  201. genderIdCopy: "rows[0].genderId",
  202. emailCopy: "rows[0].email",
  203. countryIdCopy: "rows[0].countryId",
  204. regionIdCopy: "rows[0].regionId",
  205. localityIdCopy: "rows[0].localityId",
  206. phoneNumberCopy: "rows[0].phoneNumber",
  207. clothingSizeIdCopy: "rows[0].clothingSizeId",
  208. participationTypeIdCopy: "rows[0].participationTypeId",
  209. selfRegistrationCopy: "rows[0].selfRegistration",
  210. distanceIdCopy: "rows[0].distanceId",
  211. startingNumberCopy: "rows[0].startingNumber",
  212. emergencyPhoneCopy: "rows[0].emergencyPhone",
  213. sportClubIdCopy: "rows[0].sportClubId",
  214. isBeneficiaryCopy: "rows[0].isBeneficiary",
  215. publicOfferCopy: "rows[0].publicOffer",
  216. competitionClauseCopy: "rows[0].competitionClause",
  217. plainningTime: "rows[0].plainningTime"
  218. }),
  219.  
  220. needLoggedInDuringRegistration() {
  221. return this.$store.getters.needLoggedInDuringRegistration;
  222. },
  223. loggedInDuringRegistration() {
  224. return this.$store.getters.loggedInDuringRegistration;
  225. },
  226.  
  227. clothingSize() {
  228. return this.$store.getters["part/clothingSize"];
  229. },
  230. niceNumber() {
  231. return this.$store.getters["part/niceNumber"];
  232. },
  233. loggedIn() {
  234. return this.$store.getters.loggedIn;
  235. }
  236. },
  237. methods: {
  238. fillBody() {
  239. this.body.participationTypeId = this.$route.query.participationType;
  240. this.body.selfRegistration = this.$route.query.type === "self";
  241. this.body.distanceId = this.$route.query.distance;
  242. this.body.clothingSizeId = this.clothingSize;
  243. this.body.startingNumber = this.niceNumber;
  244. this.body.lastNameRus = this.lastNameRus;
  245. this.body.firstNameRus = this.firstNameRus;
  246. this.body.middleNameRus = this.middleNameRus;
  247. this.body.genderId = this.genderId;
  248. this.body.birthDate = this.birthDate;
  249. this.body.countryId = this.countryId;
  250. this.body.regionId = this.regionId;
  251. this.body.localityId = this.localityId;
  252. this.body.email = this.email;
  253. this.body.phoneNumber = this.phoneNumber;
  254. this.body.emergencyPhone = this.emergencyPhone;
  255. this.body.sportClubId = this.sportClubId;
  256. this.body.isBeneficiary = this.isBeneficiary;
  257. this.body.publicOffer = this.publicOffer;
  258. this.body.competitionClause = this.competitionClause;
  259. this.body.promocodeId = this.promocodeId;
  260. this.body.plainningTime = this.plainningTime;
  261. },
  262. publicRegister() {
  263. this.sendingSubmit = true;
  264. axios
  265. .put(
  266. "/api/v1/events/" +
  267. this.$route.params.id +
  268. "/public-event-registration",
  269. this.body
  270. )
  271. .then(response => {
  272. // console.log(response);
  273. if (response.status === 200) {
  274. this.emailGenerated = true;
  275. this.emailExists = false;
  276. window.location.href = response.data.link;
  277. }
  278. this.sendingSubmit = false;
  279. })
  280. .catch(error => {
  281. // console.log(error.response)
  282. if (error.response.status === 400) {
  283. // this.$toastr.e(error.response.data.Ru)
  284. this.sendingSubmit = false;
  285. this.$toastr.e(error.response.data.Ru);
  286.  
  287. //
  288. // this.submitted = false;
  289. } else this.$toastr.e(error.response.data.Ru);
  290. this.sendingSubmit = false;
  291. });
  292. },
  293. loggedRegistration() {
  294. this.sendingSubmit = true;
  295. this.body.plainningTime = this.body.plainningTime + ":00"
  296. //console.log(this.body);
  297. axios
  298. .put(
  299. "/api/v1/events/" + this.$route.params.id + "/event-registration",
  300. this.body
  301. )
  302. .then(response => {
  303. // console.log(response);
  304. this.sendingSubmit = false;
  305. if (response.status === 200) {
  306. this.submitted = true;
  307. //this.step = 1;
  308. //this.paymentPage = response.data.link;
  309. ym(42001724, 'reachGoal', 'payment_button');
  310. }
  311. //this.window_payment = response.data.link;
  312. //this.paymentPage = response.data.link;
  313. window.location.href = response.data.link;
  314. })
  315. .catch(error => {
  316. // console.log(error.response);
  317. this.paymentPage = 'www.google.com/';
  318. this.sendingSubmit = false;
  319. if (error.response.status === 400) {
  320. if (error.response.statusText === "Bad Request") {
  321. //console.log('Думай над формой')
  322. this.formNotValid = true;
  323. }
  324. if (
  325. error.response.data.Ru === "Участник уже зарегистрировался на данную дистанцию"
  326. ) {
  327. this.$toastr.e(
  328. "Вы уже зарегистрированы на данное мероприятие."
  329. );
  330. }
  331. } else {
  332. this.$toastr.e(error.response.data.Ru);
  333. }
  334. });
  335. },
  336. submit() {
  337. this.fillBody();
  338. if (this.body.selfRegistration) {
  339. if (!this.loggedIn) {
  340. this.publicRegister();
  341. } else {
  342. this.loggedRegistration();
  343. }
  344. } else {
  345. // console.log('present')
  346. }
  347. },
  348. back() {
  349. this.$emit("backToPersonalData");
  350. },
  351. compareData() {
  352. let form = {
  353. participationTypeId: this.participationType,
  354. selfRegistration: this.self,
  355. distanceId: this.chosenDistance,
  356. clothingSizeId: this.clothingSize,
  357. startingNumber: this.niceNumber,
  358. lastNameRus: this.lastNameRus,
  359. firstNameRus: this.firstNameRus,
  360. middleNameRus: this.middleNameRus,
  361. genderId: this.genderId,
  362. birthDate: this.birthDate,
  363. countryId: this.countryId,
  364. regionId: this.regionId,
  365. localityId: this.localityId,
  366. email: this.email,
  367. phoneNumber: this.phoneNumber,
  368. emergencyPhone: this.emergencyPhone,
  369. sportClubId: this.sportClubId,
  370. isBeneficiary: this.isBeneficiary,
  371. publicOffer: this.publicOffer,
  372. competitionClause: this.competitionClause,
  373. plainningTime: this.plainningTime
  374. };
  375. let copyForm = {
  376. participationTypeId: this.participationType,
  377. selfRegistration: this.self,
  378. distanceId: this.chosenDistance,
  379. clothingSizeId: this.clothingSize,
  380. startingNumber: this.niceNumber,
  381. lastNameRus: this.lastNameRusCopy,
  382. firstNameRus: this.firstNameRusCopy,
  383. middleNameRus: this.middleNameRusCopy,
  384. genderId: this.genderIdCopy,
  385. birthDate: this.birthDateCopy,
  386. countryId: this.countryIdCopy,
  387. regionId: this.regionIdCopy,
  388. localityId: this.localityIdCopy,
  389. email: this.emailCopy,
  390. phoneNumber: this.phoneNumberCopy,
  391. emergencyPhone: this.emergencyPhoneCopy,
  392. sportClubId: this.sportClubIdCopy,
  393. isBeneficiary: this.isBeneficiary,
  394. publicOffer: this.publicOffer,
  395. competitionClause: this.competitionClause,
  396. plainningTime: this.plainningTime
  397. };
  398.  
  399. if (JSON.stringify(form) === JSON.stringify(copyForm)) {
  400. this.sendingPayment = true;
  401.  
  402. axios
  403. .put(
  404. "/api/v1/events/" +
  405. this.$route.params.id +
  406. "/payments/register?distanceId=" +
  407. this.chosenDistance,
  408. null
  409. )
  410. .then(response => {
  411. // console.log(response);
  412. this.sendingPayment = false;
  413. this.errorDuringPayment = false;
  414. window.location.href = "response.data.link";
  415. // window.open(response.data.link);
  416. this.$toastr.s(
  417. "Транзкакция сформирована. Убедитесь в том, что Ваш бразуер не блокирует всплывающие окна."
  418. );
  419. })
  420. .catch(error => {
  421. this.sendingPayment = false;
  422. this.$toastr.e(
  423. "Произошла ошибка во время оформления транзакции. Продолжите работу в личном кабинете"
  424. );
  425. });
  426. } else {
  427. this.$toastr.e(
  428. "Данные на форме не совпадают с предварительными данными, которые были введены"
  429. );
  430. }
  431. },
  432. payment() {
  433. this.compareData();
  434. },
  435. authorize() {
  436. this.$store.commit("SET_NEED_TO_LOG_IN_DURING_REGISTRATION", true);
  437. this.$modal.show("auth-modal");
  438. }
  439. }
  440. };
  441. </script>
  442.  
  443. <style scoped>
  444. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement