Add pricing display (#31)

This commit is contained in:
AceDataCloud committed 2024-04-21 18:22:03 +00:00
1 parent 18259e0482
commit 282256de5d
146 files changed
+1135 -582

No files matched your search

+89
View File
@@ -0,0 +1,89 @@
<template>
<div>
<el-dialog v-model="visible" center width="80%">
<el-table :data="data" stripe :span-method="spanMethod" :header-cell-style="cellStyle" :cell-style="cellStyle">
<el-table-column
v-for="(column, columnIndex) in columns"
:key="columnIndex"
:prop="column.key"
:label="column.label"
/>
</el-table>
</el-dialog>
<el-button round size="small" @click="visible = true">
{{ $t('service.button.pricing') }}
</el-button>
</div>
</template>
<script lang="ts">
import { IApiPrice } from '@/models';
import { defineComponent } from 'vue';
import { ElTable, ElTableColumn, ElDialog, ElButton } from 'element-plus';
import type { CellStyle, TableColumnCtx } from 'element-plus';
interface SpanMethodProps {
row: IApiPrice;
column: TableColumnCtx<IApiPrice>;
rowIndex: number;
columnIndex: number;
}
export default defineComponent({
name: 'ApiPrice',
components: {
ElTable,
ElTableColumn,
ElDialog,
ElButton
},
props: {
price: {
type: Object as () => IApiPrice | undefined,
required: true
}
},
data() {
return {
visible: false
};
},
computed: {
data() {
return this.price?.data || [];
},
columns() {
return this.price?.columns;
},
spans() {
return this.price?.spans;
}
},
methods: {
// @ts-ignore
cellStyle(): CellStyle {
return {
'font-weight': 'bold',
'text-align': 'center'
};
},
spanMethod({ row, column, rowIndex, columnIndex }: SpanMethodProps) {
if (this.spans) {
for (const span of this.spans) {
if (rowIndex === span[0] && columnIndex === span[1]) {
return [span[2], span[3]];
}
}
}
return [1, 1];
}
}
});
</script>
<style lang="scss" scoped>
.table {
width: 80%;
max-width: 1200px;
}
</style>
+8 -2
View File
@@ -15,9 +15,14 @@
{{ $t(`service.unit.` + application?.service?.unit + 's') }}
</span>
<span class="actions">
<el-button round size="small" type="primary" @click="onBuyMore(application)">{{
<el-button round size="small" type="primary" class="mr-1" @click="onBuyMore(application)">{{
$t('common.button.buyMore')
}}</el-button>
<api-price
v-if="application?.service?.apis?.[0]?.price"
class="price inline-block"
:price="application?.service?.apis?.[0]?.price"
/>
</span>
</div>
<div v-if="needApply && service" class="text-center info">
@@ -45,6 +50,7 @@ import ApplicationConfirm from '@/components/application/Confirm.vue';
import { IApplicationType, IApplication, IApplicationDetailResponse, IService } from '@/models';
import { ERROR_CODE_DUPLICATION } from '@/constants/errorCode';
import { ROUTE_CONSOLE_APPLICATION_BUY } from '@/router';
import ApiPrice from '@/components/api/Price.vue';
export interface IData {
confirming: boolean;
@@ -53,7 +59,7 @@ export interface IData {
export default defineComponent({
name: 'ApplicationStatus',
components: { ElButton, ApplicationConfirm, ElSkeleton, ElSkeletonItem },
components: { ElButton, ApplicationConfirm, ElSkeleton, ElSkeletonItem, ApiPrice },
props: {
application: {
type: Object as () => IApplication | undefined,
+7 -3
View File
@@ -130,8 +130,10 @@ export default defineComponent({
this.$nextTick(() => {
const textarea = this.$refs.textarea;
if (textarea) {
textarea.style.height = '35px'; // 先重置高度
textarea.style.height = textarea.scrollHeight + 'px'; // 设置高度为内容的实际高度
// @ts-ignore
textarea.style.height = '35px';
// @ts-ignore
textarea.style.height = textarea.scrollHeight + 'px';
}
});
},
@@ -159,9 +161,11 @@ textarea.input {
background: none;
box-shadow: none;
resize: none;
line-height: 35px;
line-height: 25px;
width: calc(100% - 80px);
margin-left: 30px;
font-family: var(--el-font-family);
padding-top: 6px;
}
textarea.input:focus {
outline: none;
+29
View File
@@ -0,0 +1,29 @@
<template>
<div>
<el-tooltip effect="dark" :content="$t('common.message.joinDiscord')" placement="top-start">
<el-button type="primary" circle size="large" @click="onJoin">
<font-awesome-icon icon="fa-brands fa-discord" />
</el-button>
</el-tooltip>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { ElTooltip, ElButton } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
export default defineComponent({
name: 'HelpEntry',
components: {
ElTooltip,
ElButton,
FontAwesomeIcon
},
methods: {
onJoin() {
window.open('https://discord.gg/73F3MYj3vp', '_blank');
}
}
});
</script>