1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
| <template>
| <div>
| <div class="security-apply">
| <div class = "security-title">
| <span>2021 保安证考试报名</span>
| </div>
| <div>
| <button class="security-btn" @click="applySubmit">报 名</button>
| <button class="security-btn" @click="cancelApply">取 消 报 名</button>
| </div>
| <!-- <div class = "apply-status">
| <span>{{status}}</span>
| </div> -->
| </div>
| </div>
| </template>
|
| <script>
| import { mapState } from 'vuex';
| import {
| addApply,
| cancelApply
| } from "@/api/examapi/applyexam";
|
| export default {
| data() {
| return {
| status:"未报名"
| };
| },
| computed: {
| ...mapState({
| userInfo: state => state.user.userInfo
| }),
| },
| mounted() {},
| methods:{
| applySubmit(){
| addApply({
| userId: this.userInfo.user_id
| }).then(
| (res) => {
| if (res.data.data == 201) {
| this.$message({
| type: "warning",
| message: "已报名,不能重复报名",
| });
| } else if (res.data.data == 202) {
| this.$message({
| type: "warning",
| message: "报名失败",
| });
| } else {
| this.$message({
| type: "success",
| message: "报名成功",
| });
| }
| },
| (error) => {
| window.console.log(error);
| }
| );
| },
| cancelApply(){
| cancelApply({
| userId: this.userInfo.user_id
| }).then(
| (res) => {
| if (res.data.data == 201) {
| this.$message({
| type: "warning",
| message: "尚未报名",
| });
| } else {
| this.$message({
| type: "success",
| message: "取消报名成功",
| });
| }
| },
| (error) => {
| window.console.log(error);
| }
| );
| }
| }
| };
| </script>
|
| <style lang="scss">
| .security-apply{
| width: 100%;
| height: 100%;
| margin-top: 250px;
|
| .security-title{
| width: 30%;
| font-size: 28px;
| margin-left: 35%;
| text-align: center;
| color: cadetblue;
| }
|
| .security-btn{
| width: 10%;
| margin-left: 45%;
| text-align: center;
| margin-top: 20px;
| }
|
| .apply-status{
| width: 10%;
| margin-left: 45%;
| text-align: center;
| margin-top: 20px;
| }
| }
|
|
| </style>
|
|