add apply operation
This commit is contained in:
1 parent
7a57531bc6
commit
866331343c
6 files changed
+50
-16
No files matched your search
@@ -1 +1,2 @@
|
|||||||
export const ERROR_CODE_UNVERIFIED = 'unverifed';
|
export const ERROR_CODE_UNVERIFIED = 'unverifed';
|
||||||
|
export const ERROR_CODE_DUPLICATION = 'duplication';
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
import field from './field';
|
import field from './field';
|
||||||
import button from './button';
|
import button from './button';
|
||||||
|
import message from './message';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
field,
|
field,
|
||||||
button
|
button,
|
||||||
|
message
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export default {
|
||||||
|
alreadyApplied: '已经申请过该服务,请到控制台查看',
|
||||||
|
applySuccessfully: '申请成功,即将跳转到控制台'
|
||||||
|
};
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
export interface IApplication {
|
export interface IApplication {
|
||||||
id: string;
|
id?: string;
|
||||||
service: string;
|
service: string;
|
||||||
apiKey: string;
|
apiKey?: string;
|
||||||
userId: string;
|
userId?: string;
|
||||||
remainingCount: number;
|
remainingCount?: number;
|
||||||
usedCount: number;
|
usedCount?: number;
|
||||||
createdAt?: string;
|
createdAt?: string;
|
||||||
updatedAt?: string;
|
updatedAt?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="operations">
|
<div class="operations">
|
||||||
<el-button type="danger">
|
<el-button type="danger" @click="onApply">
|
||||||
{{ $t('service.button.apply') }}
|
{{ $t('service.button.apply') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
@@ -61,12 +61,22 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { IService, IServiceDetailResponse, serviceOperator } from '@/operators';
|
import {
|
||||||
|
applicationOperator,
|
||||||
|
IApplication,
|
||||||
|
IApplicationDetailResponse,
|
||||||
|
IService,
|
||||||
|
IServiceDetailResponse,
|
||||||
|
serviceOperator
|
||||||
|
} from '@/operators';
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||||
|
import { ERROR_CODE_DUPLICATION } from '@/constants';
|
||||||
|
import { ElForm, ElMessage } from 'element-plus';
|
||||||
|
|
||||||
interface IData {
|
interface IData {
|
||||||
service: IService | undefined;
|
service: IService | undefined;
|
||||||
|
application: IApplication | undefined;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
activeTab: string;
|
activeTab: string;
|
||||||
}
|
}
|
||||||
@@ -78,30 +88,46 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
data(): IData {
|
data(): IData {
|
||||||
return {
|
return {
|
||||||
// service: undefined,
|
|
||||||
// order: undefined,
|
|
||||||
// episodes: [],
|
|
||||||
service: undefined,
|
service: undefined,
|
||||||
|
application: undefined,
|
||||||
loading: false,
|
loading: false,
|
||||||
activeTab: 'introduction'
|
activeTab: 'introduction'
|
||||||
// buying: false,
|
|
||||||
// paid: undefined
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
id() {
|
id() {
|
||||||
return this.$route.params.id;
|
return this.$route.params.id.toString();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
serviceOperator.get(this.id).then(({ data: data }: { data: IServiceDetailResponse }) => {
|
serviceOperator.get(this.id).then(({ data: data }: { data: IServiceDetailResponse }) => {
|
||||||
this.service = data;
|
this.service = data;
|
||||||
console.log('this.service', this.service);
|
|
||||||
this.loading = false;
|
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>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
import { serviceOperator, IService, IServiceListResponse } from '@/operators';
|
import { serviceOperator, IService, IServiceListResponse } from '@/operators';
|
||||||
import { defineComponent } from 'vue';
|
import { defineComponent } from 'vue';
|
||||||
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
|
||||||
|
import { ElForm, ElMessage } from 'element-plus';
|
||||||
|
|
||||||
interface IData {
|
interface IData {
|
||||||
services: IService[];
|
services: IService[];
|
||||||
|
|||||||
Reference in new issue
Block a user