8
8
</div >
9
9
<div v-else-if =" application" class =" status" >
10
10
<span class =" info" >
11
- {{ $t('common.message.usedCount') }}: {{ application?.used_amount }} {{ $t('common.message.remainingCount') }}:
12
- {{ application?.remaining_amount }}
11
+ {{ $t('common.message.usedAmount') }}: {{ application?.used_amount?.toFixed(6) }}
12
+ {{ $t('common.message.remainingAmount') }}:
13
+ {{ application?.remaining_amount?.toFixed(6) }}
13
14
</span >
14
15
<span class =" actions" >
15
16
<el-button size =" small" type =" primary" @click =" onBuyMore(application)" >{{
16
17
$t('common.button.buyMore')
17
18
}}</el-button >
18
19
</span >
19
20
</div >
20
- <div v-if =" needApply && api " class =" text-center info" >
21
+ <div v-if =" needApply && service " class =" text-center info" >
21
22
<span class =" mr-2" >{{ $t('chat.message.notApplied') }}</span >
22
23
<span >
23
24
<el-button type =" primary" class =" btn btn-apply" size =" small" @click =" confirming = true" >
24
25
{{ $t('common.button.apply') }}
25
26
</el-button >
26
27
</span >
27
28
<span class =" ml-1" >{{ $t('chat.message.tryForFree') }}</span >
28
- <application-confirm v-model.visible =" confirming" :object = " api " :type = " applicationType.API " @apply =" onApply" />
29
+ <application-confirm v-if = " service " v- model.visible =" confirming" :service = " service " @apply =" onApply" />
29
30
</div >
30
31
</template >
31
32
32
33
<script lang="ts">
33
34
import { defineComponent } from ' vue' ;
34
- import { IApplication , IApplicationDetailResponse , applicationOperator } from ' @/operators' ;
35
+ import { applicationOperator } from ' @/operators' ;
35
36
import { ElButton , ElMessage , ElSkeleton , ElSkeletonItem } from ' element-plus' ;
36
37
import ApplicationConfirm from ' @/components/application/Confirm.vue' ;
37
- import { IApplicationType } from ' @/operators' ;
38
- import { apiOperator } from ' @/operators/api/operator' ;
39
- import { IApiDetailResponse , IApi } from ' @/operators/api' ;
38
+ import { IApplicationType , IApplication , IApplicationDetailResponse , IService } from ' @/models' ;
40
39
import { ERROR_CODE_DUPLICATION } from ' @/constants/errorCode' ;
41
40
import { ROUTE_CONSOLE_APPLICATION_BUY } from ' @/router' ;
42
41
43
42
export interface IData {
44
43
confirming: boolean ;
45
44
applicationType: typeof IApplicationType ;
46
- api: IApi | undefined ;
47
45
}
48
46
49
47
export default defineComponent ({
50
- name: ' ApiStatus ' ,
48
+ name: ' ApplicationStatus ' ,
51
49
components: { ElButton , ApplicationConfirm , ElSkeleton , ElSkeletonItem },
52
50
props: {
53
51
application: {
54
52
type: Object as () => IApplication | undefined ,
55
53
required: true
56
54
},
57
- apiId: {
58
- type: String ,
59
- required: true
60
- },
61
55
initializing: {
62
56
type: Boolean ,
63
57
default: false
64
58
},
59
+ service: {
60
+ type: Object as () => IService | undefined ,
61
+ required: true
62
+ },
65
63
needApply: {
66
64
type: Boolean ,
67
65
default: false
@@ -71,8 +69,7 @@ export default defineComponent({
71
69
data(): IData {
72
70
return {
73
71
confirming: this .needApply ,
74
- applicationType: IApplicationType ,
75
- api: undefined
72
+ applicationType: IApplicationType
76
73
};
77
74
},
78
75
computed: {
@@ -88,20 +85,9 @@ export default defineComponent({
88
85
if (val ) {
89
86
this .confirming = val ;
90
87
}
91
- },
92
- apiId() {
93
- this .onFetchApi ();
94
88
}
95
89
},
96
- mounted() {
97
- this .onFetchApi ();
98
- },
99
90
methods: {
100
- onFetchApi() {
101
- apiOperator .get (this .apiId ).then (({ data : data }: { data: IApiDetailResponse }) => {
102
- this .api = data ;
103
- });
104
- },
105
91
onBuyMore(application : IApplication ) {
106
92
this .$router .push ({
107
93
name: ROUTE_CONSOLE_APPLICATION_BUY ,
@@ -114,7 +100,7 @@ export default defineComponent({
114
100
applicationOperator
115
101
.create ({
116
102
type: IApplicationType .API ,
117
- api_id : this .apiId
103
+ service_id : this .service ?. id
118
104
})
119
105
.then (({ data : data }: { data: IApplicationDetailResponse }) => {
120
106
ElMessage .success (this .$t (' application.message.applySuccessfully' ));
0 commit comments