bug fix in referal link
This commit is contained in:
parent
e08a6621f1
commit
ec17a2f4df
|
@ -1,10 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<!-- هدر -->
|
<!-- هدر -->
|
||||||
<v-toolbar color="toolbar" flat>
|
<v-toolbar color="toolbar" flat>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-tooltip text="بازگشت" location="bottom">
|
<v-tooltip text="بازگشت" location="bottom">
|
||||||
<template v-slot:activator="{ props }">
|
<template v-slot:activator="{ props }">
|
||||||
<v-btn v-bind="props" @click="$router.back()" class="d-none d-sm-flex" variant="text" icon="mdi-arrow-right" />
|
<v-btn v-bind="props" @click="$router.back()" class="d-none d-sm-flex" variant="text"
|
||||||
|
icon="mdi-arrow-right" />
|
||||||
</template>
|
</template>
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
</template>
|
</template>
|
||||||
|
@ -16,46 +17,21 @@
|
||||||
ایجاد رابط جدید
|
ایجاد رابط جدید
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-toolbar>
|
</v-toolbar>
|
||||||
<v-text-field
|
<v-text-field v-model="search" prepend-inner-icon="mdi-magnify" label="جست و جو ..." variant="outlined"
|
||||||
v-model="search"
|
density="compact" hide-details class="mb-0" :rounded="0"></v-text-field>
|
||||||
prepend-inner-icon="mdi-magnify"
|
|
||||||
label="جست و جو ..."
|
|
||||||
variant="outlined"
|
|
||||||
density="compact"
|
|
||||||
hide-details
|
|
||||||
class="mb-0"
|
|
||||||
:rounded="0"
|
|
||||||
></v-text-field>
|
|
||||||
|
|
||||||
<!-- جدول -->
|
<!-- جدول -->
|
||||||
<v-data-table
|
<v-data-table :headers="headers" :items="items" :search="search" :loading="loading" hover
|
||||||
:headers="headers"
|
:header-props="{ class: 'custom-header' }" class="elevation-1">
|
||||||
:items="items"
|
|
||||||
:search="search"
|
|
||||||
:loading="loading"
|
|
||||||
hover
|
|
||||||
:header-props="{ class: 'custom-header' }"
|
|
||||||
|
|
||||||
class="elevation-1"
|
|
||||||
>
|
|
||||||
<!-- ستون عملیات -->
|
<!-- ستون عملیات -->
|
||||||
<template v-slot:item.operation="{ item }">
|
<template v-slot:item.operation="{ item }">
|
||||||
<v-btn
|
<v-btn icon="mdi-delete" color="error" size="small" variant="text" @click="deleteItem(item.raw.token)">
|
||||||
icon="mdi-delete"
|
|
||||||
color="error"
|
|
||||||
size="small"
|
|
||||||
variant="text"
|
|
||||||
@click="deleteItem(item.raw.token)"
|
|
||||||
>
|
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- لودینگ -->
|
<!-- لودینگ -->
|
||||||
<template v-slot:loading>
|
<template v-slot:loading>
|
||||||
<v-skeleton-loader
|
<v-skeleton-loader type="table-row" class="my-2"></v-skeleton-loader>
|
||||||
type="table-row"
|
|
||||||
class="my-2"
|
|
||||||
></v-skeleton-loader>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- پیام خالی بودن -->
|
<!-- پیام خالی بودن -->
|
||||||
|
|
|
@ -148,7 +148,7 @@ import { required } from "@vuelidate/validators";
|
||||||
import { useVuelidate } from "@vuelidate/core";
|
import { useVuelidate } from "@vuelidate/core";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import VueApexCharts from "vue3-apexcharts";
|
import VueApexCharts from "vue3-apexcharts";
|
||||||
|
import { getBasePath } from "@/hesabixConfig.js";
|
||||||
export default {
|
export default {
|
||||||
name: "Dashboard",
|
name: "Dashboard",
|
||||||
components: {
|
components: {
|
||||||
|
@ -261,15 +261,51 @@ export default {
|
||||||
this.errorDialog = true;
|
this.errorDialog = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
navigator.clipboard
|
|
||||||
.writeText(this.referralLink)
|
// روش اول: استفاده از Clipboard API
|
||||||
|
if (navigator.clipboard && window.isSecureContext) {
|
||||||
|
navigator.clipboard.writeText(this.referralLink)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.copySuccessDialog = true;
|
this.copySuccessDialog = true;
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
// اگر روش اول شکست خورد، از روش دوم استفاده میکنیم
|
||||||
|
this.fallbackCopyToClipboard(this.referralLink);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// اگر Clipboard API در دسترس نیست، از روش دوم استفاده میکنیم
|
||||||
|
this.fallbackCopyToClipboard(this.referralLink);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fallbackCopyToClipboard(text) {
|
||||||
|
try {
|
||||||
|
// ایجاد یک المان موقت
|
||||||
|
const textArea = document.createElement("textarea");
|
||||||
|
textArea.value = text;
|
||||||
|
|
||||||
|
// تنظیمات استایل برای مخفی کردن المان
|
||||||
|
textArea.style.position = 'fixed';
|
||||||
|
textArea.style.top = '0';
|
||||||
|
textArea.style.left = '0';
|
||||||
|
textArea.style.opacity = '0';
|
||||||
|
|
||||||
|
document.body.appendChild(textArea);
|
||||||
|
textArea.focus();
|
||||||
|
textArea.select();
|
||||||
|
|
||||||
|
// تلاش برای کپی کردن
|
||||||
|
const successful = document.execCommand('copy');
|
||||||
|
document.body.removeChild(textArea);
|
||||||
|
|
||||||
|
if (successful) {
|
||||||
|
this.copySuccessDialog = true;
|
||||||
|
} else {
|
||||||
|
throw new Error('Copy failed');
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
this.errorMessage = this.$t("user.copy_failed");
|
this.errorMessage = this.$t("user.copy_failed");
|
||||||
this.errorDialog = true;
|
this.errorDialog = true;
|
||||||
});
|
}
|
||||||
},
|
},
|
||||||
async fetchMarketingData() {
|
async fetchMarketingData() {
|
||||||
try {
|
try {
|
||||||
|
@ -321,17 +357,17 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
try {
|
|
||||||
const res = await axios.post("/api/user/current/info");
|
const res = await axios.post("/api/user/current/info");
|
||||||
this.user_email = res.data.email;
|
this.user_email = res.data.email;
|
||||||
this.user_fullname = res.data.fullname;
|
this.user_fullname = res.data.fullname;
|
||||||
this.user_mobile = res.data.mobile;
|
this.user_mobile = res.data.mobile;
|
||||||
this.referralCode = res.data.invateCode || "";
|
this.referralCode = res.data.invateCode || "";
|
||||||
this.referralLink = this.referralCode
|
this.referralLink = this.referralCode
|
||||||
? `${window.location.origin}/ms/${this.referralCode}`
|
? `${window.location.origin + getBasePath()}ms/${this.referralCode}`
|
||||||
: "";
|
: "";
|
||||||
await this.fetchMarketingData();
|
await this.fetchMarketingData();
|
||||||
} catch (error) {
|
try {} catch (error) {
|
||||||
this.errorMessage =
|
this.errorMessage =
|
||||||
error.response?.data?.message || this.$t("dialog.error_unknown");
|
error.response?.data?.message || this.$t("dialog.error_unknown");
|
||||||
this.errorDialog = true;
|
this.errorDialog = true;
|
||||||
|
|
Loading…
Reference in a new issue