remove unused

This commit is contained in:
AceDataCloud committed 2023-04-07 13:05:35 +08:00
1 parent 301dab1ca5
commit ea1c3413a5
88 files changed
+29 -5766

No files matched your search

-307
View File
@@ -1,307 +0,0 @@
<template>
<el-row class="wrapper">
<el-col :span="24">
<el-row>
<el-col :span="24">
<h2 class="title">{{ $t('order.title.info') }}</h2>
</el-col>
</el-row>
<el-row class="panel">
<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
v-if="order?.application?.type === applicationType.PROXY"
:label="$t('order.field.proxy')"
>
{{ order?.application?.proxy?.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>
<span v-if="order?.application?.type === applicationType.PROXY">
{{ order?.amount }}{{ $t(`proxy.unit.${order?.application?.proxy?.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>
</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>
<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>
</el-row>
<pay-order v-if="order" v-model="order" :visible="paying" @hide="paying = false" />
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { IOrder, IOrderDetailResponse, orderOperator, OrderState } from '@/operators/order';
import {
ElRow,
ElCol,
ElCard,
ElSkeleton,
ElDivider,
ElAlert,
ElDescriptions,
ElDescriptionsItem,
ElButton
} from 'element-plus';
import PayOrder from '@/components/order/Pay.vue';
import { IApplicationType } from '@/operators';
enum PayWay {
WechatPay = 'WechatPay',
AliPay = 'AliPay'
}
interface IData {
PayWay: typeof PayWay;
OrderState: typeof OrderState;
payWay: PayWay | undefined;
order: IOrder | undefined;
loading: boolean;
paying: boolean;
prepaying: boolean;
applicationType: typeof IApplicationType;
}
export default defineComponent({
name: 'ConsoleOrderDetail',
components: {
ElButton,
ElRow,
ElCol,
ElCard,
ElSkeleton,
ElDivider,
ElAlert,
ElDescriptions,
ElDescriptionsItem,
PayOrder
},
data(): IData {
return {
PayWay: PayWay,
payWay: PayWay.WechatPay,
OrderState: OrderState,
order: undefined,
loading: false,
paying: false,
prepaying: false,
applicationType: IApplicationType
};
},
computed: {
id() {
return this.$route.params?.id?.toString();
},
redirect() {
return this.$route.query?.redirect;
}
},
watch: {
order: {
handler(val) {
if (val?.state === OrderState.PAID) {
setTimeout(() => {
if (this.redirect) {
window.location.replace(this.redirect?.toString());
}
}, 2000);
return;
}
},
deep: true
}
},
mounted() {
this.onFetchData();
},
methods: {
onFetchData() {
this.loading = true;
orderOperator
.refresh(this.id)
.then(({ data: data }: { data: IOrderDetailResponse }) => {
this.order = data;
this.loading = false;
})
.catch(() => {
this.loading = false;
});
},
onRepay() {
this.paying = true;
},
onPay() {
this.prepaying = true;
orderOperator
.pay(this.id, {
pay_way: this.payWay
})
.then(({ data: data }: { data: IOrderDetailResponse }) => {
this.prepaying = false;
this.order = data;
if (this.order.price && this.order.price > 0) {
this.paying = true;
}
})
.catch(() => {
this.prepaying = false;
});
}
}
});
</script>
<style lang="scss" scoped>
.title {
font-size: 26px;
font-weight: bold;
margin-bottom: 20px;
color: #333;
}
.wrapper {
padding: 30px;
.panel {
.el-card {
min-height: 500px;
}
.order {
padding-top: 50px;
.price {
font-size: 20px;
font-weight: bold;
&.unfree {
color: #ff5441;
}
&.free {
color: #29c287;
}
}
}
.payways {
overflow: hidden;
.payway {
cursor: pointer;
font-size: 14px;
float: left;
width: 120px;
line-height: 40px;
text-align: center;
height: 40px;
border: 1px solid #eee;
&.active {
border: 1px solid #3879d1;
}
}
.payicon {
width: 20px;
height: 20px;
margin-top: 2px;
display: inline-block;
&.wechatpay {
position: relative;
top: 3px;
width: 22px;
height: 19px;
background-image: url(//midas.gtimg.cn/enterprise/images/ep_new_sprites@2x.png);
background-repeat: no-repeat;
background-size: 60px 250px;
background-position: 0 -50px;
}
}
}
.btn-pay {
width: 150px;
}
}
}
</style>
-211
View File
@@ -1,211 +0,0 @@
<template>
<el-row class="wrapper">
<el-col :span="24">
<el-row>
<el-col :span="24">
<h2 class="title">{{ $t('common.title.allOrders') }}</h2>
</el-col>
</el-row>
<el-row class="panel">
<el-col :span="24">
<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="250px">
<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')">
<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" width="100px">
<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="300px">
<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>
<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 { IOrder, IOrderListResponse, orderOperator, OrderState } from '@/operators/order';
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';
interface IData {
orders: IOrder[];
loading: boolean;
total: number | undefined;
limit: number;
OrderState: typeof OrderState;
}
export default defineComponent({
name: 'ConsoleOrderList',
components: {
Pagination,
CopyToClipboard,
ElRow,
ElCol,
ElTable,
ElTableColumn,
ElButton,
ElTag,
ElCard
},
data(): IData {
return {
OrderState: OrderState,
orders: [],
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;
orderOperator
.getAll({
ordering: '-created_at',
limit: this.limit,
offset: (this.page - 1) * this.limit,
user_id: this.$store.getters.user.id
})
.then(({ data: data }: { data: IOrderListResponse }) => {
this.orders = data.items;
this.loading = false;
this.total = data.count;
})
.catch(() => {
this.loading = false;
});
}
}
});
</script>
<style lang="scss" scoped>
.title {
font-size: 26px;
font-weight: bold;
margin-bottom: 20px;
color: #333;
}
.el-table {
min-height: calc(100vh - 300px);
margin-bottom: 50px;
}
.wrapper {
padding: 30px;
.api-key {
.copy {
cursor: pointer;
margin: 0 10px;
}
}
}
.pagination {
float: right;
}
</style>