diff --git a/luckydiamond/src/components/adaptive-components/PaymentsMobile.vue b/luckydiamond/src/components/adaptive-components/PaymentsMobile.vue
index a514c5a..9f4ef9f 100644
--- a/luckydiamond/src/components/adaptive-components/PaymentsMobile.vue
+++ b/luckydiamond/src/components/adaptive-components/PaymentsMobile.vue
@@ -12,27 +12,39 @@
Сумма {{ payments.paymentsView ? 'пополнения' : 'вывода' }}
-
-
+
+
Я согласен с пользовательским соглашением.
-
+
Вы подтверждаете правильность введенных данных при создании вывода.
-
+
@@ -42,6 +54,26 @@
import PaymentsModalNumbers from "@/mocks/PaymentsModalNumbers";
import CaptchaComponent from "@/components/CaptchaComponent.vue";
+import {
+ GettingMoneyOperation,
+ WithdrawMoneyOperation,
+} from "@/assets/js/moneyoperation/Claimmoney";
+import { eventBus } from "@/main";
+
+import { useVuelidate } from "@vuelidate/core";
+import {
+ minValue,
+ required,
+ numeric,
+ integer,
+ minLength,
+ maxLength,
+} from "@vuelidate/validators";
+
+import { GetCurrentMoney } from "@/assets/js/rest/RestMethods";
+import { GetCookie } from "@/assets/js/storage/CookieStorage";
+// import { ApplyPromoCode } from "@/assets/js/rest/RestMethods.js"; // Замените на правильный путь к файлу с функцией ApplyPromoCode
+
import '@/assets/css/ComponentsStyles/AdaptiveStyles/payments-modalmobile.css'
export default {
@@ -51,13 +83,147 @@ export default {
return {
PaymentsModalNumbers,
agreeUser: false,
- number: 0
+ agreeUserDonate: false,
+ amount: 0,
+ card: '',
+ captchaToken: null,
+ url: '',
+ clickedBtn: "",
+ }
+ },
+ watch: {
+ amount(DepositCount) {
+ console.log(DepositCount);
+ if (![1, 5, 10, 50, 100, 1000].includes(DepositCount)) {
+ this.clickedBtn = null;
+ } else {
+ let index;
+ switch (DepositCount) {
+ case 1:
+ index = 0;
+ break;
+ case 5:
+ index = 1;
+ break;
+ case 10:
+ index = 2;
+ break;
+ case 50:
+ index = 3;
+ break;
+ case 100:
+ index = 4;
+ break;
+ case 1000:
+ index = 5;
+ break;
+ }
+ this.clickedBtnChoice(index, DepositCount);
+ }
+ }
+ },
+ setup() {
+ return { v$: useVuelidate() };
+ },
+ validations() {
+ return {
+ amount: { required, numeric, minValue: minValue(1), integer },
+ card: { required, numeric, minLength: minLength(5), maxLength: maxLength(5), integer }
}
},
methods: {
closeModal() {
return this.$emit('closemodal')
- }
+ },
+ clickBtn() {
+ this.v$.$touch()
+
+ if (this.payments.paymentsView === true) {
+
+ if (this.v$.amount.$error) {
+ console.log('error amount')
+ }
+
+ if (this.agreeUserDonate !== true) {
+ console.log('agreeuser error')
+ }
+
+ if (
+ !this.v$.amount.$error &&
+ this.agreeUserDonate === true
+ ) {
+ try {
+ GettingMoneyOperation(this.amount).then((response) => {
+ this.url = response
+
+ window.location.href = this.url;
+ })
+ }
+ catch (e) {
+ console.error(e)
+ }
+ }
+
+ }
+ else if (this.payments.paymentsView === false) {
+ this.v$.$touch()
+
+ if (this.v$.amount.$error) {
+ console.log('amount error')
+ }
+ if (this.v$.card.$error) {
+ console.log('card error')
+ }
+
+ if (this.agreeUser !== true) {
+ console.log('agree error')
+ }
+ if (this.captchaToken === null) {
+ console.log('token error')
+ }
+
+ let balanceUser = 0
+ GetCurrentMoney(GetCookie('AUTHTOKEN'), GetCookie('SearchToken'))
+ .then((response) => {
+ balanceUser = response.currentMoney
+ })
+
+ if (this.amount < balanceUser) {
+ console.log('money small balance')
+ }
+
+ if (
+ !this.v$.amount.$error &&
+ !this.v$.card.$error &&
+ this.agreeUser === true &&
+ this.captchaToken !== null &&
+ this.amount >= balanceUser
+ ) {
+ WithdrawMoneyOperation(
+ this.amount,
+ this.card.toString(),
+ this.captchaToken
+ ) .then((response) => {
+ try {
+ console.log('work', response)
+ eventBus.emit('Updatebalance')
+ return this.$emit('closemodal')
+ }
+ catch (e) {
+ console.error(e)
+ }
+ })
+ }
+ }
+ },
+ claimCaptchaToken(Token) {
+ this.captchaToken = Token
+ },
+ clickedBtnChoice(index, content) {
+ this.clickedBtn = index;
+ this.amount = content;
+ console.log(index);
+ },
}
}
diff --git a/luckydiamond/src/pages/adaptive-pages/ProfilemobilePage.vue b/luckydiamond/src/pages/adaptive-pages/ProfilemobilePage.vue
index 975f8fe..ee7606e 100644
--- a/luckydiamond/src/pages/adaptive-pages/ProfilemobilePage.vue
+++ b/luckydiamond/src/pages/adaptive-pages/ProfilemobilePage.vue
@@ -32,6 +32,7 @@ import { GetCookie } from "@/assets/js/storage/CookieStorage";
import {GetCurrentMoney} from "@/assets/js/rest/RestMethods";
import '@/assets/css/PagesStyles/adaptive-pages/profilemobile.css'
+import {eventBus} from "@/main";
export default {
components: { HeaderMobileComponent, MenuMobileComponent, PaymentsMobile },
@@ -57,6 +58,11 @@ export default {
this.imageUrl = `https://avatar.spworlds.ru/front/256/${this.username}`
}
},
+ mounted() {
+ eventBus.on("Updatebalance", () => {
+ this.updateBalanceMethod();
+ });
+ },
methods: {
paymetsCall(view) {
this.payments.paymentsWindow = true
@@ -64,7 +70,15 @@ export default {
},
paymentsClose() {
this.payments.paymentsWindow = false
- }
+ },
+ updateBalanceMethod() {
+ GetCurrentMoney(GetCookie("AUTHTOKEN"), GetCookie("SearchToken")).then(
+ (response) => {
+ this.balance = response.currentMoney;
+ }
+ );
+ eventBus.emit("Updatebalance-saper");
+ },
}
}