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
| <template>
| <div class="params-dialog">
| <div class="form-content">
| {{ message }}
| </div>
| <div class="form-footer">
| <el-button type="primary" :disabled="bindState" @click="next">下一步</el-button>
| </div>
| </div>
| </template>
|
| <script>
| import { getUNameByUKey } from "@/api/user";
| import useElement from '@/hooks/useElement.js';
|
| const { $loading } = useElement();
| export default {
| name: "BindStep2",
| props: {
| id: {
| type: String,
| default: ""
| }
| },
| watch: {
| id(id) {
| this.checkUKey(id);
| }
| },
| data() {
| return {
| bindState: false, // uKey绑定的状态
| userName: "", // 绑定的用户名
| state: 0
| };
| },
| methods: {
| /**
| * 检测uKey是否已经绑定用户
| */
| checkUKey(id) {
| if (id) {
| let loading = $loading();
| getUNameByUKey(id.trim())
| .then(res => {
| let { code, data, data2 } = res;
| if (code && data) {
| this.state = 1;
| this.bindState = true;
| this.userName = data2.uname;
| } else {
| this.state = 0;
| this.bindState = false;
| }
| // 关闭等待框
| loading.close();
| })
| .catch(error => {
| // 请求网络失败
| this.state = -1;
| this.bindState = true;
| // 关闭等待框
| loading.close();
| console.log(error);
| });
| } else {
| this.state = -2;
| this.bindState = true;
| }
| },
| next() {
| this.$emit("next");
| }
| },
| computed: {
| message() {
| let msg = "";
| switch (this.state) {
| case -2:
| msg = "未获取到ukey的信息";
| break;
| case -1:
| msg = "请求网络失败,无法检测ukey绑定状态!";
| break;
| case 0:
| msg = "ukey未绑定用户";
| break;
| case 1:
| msg = "ukey已绑定" + this.userName + "用户";
| break;
| }
| return msg;
| }
| },
| mounted() {
| this.checkUKey(this.id);
| }
| };
| </script>
|
| <style scoped>
| .form-content {
| padding: 8px;
| font-size: 18px;
| text-align: center;
| }
|
| .form-footer {
| padding: 8px;
| text-align: right;
| }
| </style>
|
|