Browse Source

验证卡问题

Shannon_mu 3 years ago
parent
commit
361eef6700

+ 38 - 12
accessControlSystem/src/views/accessControlCard/popups/addManagemenCard.vue

@@ -37,6 +37,12 @@
     </div>
 </template>
 <script >
+import axios from 'axios';
+const CancelToken = axios.CancelToken;
+const source = CancelToken.source();
+var http = axios.create({
+    timout: 30000
+});
 export default {
     props: ['params'],
     data() {
@@ -120,19 +126,39 @@ export default {
         },
         //读卡
         getReadCard() {
+            // axios request 拦截器
+            http.interceptors.request.use(
+                (config) => {
+                    config.headers[localStorage.getItem('SC_token') && 'Authorization'] = 'Bearer ' + localStorage.getItem('SC_token');
+                    // 全局添加cancelToken
+                    config.cancelToken = source.token;
+                    return config;
+                },
+                (err) => {
+                    return Promise.reject(err);
+                }
+            );
             new Promise((resolve) => {
-                this.$http.get('/card/load').then(({ data, status, msg }) => {
-                    if (status == 0) {
-                        if (!!data) {
-                            // this.$message.success(msg);
-                            resolve && resolve(data);
-                        } else {
-                            this.$message.warning('没有读取到卡号');
-                        }
-                    } else {
-                        this.$message.error('读取失败');
-                    }
-                });
+                http.get('http://127.0.0.1:8099/card/load')
+                    .then((res) => {
+                        debugger;
+                        // this.callback(resolve, res);
+                    })
+                    .catch((err) => {
+                        this.reject(reject, err);
+                    });
+                // this.$http.get('/card/load').then(({ data, status, msg }) => {
+                //     if (status == 0) {
+                //         if (!!data) {
+                //             // this.$message.success(msg);
+                //             resolve && resolve(data);
+                //         } else {
+                //             this.$message.warning('没有读取到卡号');
+                //         }
+                //     } else {
+                //         this.$message.error('读取失败');
+                //     }
+                // });
             }).then((res) => {
                 this.queryBinding(res);
             });

+ 0 - 1
accessControlSystem/vue.config.js

@@ -13,7 +13,6 @@ const proxyAgent = {
 
     }
 }
-console.log(envConfig.readCard)
 module.exports = {
     publicPath: process.env.NODE_ENV === 'sit' ? '/sc-accessControlSystem' : '/',
     productionSourceMap: false,