add apply operation

This commit is contained in:
AceDataCloud committed 2023-01-01 00:38:03 +08:00
1 parent 7a57531bc6
commit 866331343c
6 files changed
+50 -16

No files matched your search

+1
View File
@@ -1 +1,2 @@
export const ERROR_CODE_UNVERIFIED = 'unverifed';
export const ERROR_CODE_DUPLICATION = 'duplication';
+3 -1
View File
@@ -1,7 +1,9 @@
import field from './field';
import button from './button';
import message from './message';
export default {
field,
button
button,
message
};
+4
View File
@@ -0,0 +1,4 @@
export default {
alreadyApplied: '已经申请过该服务,请到控制台查看',
applySuccessfully: '申请成功,即将跳转到控制台'
};
+5 -5
View File
@@ -1,10 +1,10 @@
export interface IApplication {
id: string;
id?: string;
service: string;
apiKey: string;
userId: string;
remainingCount: number;
usedCount: number;
apiKey?: string;
userId?: string;
remainingCount?: number;
usedCount?: number;
createdAt?: string;
updatedAt?: string;
}
+36 -10
View File
@@ -30,7 +30,7 @@
</p>
</div>
<div class="operations">
<el-button type="danger">
<el-button type="danger" @click="onApply">
{{ $t('service.button.apply') }}
</el-button>
</div>
@@ -61,12 +61,22 @@
</template>
<script lang="ts">
import { IService, IServiceDetailResponse, serviceOperator } from '@/operators';
import {
applicationOperator,
IApplication,
IApplicationDetailResponse,
IService,
IServiceDetailResponse,
serviceOperator
} from '@/operators';
import { defineComponent } from 'vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { ERROR_CODE_DUPLICATION } from '@/constants';
import { ElForm, ElMessage } from 'element-plus';
interface IData {
service: IService | undefined;
application: IApplication | undefined;
loading: boolean;
activeTab: string;
}
@@ -78,30 +88,46 @@ export default defineComponent({
},
data(): IData {
return {
// service: undefined,
// order: undefined,
// episodes: [],
service: undefined,
application: undefined,
loading: false,
activeTab: 'introduction'
// buying: false,
// paid: undefined
};
},
computed: {
id() {
return this.$route.params.id;
return 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: {}
methods: {
onApply() {
applicationOperator
.create({
service: this.id
})
.then(({ data: data }: { data: IApplicationDetailResponse }) => {
this.application = data;
ElMessage.success(this.$t('application.message.applySuccessfully'));
setTimeout(() => {
this.$router.push({
name: 'console-application-list'
});
}, 2000);
})
.catch((error) => {
if (error?.response?.data?.code === ERROR_CODE_DUPLICATION) {
ElMessage.error(this.$t('application.message.alreadyApplied'));
}
});
}
}
});
</script>
+1
View File
@@ -46,6 +46,7 @@
import { serviceOperator, IService, IServiceListResponse } from '@/operators';
import { defineComponent } from 'vue';
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
import { ElForm, ElMessage } from 'element-plus';
interface IData {
services: IService[];