update distribution

This commit is contained in:
AceDataCloud committed 2024-01-01 15:42:27 +08:00
1 parent 51dc05a655
commit 0525d87711
32 files changed
+1362 -252

No files matched your search

+15 -8
View File
@@ -7,9 +7,15 @@
</el-col>
</el-row>
<el-row>
<el-col :span="12" :offset="6">
<el-skeleton v-if="loading" />
<create-order v-else-if="application" :application="application" />
<el-col :span="24">
<el-card shadow="hover">
<el-row>
<el-col :span="12" :offset="6">
<el-skeleton v-if="loading" />
<create-order v-else-if="application" :application="application" />
</el-col>
</el-row>
</el-card>
</el-col>
</el-row>
</el-col>
@@ -33,7 +39,8 @@ export default defineComponent({
CreateOrder,
ElSkeleton,
ElRow,
ElCol
ElCol,
ElCard
},
data(): IData {
return {
@@ -77,10 +84,10 @@ export default defineComponent({
.panel {
padding: 30px;
width: calc(100% - 300px);
.credential {
.copy {
cursor: pointer;
}
background-color: #f3f5f6;
.el-card {
padding: 50px 0;
}
}
+52 -47
View File
@@ -8,50 +8,52 @@
</el-row>
<el-row>
<el-col :span="24">
<el-table v-loading="loading" :data="applications" stripe table-layout="fixed">
<el-table-column prop="id" :label="$t('application.field.id')" width="300px" class-name="text-center">
<template #default="scope">
<span>{{ scope.row.id }}</span>
<span class="copy">
<copy-to-clipboard :content="scope?.row?.id" />
</span>
</template>
</el-table-column>
<el-table-column :label="$t('application.field.name')" width="220px">
<template #default="scope">
<span v-if="scope.row.type === applicationType.API">{{ scope.row?.api?.title }}</span>
</template>
</el-table-column>
<el-table-column
prop="remaining_amount"
:label="$t('application.field.remainingAmount')"
width="120px"
class-name="text-center"
>
<template #default="scope">
<span>{{ getRemainingAmount(scope.row) }}</span>
</template>
</el-table-column>
<el-table-column
prop="used_amount"
:label="$t('application.field.usedAmount')"
width="120px"
class-name="text-center"
>
<template #default="scope">
<span>{{ getUsedAmount(scope.row) }}</span>
</template>
</el-table-column>
<el-table-column fixed="right" width="100px">
<template #default="scope">
<div class="float-right">
<el-button type="primary" @click="onBuyMore(scope?.row)">
{{ $t('application.button.buyMore') }}
</el-button>
</div>
</template>
</el-table-column>
</el-table>
<el-card shadow="hover">
<el-table v-loading="loading" :data="applications" stripe table-layout="fixed">
<el-table-column prop="id" :label="$t('application.field.id')" width="300px" class-name="text-center">
<template #default="scope">
<span>{{ scope.row.id }}</span>
<span class="copy">
<copy-to-clipboard :content="scope?.row?.id" />
</span>
</template>
</el-table-column>
<el-table-column :label="$t('application.field.name')" width="220px">
<template #default="scope">
<span v-if="scope.row.type === applicationType.API">{{ scope.row?.api?.title }}</span>
</template>
</el-table-column>
<el-table-column
prop="remaining_amount"
:label="$t('application.field.remainingAmount')"
width="120px"
class-name="text-center"
>
<template #default="scope">
<span>{{ getRemainingAmount(scope.row) }}</span>
</template>
</el-table-column>
<el-table-column
prop="used_amount"
:label="$t('application.field.usedAmount')"
width="120px"
class-name="text-center"
>
<template #default="scope">
<span>{{ getUsedAmount(scope.row) }}</span>
</template>
</el-table-column>
<el-table-column fixed="right" width="100px">
<template #default="scope">
<div class="float-right">
<el-button type="primary" @click="onBuyMore(scope?.row)">
{{ $t('application.button.buyMore') }}
</el-button>
</div>
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
<el-row>
@@ -76,7 +78,7 @@ import {
} from '@/operators';
import Pagination from '@/components/common/Pagination.vue';
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
import { ElTable, ElRow, ElCol, ElTableColumn, ElButton } from 'element-plus';
import { ElTable, ElRow, ElCol, ElTableColumn, ElButton, ElCard } from 'element-plus';
import { ROUTE_CONSOLE_APPLICATION_BUY } from '@/router/constants';
interface IData {
@@ -104,7 +106,8 @@ export default defineComponent({
ElRow,
ElCol,
ElTableColumn,
ElButton
ElButton,
ElCard
},
data(): IData {
return {
@@ -115,7 +118,7 @@ export default defineComponent({
total: undefined,
buying: false,
// dynamic calculate the limit according to window height
limit: Math.floor((window.innerHeight - 200) / 50),
limit: Math.floor((window.innerHeight - 300) / 50),
form: {
amount: 1
},
@@ -220,6 +223,8 @@ export default defineComponent({
.panel {
padding: 30px;
width: calc(100% - 300px);
background-color: #f3f5f6;
.title {
font-size: 26px;
font-weight: bold;
+190
View File
@@ -0,0 +1,190 @@
<template>
<el-row class="panel">
<el-col :span="24">
<el-row>
<el-col :span="24">
<h2 class="title">{{ $t('common.title.distributionHistory') }}</h2>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-card shadow="hover">
<el-table v-loading="loading" :data="distributionHistories" stripe>
<el-table-column prop="id" :label="$t('distribution.field.id')" class-name="text-center" width="350px">
<template #default="scope">
<span class="key">{{ scope.row.id }}</span>
<span class="copy">
<copy-to-clipboard :content="scope.row.id" />
</span>
</template>
</el-table-column>
<el-table-column
prop="id"
:label="$t('distribution.field.userId')"
class-name="text-center"
width="350px"
>
<template #default="scope">
<span class="key">{{ scope.row.user_id }}</span>
<span class="copy">
<copy-to-clipboard :content="scope.row.user_id" />
</span>
</template>
</el-table-column>
<el-table-column :label="$t('distribution.field.price')" width="100px">
<template #default="scope">
<span class="price">¥{{ scope.row?.price?.toFixed(2) }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('distribution.field.reward')" width="100px">
<template #default="scope">
<span class="description">¥{{ scope.row?.reward?.toFixed(2) }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('distribution.field.percentage')" width="100px">
<template #default="scope">
<span class="description">{{ scope.row.percentage }}%</span>
</template>
</el-table-column>
<el-table-column :label="$t('distribution.field.createdAt')" width="200px">
<template #default="scope">
<span class="created-at">{{ $dayjs.format(scope.row.created_at) }}</span>
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
<el-row>
<el-col :span="10" :offset="14">
<div class="pagination m-v-lg">
<pagination :current-page="page" :page-size="limit" :total="total" @change="onPageChange"> </pagination>
</div>
</el-col>
</el-row>
</el-col>
</el-row>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import Pagination from '@/components/common/Pagination.vue';
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
import { ElRow, ElCol, ElTable, ElTableColumn, ElButton, ElTag, ElCard } from 'element-plus';
import { distributionHistoryOperator, IDistributionHistory, IDistributionStatus } from '@/operators/distribution';
interface IData {
distributionHistories: IDistributionHistory[];
distributionStatus: IDistributionStatus | undefined;
loading: boolean;
total: number | undefined;
limit: number;
}
export default defineComponent({
name: 'ConsoleDistributionList',
components: {
Pagination,
CopyToClipboard,
ElRow,
ElCol,
ElTable,
ElTableColumn,
ElCard
},
data(): IData {
return {
distributionHistories: [],
distributionStatus: undefined,
loading: false,
total: undefined,
limit: 10
};
},
computed: {
redirect() {
return this.$route.query.redirect;
},
page() {
return parseInt(this.$route.query.page?.toString() || '1');
}
},
watch: {
page: {
handler() {
this.onFetchData();
}
}
},
mounted() {
this.onFetchData();
},
methods: {
onPageChange(page: number) {
this.$router.push({
name: this.$route.name?.toString(),
query: {
page: page
}
});
},
onFetchData() {
this.loading = true;
Promise.all([this.onFetchDistributionHistory()]).finally(() => {
this.loading = false;
});
},
async onFetchDistributionHistory() {
const { data } = await distributionHistoryOperator.getAll({
user_id: this.$store.getters.user.id,
ordering: '-created_at',
limit: this.limit,
offset: (this.page - 1) * this.limit
});
this.distributionHistories = data.items;
this.total = data.count;
}
}
});
</script>
<style lang="scss" scoped>
.title {
font-size: 26px;
font-weight: bold;
margin-bottom: 20px;
color: #333;
}
.item-mini {
.value {
font-weight: 600;
font-size: 40px;
}
.description {
color: #999;
font-size: 14px;
}
}
.el-table {
min-height: calc(100vh - 300px);
margin-bottom: 50px;
}
.panel {
padding: 30px;
width: calc(100% - 300px);
background-color: #f3f5f6;
.api-key {
.copy {
cursor: pointer;
margin: 0 10px;
}
}
}
.pagination {
float: right;
}
</style>
+420
View File
@@ -0,0 +1,420 @@
<template>
<el-row class="panel">
<el-col :span="24">
<el-row>
<el-col :span="24">
<h2 class="title">{{ $t('common.title.distribution') }}</h2>
<p class="message mb-4">
{{ $t('distribution.message.distributionDescription') }}
</p>
</el-col>
</el-row>
<el-row :gutter="15">
<el-col :md="6" :xs="24">
<el-card shadow="hover" class="item-mini mb-4">
<el-skeleton v-if="loading" />
<div v-else>
<div class="icon-wrapper">
<font-awesome-icon icon="fa-solid fa-wallet" class="icon" />
</div>
<div class="text-left">
<p class="description">{{ $t('distribution.title.price') }}</p>
<p class="value">¥{{ distributionStatus?.price?.toFixed(2) }}</p>
</div>
<el-button type="primary" class="btn" @click="goHistory"
>{{ $t('distribution.button.detail') }}
</el-button>
</div>
</el-card>
</el-col>
<el-col :md="6" :xs="24">
<el-card shadow="hover" class="item-mini mb-4">
<el-skeleton v-if="loading" />
<div v-else>
<div class="icon-wrapper">
<font-awesome-icon icon="fa-solid fa-coins" class="icon" />
</div>
<div class="text-left">
<p class="description">{{ $t('distribution.title.reward') }}</p>
<p class="value">¥{{ distributionStatus?.reward?.toFixed(2) }}</p>
</div>
<el-tooltip effect="dark" :content="$t('distribution.message.howToWithdrawal')" placement="top">
<el-button type="primary" class="btn">{{ $t('distribution.button.withdrawal') }} </el-button>
</el-tooltip>
</div>
</el-card>
</el-col>
<el-col :md="6" :xs="24">
<el-card shadow="hover" class="item-mini mb-4">
<el-skeleton v-if="loading" />
<div v-else>
<div class="icon-wrapper">
<font-awesome-icon icon="fa-solid fa-percent" class="icon" />
</div>
<div class="text-left">
<p class="description">{{ $t('distribution.title.percentage') }}</p>
<p class="value">{{ distributionStatus?.level?.percentage }}%</p>
</div>
</div>
</el-card>
</el-col>
<el-col :md="6" :xs="24">
<el-card shadow="hover" class="item-mini mb-4">
<el-skeleton v-if="loading" />
<div v-else>
<div class="icon-wrapper">
<font-awesome-icon icon="fa-regular fa-user" class="icon" />
</div>
<div class="text-left">
<p class="description">{{ $t('distribution.title.inviteesCount') }}</p>
<p class="value">{{ inviteesCount }}</p>
</div>
<el-button type="primary" class="btn" @click="goInvitees"
>{{ $t('distribution.button.detail') }}
</el-button>
</div>
</el-card>
</el-col>
</el-row>
<el-row :gutter="15">
<el-col :md="12" :xs="24">
<el-card shadow="hover" class="distribution-info mb-4">
<el-skeleton v-if="loading" />
<div v-else>
<h4 class="title">
{{ $t('distribution.title.distributionLink') }}
</h4>
<el-divider />
<div class="link-wrapper">
<font-awesome-icon v-if="false" icon="fa-solid fa-link" class="icon" />
<a :href="distributionLink" class="link">
{{ distributionLink }}
</a>
<copy-to-clipboard :content="distributionLink" />
</div>
<div class="qr-wrapper">
<qr-code v-if="distributionLink" :value="distributionLink" :size="150" class="mb-2 ml-auto mr-auto" />
<p>
{{ $t('distribution.message.distributionQrDescription') }}
</p>
</div>
<p class="description">
{{ $t('distribution.message.distributionLinkDescription') }}
<span class="more">
<el-tooltip
effect="dark"
:content="$t('distribution.message.distributionLinkDescription2')"
placement="top"
>
{{ $t('distribution.message.technicalDetail') }}
</el-tooltip>
</span>
</p>
</div>
</el-card>
</el-col>
<el-col :md="12" :xs="24">
<el-card shadow="hover" class="level-info mb-4">
<el-skeleton v-if="loading" />
<div v-else>
<h4 class="title">
{{ $t('distribution.title.levelInfo') }}
</h4>
<div class="clear-both overflow-hidden">
<div class="float-left description">
<p>{{ $t('distribution.title.currentLevel') }}: L{{ distributionStatus?.level?.level }}</p>
<p>
{{ $t('distribution.title.currentPercentage') }}:
{{ distributionLevelMap[distributionStatus?.level?.level!]?.percentage }}%
</p>
</div>
<div class="float-right description">
<p>{{ $t('distribution.title.nextLevel') }}: L{{ distributionStatus?.level?.level! + 1 }}</p>
<p>
{{ $t('distribution.title.nextPercentage') }}:
{{ distributionLevelMap[distributionStatus?.level?.level! + 1]?.percentage }}%
</p>
</div>
</div>
<el-progress
:text-inside="true"
:stroke-width="20"
:percentage="getPercentageForNextLevel()"
class="mb-2"
>
</el-progress>
<p class="description">
{{ $t('distribution.message.deltaPriceForNextLevel') }}: ¥{{ getDeltaForNextLevel() }}
</p>
<el-divider />
<el-table v-if="distributionLevels" :data="distributionLevels" stripe>
<el-table-column :label="$t('distribution.field.level')">
<template #default="scope">
<span class="level">L{{ scope.row?.level }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('distribution.field.threshold')">
<template #default="scope">
<span class="level">¥{{ scope.row?.threshold }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('distribution.field.percentage')">
<template #default="scope">
<span class="level">{{ scope.row?.percentage }}%</span>
</template>
</el-table-column>
</el-table>
</div>
</el-card>
</el-col>
</el-row>
</el-col>
</el-row>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
import {
ElRow,
ElCol,
ElProgress,
ElTable,
ElTableColumn,
ElButton,
ElCard,
ElDivider,
ElInput,
ElTooltip,
ElSkeleton
} from 'element-plus';
import {
distributionLevelOperator,
distributionStatusOperator,
IDistributionLevel,
IDistributionStatus
} from '@/operators/distribution';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { ROUTE_CONSOLE_DISTRIBUTION_HISTORY, ROUTE_CONSOLE_DISTRIBUTION_INVITEES } from '@/router';
import { IUser, userOperator } from '@/operators';
import QrCode from 'qrcode.vue';
interface IData {
invitees: IUser[];
inviteesCount: number | undefined;
distributionLevels: IDistributionLevel[];
distributionStatus: IDistributionStatus | undefined;
loading: boolean;
}
export default defineComponent({
name: 'ConsoleDistributionList',
components: {
CopyToClipboard,
FontAwesomeIcon,
QrCode,
ElProgress,
ElRow,
ElCol,
ElButton,
ElDivider,
ElCard,
ElTooltip,
ElTable,
ElTableColumn,
ElSkeleton
},
data(): IData {
return {
invitees: [],
inviteesCount: undefined,
distributionLevels: [],
distributionStatus: undefined,
loading: false
};
},
computed: {
redirect() {
return this.$route.query.redirect;
},
page() {
return parseInt(this.$route.query.page?.toString() || '1');
},
distributionLevelMap() {
let result: {
[key: number]: IDistributionLevel;
} = {};
this.distributionLevels.forEach((item) => {
result[item.level] = item;
});
return result;
},
distributionLink() {
const origin = window.location.origin;
const newOrigin = origin.replace('data.', 'auth.');
return `${newOrigin}/auth/login?inviter_id=${this.$store.getters.user.id}&redirect=${origin}`;
}
},
watch: {
page: {
handler() {
this.onFetchData();
}
}
},
async mounted() {
this.onFetchData();
},
methods: {
goHistory() {
this.$router.push({
name: ROUTE_CONSOLE_DISTRIBUTION_HISTORY
});
},
goInvitees() {
this.$router.push({
name: ROUTE_CONSOLE_DISTRIBUTION_INVITEES
});
},
onPageChange(page: number) {
this.$router.push({
name: this.$route.name?.toString(),
query: {
page: page
}
});
},
getPercentageForNextLevel() {
const currentThreshold = this.distributionLevelMap[this.distributionStatus?.level?.level!]?.threshold;
const nextThreshold = this.distributionLevelMap[this.distributionStatus?.level?.level! + 1]?.threshold;
return Math.floor(
((this.distributionStatus?.price! - currentThreshold!) / (nextThreshold! - currentThreshold!)) * 100
);
},
getDeltaForNextLevel() {
const nextThreshold = this.distributionLevelMap[this.distributionStatus?.level?.level! + 1]?.threshold;
return Math.floor(nextThreshold - this.distributionStatus?.price!);
},
async onFetchData() {
this.loading = true;
await distributionStatusOperator.initialize();
Promise.all([this.onFetchDistributionStatus(), this.onFetchDistributionLevels(), this.onFetchInvitees()]).finally(
() => {
this.loading = false;
}
);
},
async onFetchDistributionStatus() {
const { data } = await distributionStatusOperator.getAll({
user_id: this.$store.getters.user.id
});
if (data.items && data.items.length > 0) {
this.distributionStatus = data.items[0];
}
},
async onFetchDistributionLevels() {
const { data } = await distributionLevelOperator.getAll();
this.distributionLevels = data.items;
},
async onFetchInvitees() {
const { data } = await userOperator.getInvitees({});
this.invitees = data.items;
this.inviteesCount = data.count;
}
}
});
</script>
<style lang="scss" scoped>
.title {
font-size: 26px;
font-weight: bold;
margin-bottom: 20px;
color: #333;
}
.item-mini {
position: relative;
.icon-wrapper {
height: 40px;
width: 40px;
line-height: 40px;
border-radius: 50%;
background-color: #eee;
text-align: center;
margin-bottom: 10px;
.icon {
color: var(--el-color-primary);
}
}
.btn {
position: absolute;
right: 20px;
top: 50%;
border-radius: 20px;
transform: translateY(-50%);
}
.value {
font-weight: 600;
font-size: 30px;
}
.description {
color: #999;
font-size: 14px;
}
}
.level-info,
.distribution-info {
.title {
font-size: 20px;
font-weight: bold;
margin-bottom: 20px;
color: #333;
}
.icon {
margin-right: 5px;
}
.qr-wrapper {
padding: 15px 0;
p {
text-align: center;
color: #999;
font-size: 12px;
}
}
.link-wrapper {
margin-bottom: 10px;
.link {
color: var(--el-color-primary);
cursor: pointer;
text-decoration: dashed;
font-size: 14px;
margin-bottom: 10px;
}
}
.description {
color: #999;
font-size: 14px;
margin-bottom: 10px;
.more {
color: var(--el-color-primary);
cursor: pointer;
}
}
}
.panel {
padding: 30px;
width: calc(100% - 300px);
background-color: #f3f5f6;
.message {
font-size: 14px;
color: #666;
}
}
</style>
+167
View File
@@ -0,0 +1,167 @@
<template>
<el-row class="panel">
<el-col :span="24">
<el-row>
<el-col :span="24">
<h2 class="title">{{ $t('common.title.invitee') }}</h2>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-card shadow="hover">
<el-table v-loading="loading" :data="invitees" stripe>
<el-table-column prop="id" :label="$t('user.field.id')" class-name="text-center" width="350px">
<template #default="scope">
<span class="key">{{ scope.row.id }}</span>
<span class="copy">
<copy-to-clipboard :content="scope.row.id" />
</span>
</template>
</el-table-column>
<el-table-column :label="$t('user.field.username')" width="300px">
<template #default="scope">
<span class="description">{{ scope.row?.username }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('user.field.nickname')" width="200px">
<template #default="scope">
<span class="description">{{ scope.row.nickname }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('user.field.isVerified')" width="100px">
<template #default="scope">
<el-switch :model-value="scope.row?.is_verified" />
</template>
</el-table-column>
<el-table-column :label="$t('user.field.dateJoined')">
<template #default="scope">
<span class="created-at">{{ $dayjs.format(scope.row.date_joined) }}</span>
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
<el-row>
<el-col :span="10" :offset="14">
<div class="pagination m-v-lg">
<pagination :current-page="page" :page-size="limit" :total="total" @change="onPageChange"> </pagination>
</div>
</el-col>
</el-row>
</el-col>
</el-row>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import Pagination from '@/components/common/Pagination.vue';
import CopyToClipboard from '@/components/common/CopyToClipboard.vue';
import { ElRow, ElCol, ElTable, ElTableColumn, ElCard, ElSwitch } from 'element-plus';
import { IUser, userOperator } from '@/operators';
interface IData {
invitees: IUser[];
loading: boolean;
total: number | undefined;
limit: number;
}
export default defineComponent({
name: 'ConsoleDistributionInvitees',
components: {
Pagination,
CopyToClipboard,
ElRow,
ElSwitch,
ElCol,
ElTable,
ElTableColumn,
ElCard
},
data(): IData {
return {
invitees: [],
loading: false,
total: undefined,
limit: 10
};
},
computed: {
redirect() {
return this.$route.query.redirect;
},
page() {
return parseInt(this.$route.query.page?.toString() || '1');
}
},
watch: {
page: {
handler() {
this.onFetchData();
}
}
},
mounted() {
this.onFetchData();
},
methods: {
onPageChange(page: number) {
this.$router.push({
name: this.$route.name?.toString(),
query: {
page: page
}
});
},
onFetchData() {
this.loading = true;
Promise.all([this.onFetchInvitees()]).finally(() => {
this.loading = false;
});
},
async onFetchInvitees() {
const { data } = await userOperator.getInvitees({
limit: this.limit,
offset: (this.page - 1) * this.limit
});
this.invitees = data.items;
this.total = data.count;
}
}
});
</script>
<style lang="scss" scoped>
.title {
font-size: 26px;
font-weight: bold;
margin-bottom: 20px;
color: #333;
}
.item-mini {
.value {
font-weight: 600;
font-size: 40px;
}
.description {
color: #999;
font-size: 14px;
}
}
.el-table {
min-height: calc(100vh - 300px);
margin-bottom: 50px;
}
.panel {
padding: 30px;
width: calc(100% - 300px);
background-color: #f3f5f6;
}
.pagination {
float: right;
}
</style>
+111 -102
View File
@@ -7,107 +7,113 @@
</el-col>
</el-row>
<el-row>
<el-col :span="12" :offset="6">
<div v-if="loading" class="pt-5">
<el-skeleton animated />
</div>
<div v-else class="order">
<el-descriptions :column="1">
<el-descriptions-item :label="$t('order.field.id')">{{ order?.id }}</el-descriptions-item>
<el-descriptions-item :label="$t('order.field.description')">
{{ order?.description }}
</el-descriptions-item>
<el-descriptions-item
v-if="order?.application?.type === applicationType.API"
:label="$t('order.field.api')"
>
{{ order?.application?.api?.title }}
</el-descriptions-item>
<el-descriptions-item :label="$t('order.field.amount')">
<span v-if="order?.application?.type === applicationType.API">
{{ order?.amount }}{{ $t(`api.unit.${order?.application?.api?.unit}`) }}
</span>
</el-descriptions-item>
<el-descriptions-item :label="$t('order.field.createdAt')">
{{ $dayjs.format(order?.created_at) }}
</el-descriptions-item>
<el-descriptions-item :label="$t('order.field.price')">
<span v-if="order?.price && order?.price > 0" class="price unfree">
¥{{ order?.price?.toFixed(2) }}
</span>
<span v-else class="price free"> {{ $t('order.message.free') }} </span>
</el-descriptions-item>
<el-descriptions-item v-if="order?.pay_way" :label="$t('order.field.payWay')">
<span v-if="order?.pay_way === PayWay.WechatPay">
{{ $t('order.title.wechatPay') }}
</span>
<span v-if="order?.pay_way === PayWay.AliPay">
{{ $t('order.title.aliPay') }}
</span>
<span v-if="order?.pay_way === PayWay.Stripe">
{{ $t('order.title.stripe') }}
</span>
</el-descriptions-item>
</el-descriptions>
</div>
</el-col>
</el-row>
<el-row v-if="order?.state === OrderState.PAID" class="mb-5">
<el-col :span="12" :offset="6">
<el-divider border-style="dashed" />
<el-alert :title="$t('order.message.paidSuccessfully')" type="success" show-icon :closable="false" />
</el-col>
</el-row>
<el-row v-if="order?.state === OrderState.PENDING || order?.state === OrderState.FAILED">
<el-col :span="12" :offset="6">
<el-divider border-style="dashed" />
<div v-if="order.price && order.price > 0 && !order.pay_way" class="payways mb-4">
<div
:class="{
payway: true,
wechatpay: true,
active: payWay === PayWay.WechatPay
}"
@click="payWay = PayWay.WechatPay"
>
<span class="payicon wechatpay"></span>
{{ $t('order.title.wechatPay') }}
</div>
<div
v-if="false"
:class="{
payway: true,
alipay: true,
active: payWay === PayWay.AliPay
}"
@click="payWay = PayWay.AliPay"
>
<span class="payicon alipay"></span>
{{ $t('order.title.aliPay') }}
</div>
<div
v-if="false"
:class="{
payway: true,
stripe: true,
active: payWay === PayWay.Stripe
}"
@click="payWay = PayWay.Stripe"
>
<span class="payicon stripe"></span>
{{ $t('order.title.stripe') }}
</div>
</div>
<div v-if="!order?.pay_way">
<el-button :loading="prepaying" type="primary" size="large" class="btn-pay" @click="onPay">{{
$t('common.button.pay')
}}</el-button>
</div>
<div v-else>
<el-button type="primary" size="large" class="btn-repay" @click="onRepay">{{
$t('common.button.repay')
}}</el-button>
</div>
<el-col :span="24">
<el-card shadow="hover">
<el-row>
<el-col :span="12" :offset="6">
<div v-if="loading" class="pt-5">
<el-skeleton animated />
</div>
<div v-else class="order">
<el-descriptions :column="1">
<el-descriptions-item :label="$t('order.field.id')">{{ order?.id }}</el-descriptions-item>
<el-descriptions-item :label="$t('order.field.description')">
{{ order?.description }}
</el-descriptions-item>
<el-descriptions-item
v-if="order?.application?.type === applicationType.API"
:label="$t('order.field.api')"
>
{{ order?.application?.api?.title }}
</el-descriptions-item>
<el-descriptions-item :label="$t('order.field.amount')">
<span v-if="order?.application?.type === applicationType.API">
{{ order?.amount }}{{ $t(`api.unit.${order?.application?.api?.unit}`) }}
</span>
</el-descriptions-item>
<el-descriptions-item :label="$t('order.field.createdAt')">
{{ $dayjs.format(order?.created_at) }}
</el-descriptions-item>
<el-descriptions-item :label="$t('order.field.price')">
<span v-if="order?.price && order?.price > 0" class="price unfree">
¥{{ order?.price?.toFixed(2) }}
</span>
<span v-else class="price free"> {{ $t('order.message.free') }} </span>
</el-descriptions-item>
<el-descriptions-item v-if="order?.pay_way" :label="$t('order.field.payWay')">
<span v-if="order?.pay_way === PayWay.WechatPay">
{{ $t('order.title.wechatPay') }}
</span>
<span v-if="order?.pay_way === PayWay.AliPay">
{{ $t('order.title.aliPay') }}
</span>
<span v-if="order?.pay_way === PayWay.Stripe">
{{ $t('order.title.stripe') }}
</span>
</el-descriptions-item>
</el-descriptions>
</div>
</el-col>
</el-row>
<el-row v-if="order?.state === OrderState.PAID" class="mb-5">
<el-col :span="12" :offset="6">
<el-divider border-style="dashed" />
<el-alert :title="$t('order.message.paidSuccessfully')" type="success" show-icon :closable="false" />
</el-col>
</el-row>
<el-row v-if="order?.state === OrderState.PENDING || order?.state === OrderState.FAILED">
<el-col :span="12" :offset="6">
<el-divider border-style="dashed" />
<div v-if="order.price && order.price > 0 && !order.pay_way" class="payways mb-4">
<div
:class="{
payway: true,
wechatpay: true,
active: payWay === PayWay.WechatPay
}"
@click="payWay = PayWay.WechatPay"
>
<span class="payicon wechatpay"></span>
{{ $t('order.title.wechatPay') }}
</div>
<div
v-if="false"
:class="{
payway: true,
alipay: true,
active: payWay === PayWay.AliPay
}"
@click="payWay = PayWay.AliPay"
>
<span class="payicon alipay"></span>
{{ $t('order.title.aliPay') }}
</div>
<div
v-if="false"
:class="{
payway: true,
stripe: true,
active: payWay === PayWay.Stripe
}"
@click="payWay = PayWay.Stripe"
>
<span class="payicon stripe"></span>
{{ $t('order.title.stripe') }}
</div>
</div>
<div v-if="!order?.pay_way">
<el-button :loading="prepaying" type="primary" size="large" class="btn-pay" @click="onPay">{{
$t('common.button.pay')
}}</el-button>
</div>
<div v-else>
<el-button type="primary" size="large" class="btn-repay" @click="onRepay">{{
$t('common.button.repay')
}}</el-button>
</div>
</el-col>
</el-row>
</el-card>
</el-col>
</el-row>
</el-col>
@@ -132,7 +138,8 @@ import {
ElAlert,
ElDescriptions,
ElDescriptionsItem,
ElButton
ElButton,
ElCard
} from 'element-plus';
import WechatPayOrder from '@/components/order/WechatPay.vue';
import StripePayOrder from '@/components/order/StripePay.vue';
@@ -160,6 +167,7 @@ export default defineComponent({
components: {
ElButton,
ElRow,
ElCard,
ElCol,
ElSkeleton,
ElDivider,
@@ -252,6 +260,7 @@ export default defineComponent({
.panel {
padding: 30px;
width: calc(100% - 300px);
background-color: #f3f5f6;
.title {
font-size: 26px;
+80 -75
View File
@@ -8,80 +8,82 @@
</el-row>
<el-row>
<el-col :span="24">
<el-table v-loading="loading" :data="orders" stripe>
<el-table-column prop="id" :label="$t('order.field.id')" class-name="text-center" width="350px">
<template #default="scope">
<span class="key">{{ scope.row.id }}</span>
<span class="copy">
<copy-to-clipboard :content="scope.row.id" />
</span>
</template>
</el-table-column>
<el-table-column :label="$t('order.field.price')" width="100px">
<template #default="scope">
<span class="price">¥{{ scope.row?.price?.toFixed(2) }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('order.field.createdAt')" width="180px">
<template #default="scope">
<span class="created-at">{{ $dayjs.format(scope.row.created_at) }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('order.field.description')" width="300px">
<template #default="scope">
<span class="description">{{ scope.row.description }}</span>
</template>
</el-table-column>
<el-table-column prop="state" :label="$t('order.field.state')" class-name="text-center">
<template #default="scope">
<span v-if="scope.row.state === OrderState?.PENDING">
<el-tag type="info" class="mx-1" effect="dark">{{ $t('order.state.pending') }}</el-tag>
</span>
<span v-else-if="scope.row.state === OrderState?.PAID" class="state state-paid">
<el-tag type="success" class="mx-1" effect="dark">{{ $t('order.state.paid') }}</el-tag>
</span>
<span v-else-if="scope.row.state === OrderState?.EXPIRED" class="state state-expired">
<el-tag type="warning" class="mx-1" effect="dark">{{ $t('order.state.expired') }}</el-tag>
</span>
<span v-else-if="scope.row.state === OrderState?.FAILED" class="state state-failed">
<el-tag type="danger" class="mx-1" effect="dark"> {{ $t('order.state.failed') }}</el-tag>
</span>
</template>
</el-table-column>
<el-table-column min-width="120px">
<template #default="scope">
<div class="float-right">
<el-button
v-if="scope.row.state !== OrderState.PAID"
type="primary"
@click="
$router.push({
name: 'console-order-detail',
params: {
id: scope.row.id
}
})
"
>
{{ $t('order.button.continuePay') }}
</el-button>
<el-button
v-else
@click="
$router.push({
name: 'console-order-detail',
params: {
id: scope.row.id
}
})
"
>
{{ $t('order.button.checkDetail') }}
</el-button>
</div>
</template>
</el-table-column>
</el-table>
<el-card shadow="hover">
<el-table v-loading="loading" :data="orders" stripe>
<el-table-column prop="id" :label="$t('order.field.id')" class-name="text-center" width="350px">
<template #default="scope">
<span class="key">{{ scope.row.id }}</span>
<span class="copy">
<copy-to-clipboard :content="scope.row.id" />
</span>
</template>
</el-table-column>
<el-table-column :label="$t('order.field.price')" width="100px">
<template #default="scope">
<span class="price">¥{{ scope.row?.price?.toFixed(2) }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('order.field.createdAt')" width="180px">
<template #default="scope">
<span class="created-at">{{ $dayjs.format(scope.row.created_at) }}</span>
</template>
</el-table-column>
<el-table-column :label="$t('order.field.description')" width="300px">
<template #default="scope">
<span class="description">{{ scope.row.description }}</span>
</template>
</el-table-column>
<el-table-column prop="state" :label="$t('order.field.state')" class-name="text-center">
<template #default="scope">
<span v-if="scope.row.state === OrderState?.PENDING">
<el-tag type="info" class="mx-1" effect="dark">{{ $t('order.state.pending') }}</el-tag>
</span>
<span v-else-if="scope.row.state === OrderState?.PAID" class="state state-paid">
<el-tag type="success" class="mx-1" effect="dark">{{ $t('order.state.paid') }}</el-tag>
</span>
<span v-else-if="scope.row.state === OrderState?.EXPIRED" class="state state-expired">
<el-tag type="warning" class="mx-1" effect="dark">{{ $t('order.state.expired') }}</el-tag>
</span>
<span v-else-if="scope.row.state === OrderState?.FAILED" class="state state-failed">
<el-tag type="danger" class="mx-1" effect="dark"> {{ $t('order.state.failed') }}</el-tag>
</span>
</template>
</el-table-column>
<el-table-column min-width="120px">
<template #default="scope">
<div class="float-right">
<el-button
v-if="scope.row.state !== OrderState.PAID"
type="primary"
@click="
$router.push({
name: 'console-order-detail',
params: {
id: scope.row.id
}
})
"
>
{{ $t('order.button.continuePay') }}
</el-button>
<el-button
v-else
@click="
$router.push({
name: 'console-order-detail',
params: {
id: scope.row.id
}
})
"
>
{{ $t('order.button.checkDetail') }}
</el-button>
</div>
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
<el-row>
@@ -120,7 +122,8 @@ export default defineComponent({
ElTable,
ElTableColumn,
ElButton,
ElTag
ElTag,
ElCard
},
data(): IData {
return {
@@ -185,6 +188,8 @@ export default defineComponent({
.panel {
padding: 30px;
width: calc(100% - 300px);
background-color: #f3f5f6;
.title {
font-size: 26px;
font-weight: bold;