bug fix in referal link
This commit is contained in:
parent
e08a6621f1
commit
ec17a2f4df
|
@ -4,7 +4,8 @@
|
|||
<template v-slot:prepend>
|
||||
<v-tooltip text="بازگشت" location="bottom">
|
||||
<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>
|
||||
</v-tooltip>
|
||||
</template>
|
||||
|
@ -16,46 +17,21 @@
|
|||
ایجاد رابط جدید
|
||||
</v-btn>
|
||||
</v-toolbar>
|
||||
<v-text-field
|
||||
v-model="search"
|
||||
prepend-inner-icon="mdi-magnify"
|
||||
label="جست و جو ..."
|
||||
variant="outlined"
|
||||
density="compact"
|
||||
hide-details
|
||||
class="mb-0"
|
||||
:rounded="0"
|
||||
></v-text-field>
|
||||
<v-text-field v-model="search" prepend-inner-icon="mdi-magnify" label="جست و جو ..." variant="outlined"
|
||||
density="compact" hide-details class="mb-0" :rounded="0"></v-text-field>
|
||||
|
||||
<!-- جدول -->
|
||||
<v-data-table
|
||||
:headers="headers"
|
||||
:items="items"
|
||||
:search="search"
|
||||
:loading="loading"
|
||||
hover
|
||||
:header-props="{ class: 'custom-header' }"
|
||||
|
||||
class="elevation-1"
|
||||
>
|
||||
<v-data-table :headers="headers" :items="items" :search="search" :loading="loading" hover
|
||||
:header-props="{ class: 'custom-header' }" class="elevation-1">
|
||||
<!-- ستون عملیات -->
|
||||
<template v-slot:item.operation="{ item }">
|
||||
<v-btn
|
||||
icon="mdi-delete"
|
||||
color="error"
|
||||
size="small"
|
||||
variant="text"
|
||||
@click="deleteItem(item.raw.token)"
|
||||
>
|
||||
<v-btn icon="mdi-delete" color="error" size="small" variant="text" @click="deleteItem(item.raw.token)">
|
||||
</v-btn>
|
||||
</template>
|
||||
|
||||
<!-- لودینگ -->
|
||||
<template v-slot:loading>
|
||||
<v-skeleton-loader
|
||||
type="table-row"
|
||||
class="my-2"
|
||||
></v-skeleton-loader>
|
||||
<v-skeleton-loader type="table-row" class="my-2"></v-skeleton-loader>
|
||||
</template>
|
||||
|
||||
<!-- پیام خالی بودن -->
|
||||
|
|
|
@ -148,7 +148,7 @@ import { required } from "@vuelidate/validators";
|
|||
import { useVuelidate } from "@vuelidate/core";
|
||||
import { ref } from "vue";
|
||||
import VueApexCharts from "vue3-apexcharts";
|
||||
|
||||
import { getBasePath } from "@/hesabixConfig.js";
|
||||
export default {
|
||||
name: "Dashboard",
|
||||
components: {
|
||||
|
@ -261,15 +261,51 @@ export default {
|
|||
this.errorDialog = true;
|
||||
return;
|
||||
}
|
||||
navigator.clipboard
|
||||
.writeText(this.referralLink)
|
||||
|
||||
// روش اول: استفاده از Clipboard API
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
navigator.clipboard.writeText(this.referralLink)
|
||||
.then(() => {
|
||||
this.copySuccessDialog = true;
|
||||
})
|
||||
.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.errorDialog = true;
|
||||
});
|
||||
}
|
||||
},
|
||||
async fetchMarketingData() {
|
||||
try {
|
||||
|
@ -321,17 +357,17 @@ export default {
|
|||
},
|
||||
},
|
||||
async mounted() {
|
||||
try {
|
||||
|
||||
const res = await axios.post("/api/user/current/info");
|
||||
this.user_email = res.data.email;
|
||||
this.user_fullname = res.data.fullname;
|
||||
this.user_mobile = res.data.mobile;
|
||||
this.referralCode = res.data.invateCode || "";
|
||||
this.referralLink = this.referralCode
|
||||
? `${window.location.origin}/ms/${this.referralCode}`
|
||||
? `${window.location.origin + getBasePath()}ms/${this.referralCode}`
|
||||
: "";
|
||||
await this.fetchMarketingData();
|
||||
} catch (error) {
|
||||
try {} catch (error) {
|
||||
this.errorMessage =
|
||||
error.response?.data?.message || this.$t("dialog.error_unknown");
|
||||
this.errorDialog = true;
|
||||
|
|
Loading…
Reference in a new issue