update console

This commit is contained in:
AceDataCloud committed 2024-01-01 02:50:17 +08:00
1 parent 29fd2dd801
commit 18ec9d181c
34 files changed
+1713 -112

No files matched your search

+2 -2
View File
@@ -142,7 +142,7 @@ export default defineComponent({
.el-upload-list {
position: absolute;
width: 400px;
bottom: 40px;
bottom: 45px;
}
}
</style>
@@ -155,7 +155,7 @@ export default defineComponent({
border-radius: 10px;
background: none;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.1);
top: 50px;
top: 30px;
.upload {
display: inline-block;
&.disabled {
+11 -4
View File
@@ -12,7 +12,9 @@
{{ application?.remaining_amount }}
</span>
<span class="actions">
<el-button size="small" type="primary" @click="onBuy">{{ $t('common.button.buyMore') }}</el-button>
<el-button size="small" type="primary" @click="onBuyMore(application)">{{
$t('common.button.buyMore')
}}</el-button>
</span>
</div>
<div v-else class="text-center info">
@@ -36,6 +38,7 @@ import { IApplicationType } from '@/operators';
import { apiOperator } from '@/operators/api/operator';
import { IApiDetailResponse, IApi } from '@/operators/api';
import { ERROR_CODE_DUPLICATION } from '@/constants/errorCode';
import { ROUTE_CONSOLE_APPLICATION_BUY } from '@/router';
export interface IData {
confirming: boolean;
@@ -83,9 +86,13 @@ export default defineComponent({
this.api = data;
});
},
onBuy() {
const url = `https://data.zhishuyun.com/console/applications/${this.application?.id}/buy`;
window.open(url, '_blank');
onBuyMore(application: IApplication) {
this.$router.push({
name: ROUTE_CONSOLE_APPLICATION_BUY,
params: {
id: application.id
}
});
},
onApply() {
applicationOperator
+11 -1
View File
@@ -11,13 +11,19 @@
@click="$router.push(link.route)"
>
<font-awesome-icon :icon="link.icon" />
<!-- <img :src="link.image" class="image" :alt="link.icon" /> -->
</el-button>
</el-tooltip>
</div>
</div>
<div class="middle"></div>
<div class="bottom">
<div class="link">
<el-tooltip effect="dark" :content="$t('common.nav.console')" placement="right">
<el-button class="button" @click="onConsole">
<font-awesome-icon icon="fa-solid fa-compass" />
</el-button>
</el-tooltip>
</div>
<div class="link">
<el-tooltip effect="dark" :content="$t('common.nav.logOut')" placement="right">
<el-button class="button" @click="onLogout">
@@ -38,6 +44,7 @@ import {
ROUTE_CHAT_CONVERSATION,
ROUTE_CHAT_CONVERSATION_NEW,
ROUTE_CHAT_INDEX,
ROUTE_CONSOLE_ROOT,
ROUTE_MIDJOURNEY_HISTORY,
ROUTE_MIDJOURNEY_INDEX
} from '@/router/constants';
@@ -78,6 +85,9 @@ export default defineComponent({
console.debug('logout');
this.$store.dispatch('common/resetToken');
this.$router.push({ name: ROUTE_AUTH_LOGIN });
},
onConsole() {
this.$router.push({ name: ROUTE_CONSOLE_ROOT });
}
}
});
+1 -1
View File
@@ -2,7 +2,7 @@
<div class="price-text">
<span v-if="price > 0" class="unfree"
>¥{{ price }} {{ unit ? ` / ${unit}` : '' }}{{ start ? $t('common.message.startPrice') : ''
}}{{ $t('service.message.fromPrice') }}
}}{{ $t('common.message.startPrice') }}
</span>
<span v-else class="free">
{{ $t('common.message.free') }}
+157
View File
@@ -0,0 +1,157 @@
<template>
<div class="side-panel">
<div>
<img src="@/assets/images/logo2.svg" class="logo" @click="onHome" />
</div>
<div class="links">
<a
v-for="(link, linkIndex) in links"
:key="linkIndex"
:class="{ link: true, active: $route.name === link.name }"
@click="onNavigate(link)"
>
<span class="icon">
<font-awesome-icon :icon="link.icon" class="text-sm" />
</span>
<span class="text">{{ link.text }}</span>
<span class="outer">
<font-awesome-icon
v-if="!link.name && link.href"
icon="fa-solid fa-up-right-from-square"
class="text-sm ml-2"
/>
</span>
<span class="suffix"> </span>
</a>
</div>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
import { ROUTE_CONSOLE_APPLICATION_LIST, ROUTE_CONSOLE_ORDER_LIST, ROUTE_INDEX } from '@/router';
import { ElRow, ElCol } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
interface ILink {
key: string;
text: string;
name?: string;
href?: string;
icon: string;
admin?: boolean;
}
export default defineComponent({
name: 'Navigator',
components: {
FontAwesomeIcon
},
computed: {
active() {
return this.$route.matched[0].path;
},
user() {
return this.$store.getters.user;
},
links(): ILink[] {
let links: ILink[] = [
{
key: 'application-list',
text: this.$t('console.menu.applicationList'),
name: ROUTE_CONSOLE_APPLICATION_LIST,
icon: 'fa-solid fa-cube'
},
{
key: 'order-list',
text: this.$t('console.menu.orderList'),
name: ROUTE_CONSOLE_ORDER_LIST,
icon: 'fa-solid fa-store'
}
];
return links;
}
},
mounted() {},
methods: {
onHome() {
this.$router.push({
name: ROUTE_INDEX
});
},
onNavigate(link: ILink) {
if (link.name) {
this.$router.push({
name: link.name
});
} else if (link.href) {
window.open(link.href, '_blank');
}
}
}
});
</script>
<style lang="scss" scoped>
$width: 250px;
$padding-left: 10px;
.side-panel {
padding-left: $padding-left;
width: $width;
padding-top: 50px;
border-right: 1px solid var(--el-border-color);
height: 100%;
}
.logo {
width: 100%;
height: 60px;
cursor: pointer;
margin-bottom: 50px;
}
.links {
width: $width;
.link {
$height: 40px;
height: $height;
display: block;
width: calc(100% - #{$padding-left});
border-radius: 6px;
cursor: pointer;
margin-bottom: 5px;
position: relative;
color: #444;
line-height: $height;
padding-left: 10px;
.suffix {
width: 3px;
height: $height;
position: absolute;
right: -5px;
margin-right: 5px;
border-radius: 3px;
display: inline-block;
}
.icon {
width: 16px;
height: 16px;
display: inline-block;
position: relative;
margin-right: 10px;
transform: translateY(-2%);
}
.text {
font-size: 14px;
}
&.active {
.suffix {
background-color: var(--el-color-primary);
}
}
&:hover {
background-color: #ebedf1;
}
}
}
</style>
+180
View File
@@ -0,0 +1,180 @@
<template>
<el-form label-width="100px">
<el-form-item :label="$t('application.field.service')">
<span v-if="application.type === applicationType.API">
{{ application?.api?.title }}
</span>
</el-form-item>
<el-form-item :label="$t('application.field.package')">
<el-radio-group v-if="application.type === applicationType.API" v-model="form.packageId">
<el-radio-button v-for="(pkg, pkgIndex) in application?.api?.packages" :key="pkgIndex" :label="pkg.id">
{{ pkg.amount }}{{ $t(`api.unit.${application?.api?.unit}`) }}
</el-radio-button>
<el-radio-button label="custom">
{{ $t('application.button.custom') }}
</el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item v-if="form.packageId === 'custom'" :label="$t('application.field.amount')">
<el-input-number v-model="form.amount" :min="1" :max="10000" controls-position="right" />
</el-form-item>
<el-form-item :label="$t('application.field.price')">
<div v-if="application.type === applicationType.API">
<price
v-if="form.packageId === 'custom'"
:price="application?.api?.price"
:unit="$t(`api.unit.${application?.api?.unit}`)"
/>
<price v-else :price="package?.price" />
</div>
</el-form-item>
<el-divider border-style="dashed" />
<el-form-item :label="$t('application.field.shouldPayPrice')">
<span v-if="form.packageId === 'custom'" :class="{ price: true, unfree: price > 0, free: price === 0 }">
¥{{ price.toFixed(2) }}
</span>
<span v-else-if="package" :class="{ price: true, unfree: package?.price > 0, free: package?.price === 0 }">
¥{{ package?.price?.toFixed(2) }}
</span>
</el-form-item>
<el-form-item>
<el-button type="primary" size="large" class="btn-create" :loading="creating" @click="onCreateOrder">
{{ $t('application.button.createOrder') }}
</el-button>
</el-form-item>
</el-form>
</template>
<script lang="ts">
import { IApplication, IApplicationType, IOrderDetailResponse, IPackage, orderOperator } from '@/operators';
import { defineComponent } from 'vue';
import { ElMessage } from 'element-plus';
import { ROUTE_CONSOLE_ORDER_DETAIL } from '@/router';
import { ElForm, ElFormItem, ElButton, ElInputNumber, ElDivider, ElRadioGroup, ElRadioButton } from 'element-plus';
import Price from '@/components/common/Price.vue';
interface IData {
form: {
amount: number;
packageId: string | undefined;
};
creating: boolean;
applicationType: typeof IApplicationType;
}
export default defineComponent({
name: 'CreateOrderDialog',
components: {
ElForm,
ElFormItem,
ElInputNumber,
ElButton,
ElDivider,
ElRadioGroup,
ElRadioButton,
Price
},
props: {
application: {
type: Object as () => IApplication,
required: true
}
},
data(): IData {
return {
form: {
amount: 1000,
packageId: undefined
},
creating: false,
applicationType: IApplicationType
};
},
computed: {
price() {
if (this.application?.type === IApplicationType.API) {
if (this.application.api?.price && this.form.amount) {
return this.form.amount * this.application.api?.price;
}
}
return 0;
},
package() {
if (this.application?.type === IApplicationType.API) {
if (this.application.api?.packages && this.form.packageId) {
const filterPackages = this.application.api?.packages.filter((item) => item.id === this.form.packageId);
if (filterPackages.length > 0) {
return filterPackages[0];
}
}
}
return undefined;
}
},
mounted() {
this.onInit();
},
methods: {
onInit() {
if (this.application.type === IApplicationType.API) {
if (this.application?.api?.packages && this.application?.api?.packages.length > 0) {
this.form.packageId = this.application?.api?.packages[0].id;
} else {
this.form.packageId = 'custom';
}
}
},
onChangePackage(pkg: IPackage) {
console.log('pkg', pkg);
},
onCreateOrder() {
if (!this.application?.id) {
return;
}
this.creating = true;
orderOperator
.create({
application_id: this.application?.id,
amount: this.form.amount,
...(this.form.packageId !== 'custom' && this.package
? {
package_id: this.package.id
}
: {})
})
.then(({ data: data }: { data: IOrderDetailResponse }) => {
this.creating = false;
const order = data;
this.$router.push({
name: ROUTE_CONSOLE_ORDER_DETAIL,
params: {
id: order.id
}
});
})
.catch(() => {
ElMessage.error(this.$t('order.message.createFailed'));
this.creating = false;
});
}
}
});
</script>
<style lang="scss" scoped>
.price {
font-size: 20px;
font-weight: bold;
&.unfree {
color: #ff5441;
}
&.free {
color: #29c287;
}
}
.btn-create {
width: 150px;
border-radius: 20px;
}
</style>
+93
View File
@@ -0,0 +1,93 @@
<template>
<el-dialog :model-value="visible" :title="$t('application.title.buyService')" width="500px" center>
<p class="text-center">
{{ $t('order.message.buyInExternalUrl') }}
</p>
</el-dialog>
</template>
<script lang="ts">
import { IOrder, IOrderDetailResponse, orderOperator, OrderState } from '@/operators';
import { defineComponent } from 'vue';
import { ElDialog } from 'element-plus';
interface IData {
refreshTimer: number | undefined;
}
export default defineComponent({
name: 'PayOrderDialog',
components: {
ElDialog
},
props: {
modelValue: {
type: Object as () => IOrder,
required: true
},
visible: {
type: Boolean,
required: false,
default: false
}
},
emits: ['hide', 'update:modelValue'],
data(): IData {
return {
refreshTimer: undefined
};
},
watch: {
visible: {
handler(val) {
if (val && this.modelValue.pay_url) {
window.open(this.modelValue.pay_url, '_blank');
}
}
}
},
mounted() {
this.onRefresh();
},
unmounted() {
if (this.refreshTimer) {
clearTimeout(this.refreshTimer);
}
},
methods: {
onRefresh() {
if (!this.modelValue.id) {
console.error('id does not exist');
return;
}
orderOperator
.refresh(this.modelValue.id)
.then(({ data: data }: { data: IOrderDetailResponse }) => {
// if not paid, check for next loop
if (data.state !== OrderState.PAID) {
setTimeout(() => {
this.onRefresh();
}, 2000);
} else {
// paid, just notify parent, and hide the dialog
this.$emit('hide');
}
this.$emit('update:modelValue', data);
})
.catch(() => {
setTimeout(() => {
this.onRefresh();
}, 5000);
});
}
}
});
</script>
<style lang="scss" scoped>
.paycodes {
padding: 30px 0;
width: 500px;
margin: auto;
}
</style>
+111
View File
@@ -0,0 +1,111 @@
<template>
<el-dialog :model-value="visible" :title="$t('application.title.buyService')" width="500px" center>
<el-row class="paycodes">
<el-col :span="12">
<div class="paycode wechat">
<qr-code v-if="modelValue?.pay_url" :value="modelValue?.pay_url" :size="200" class="m-auto" />
<p class="help-text">{{ $t('order.message.wechatPayHelp') }}</p>
</div>
</el-col>
<el-col :span="12">
<div class="help-img">
<img src="https://midas.gtimg.cn/enterprise/images/ep_sys_wx_tip.jpg" />
</div>
</el-col>
</el-row>
</el-dialog>
</template>
<script lang="ts">
import { IOrder, IOrderDetailResponse, orderOperator, OrderState } from '@/operators';
import { defineComponent } from 'vue';
import { ElDialog, ElRow, ElCol } from 'element-plus';
import QrCode from 'qrcode.vue';
interface IData {
refreshTimer: number | undefined;
}
export default defineComponent({
name: 'PayOrderDialog',
components: {
ElDialog,
QrCode,
ElRow,
ElCol
},
props: {
modelValue: {
type: Object as () => IOrder,
required: true
},
visible: {
type: Boolean,
required: false,
default: false
}
},
emits: ['hide', 'update:modelValue'],
data(): IData {
return {
refreshTimer: undefined
};
},
mounted() {
this.onRefresh();
},
unmounted() {
if (this.refreshTimer) {
clearTimeout(this.refreshTimer);
}
},
methods: {
onRefresh() {
if (!this.modelValue.id) {
console.error('id does not exist');
return;
}
orderOperator
.refresh(this.modelValue.id)
.then(({ data: data }: { data: IOrderDetailResponse }) => {
// if not paid, check for next loop
if (data.state !== OrderState.PAID) {
setTimeout(() => {
this.onRefresh();
}, 2000);
} else {
// paid, just notify parent, and hide the dialog
this.$emit('hide');
}
this.$emit('update:modelValue', data);
})
.catch(() => {
setTimeout(() => {
this.onRefresh();
}, 2000);
});
}
}
});
</script>
<style lang="scss" scoped>
.paycodes {
padding: 30px 0;
width: 500px;
margin: auto;
.wechat {
.help-text {
display: block;
background-color: #00c800;
color: white;
font-size: 14px;
height: 35px;
width: 240px;
text-align: center;
line-height: 35px;
margin: 10px auto 0 auto;
}
}
}
</style>