Skip to content

Commit

Permalink
Fix discount (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyf-github-user authored Sep 13, 2024
1 parent e60c976 commit 9754e27
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fit discount information",
"packageName": "@acedatacloud/nexior",
"email": "[email protected]",
"dependentChangeType": "patch"
}
41 changes: 41 additions & 0 deletions src/pages/console/application/Buy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
<el-form-item :label="$t('application.field.package')" class="mb-0">
<el-radio-group v-if="packages" v-model="form.packageId">
<el-radio-button v-for="(pkg, pkgIndex) in packages" :key="pkgIndex" :label="pkg.id" class="mb-2">
<span v-show="pkgIndex !== 0" class="corner">
{{ getDiscount(pkg) }}
</span>
{{ pkg.amount }} {{ $t(`service.unit.${application?.service?.unit}s`) }}
</el-radio-button>
</el-radio-group>
Expand Down Expand Up @@ -122,6 +125,7 @@ interface IData {
packageId: string | undefined;
};
type: string;
lang: string;
creating: boolean;
}
Expand All @@ -143,6 +147,7 @@ export default defineComponent({
},
data(): IData {
return {
lang: this.$i18n.locale,
application: undefined,
loading: false,
type: 'Usage',
Expand Down Expand Up @@ -183,6 +188,22 @@ export default defineComponent({
this.onFetchApplication();
},
methods: {
getDiscount(pkg: any) {
if (this.packages && this.packages.length > 0) {
if (this.lang?.startsWith('zh')) {
return (
// @ts-ignore
((10 * pkg?.price) / pkg?.amount / (this.packages[0].price / this.packages[0]?.amount))?.toFixed(1) + '折'
);
} else {
return (
Math.round(100 - (100 * pkg?.price) / pkg?.amount / (this.packages[0].price / this.packages[0]?.amount)) +
'% OFF'
);
}
}
return '';
},
onSubscribe() {
this.$router.push({
name: ROUTE_CONSOLE_APPLICATION_SUBSCRIBE,
Expand Down Expand Up @@ -255,6 +276,26 @@ export default defineComponent({
color: var(--el-text-color-primary);
}
.el-form {
.el-radio-group {
.el-radio-button {
position: relative;
.corner {
position: absolute;
top: -13px;
right: 0px;
font-size: 12px;
border: 1px solid #ff7200;
color: #ff7200;
background-color: #ffe8d5;
border-radius: 3px;
padding: 2px 5px;
z-index: 1000;
}
}
}
}
.panel {
padding: 30px;
width: calc(100% - 300px);
Expand Down

0 comments on commit 9754e27

Please sign in to comment.