add service detail page

This commit is contained in:
AceDataCloud committed 2022-12-29 20:28:52 +08:00
1 parent 7e38c8944a
commit 6aebeba477
9 files changed
+225 -31

No files matched your search

+4 -1
View File
@@ -1,3 +1,6 @@
export default {
learnMore: '了解更多'
learnMore: '了解更多',
apply: '立即申请',
introduction: '服务介绍',
apis: '接口说明'
};
+2 -1
View File
@@ -1,3 +1,4 @@
export default {
free: '免费'
free: '免费',
appliedCount: '申请次数'
};
+2
View File
@@ -7,6 +7,8 @@ import i18n from './i18n/index';
import './assets/css/tailwind.css';
import './assets/scss/style.scss';
import dayjs from './plugins/dayjs';
import './plugins/font-awesome';
const app = createApp(App);
app.use(router);
+2 -1
View File
@@ -4,8 +4,9 @@ export interface IService {
description?: string;
tags?: string[];
thumbnail?: string;
icon?: string;
price?: number;
applied_count: number;
appliedCount: number;
introduction: string;
createdAt?: string;
updatedAt?: string;
+160 -23
View File
@@ -1,55 +1,192 @@
<template>
<verification-alert />
<el-row v-if="service" class="preview">
<el-col :span="20" :offset="2">
<el-row>
<el-col :span="24">
<el-card shadow="hover">
<div class="body">
<div class="left">
<div class="icon">
<font-awesome-icon :icon="'fa-regular fa-' + service.icon" />
</div>
<div class="count">
<p>{{ $t('service.message.appliedCount') }}: {{ service.appliedCount }}</p>
</div>
</div>
<div class="right">
<div class="title">
{{ service.title }}
</div>
<div class="description">
{{ service.description }}
</div>
<div class="price">
<p v-if="service && service.price && service.price > 0" class="nonfree">
<span class="value">¥{{ service.price }}</span>
<span class="unit"> / {{ $t('service.unit.usage') }}</span>
</p>
<p v-else class="free">
{{ $t('service.message.free') }}
</p>
</div>
<div class="operations">
<el-button type="danger">
{{ $t('service.button.apply') }}
</el-button>
</div>
</div>
</div>
</el-card>
</el-col>
</el-row>
<el-row>
<el-col></el-col>
</el-row>
</el-col>
</el-row>
<el-row v-if="service" class="detail">
<el-col :span="20" :offset="2">
<el-card shadow="hover">
<el-tabs v-model="activeTab" class="demo-tabs">
<el-tab-pane :label="$t('service.button.introduction')" name="introduction">
<div class="introduction">
{{ service?.introduction }}
</div>
</el-tab-pane>
<el-tab-pane :label="$t('service.button.apis')" name="apis">Config</el-tab-pane>
</el-tabs>
</el-card>
</el-col>
</el-row>
</template>
<script lang="ts">
import { serviceOperator } from '@/operators';
import { IService, IServiceDetailResponse, serviceOperator } from '@/operators';
import { defineComponent } from 'vue';
import { Clock, MagicStick, Collection, VideoPlay, Goods, Lock } from '@element-plus/icons-vue';
import VerificationAlert from '@/components/common/VerificationAlert.vue';
import { v4 as uuidv4 } from 'uuid';
import { ElMessage } from 'element-plus';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
interface IData {
service: IService | undefined;
loading: boolean;
buying: boolean;
paid: boolean | undefined;
activeTab: string;
}
export default defineComponent({
name: 'ServiceDetail',
components: {
Clock,
Collection,
MagicStick,
VerificationAlert,
VideoPlay,
Goods,
Lock
FontAwesomeIcon
},
data(): IData {
return {
// service: undefined,
// order: undefined,
// episodes: [],
service: undefined,
order: undefined,
episodes: [],
loading: false,
buying: false,
paid: undefined
activeTab: 'introduction'
// buying: false,
// paid: undefined
};
},
computed: {
verified() {
return this.$store.getters.user.isVerified;
},
id() {
return parseInt(this.$route.params.id.toString());
}
},
async mounted() {
this.loading = true;
serviceOperator.get(this.id).then(({ data: data }: { data: IServiceDetailResponse }) => {
this.service = data;
console.log('this.service', this.service);
this.loading = false;
});
},
methods: {}
});
</script>
<style lang="scss" scoped></style>
<style lang="scss" scoped>
.preview {
overflow: hidden;
$left-width: 320px;
$left-height: 290px;
margin: 15px 0;
.body {
display: flex;
.left {
float: left;
position: relative;
border: 1px solid #e8e8e8;
border-radius: 8px;
width: $left-width;
height: $left-height;
text-align: center;
box-sizing: border-box;
box-shadow: none;
padding-top: 50px;
.icon {
width: 150px;
height: 150px;
margin: 0 auto;
font-size: 80px;
}
.count {
color: #999;
}
}
.right {
position: relative;
padding: 15px;
float: left;
width: calc(100% - $left-width);
.title {
font-size: 18px;
color: #000;
line-height: 26px;
padding-right: 8px;
}
.description {
line-height: 22px;
color: #303030;
padding: 15px 0;
font-size: 14px;
}
.price {
margin: 0;
.nonfree {
.value {
font-weight: bold;
color: #ff5441;
font-size: 30px;
}
.unit {
color: #666;
}
}
.free {
color: #29c287;
}
}
.operations {
position: absolute;
left: 15px;
bottom: 10px;
}
}
}
}
.detail {
margin-bottom: 15px;
font-size: 14px;
.introduction {
padding: 10px 0;
color: #999;
font-weight: 400;
}
}
</style>
+3 -5
View File
@@ -5,7 +5,7 @@
<el-col v-for="(service, serviceIndex) in services" :key="serviceIndex" :md="6" :xs="24">
<el-card shadow="hover" class="service">
<div class="icon">
<el-icon> <user /> </el-icon>
<font-awesome-icon :icon="'fa-regular fa-' + service.icon" />
</div>
<div class="title">{{ service.title }}</div>
<div class="price">
@@ -38,7 +38,6 @@
</el-card>
</el-col>
</el-row>
<div class="services"></div>
</el-col>
</el-row>
</template>
@@ -46,7 +45,7 @@
<script lang="ts">
import { serviceOperator, IService, IServiceListResponse } from '@/operators';
import { defineComponent } from 'vue';
import { User, Picture } from '@element-plus/icons-vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
interface IData {
services: IService[];
@@ -55,8 +54,7 @@ interface IData {
export default defineComponent({
name: 'ServiceList',
components: {
User,
Picture
FontAwesomeIcon
},
data(): IData {
return {
+9
View File
@@ -0,0 +1,9 @@
import { library } from '@fortawesome/fontawesome-svg-core';
import * as icons from '@fortawesome/free-regular-svg-icons';
// register all icons from font awesome
for (const key in icons) {
//@ts-ignore
const icon = icons[key];
if (icon?.iconName) library.add(icon);
}