浏览代码

获取机器码失败提示

zcb 4 年之前
父节点
当前提交
a6747ea34f
共有 1 个文件被更改,包括 26 次插入9 次删除
  1. 26 9
      kmall-admin/src/main/webapp/login.html

+ 26 - 9
kmall-admin/src/main/webapp/login.html

@@ -118,15 +118,32 @@
         },
         beforeMount: function(){
             // TODO 调用接口获取机器码
-            $.get("http://127.0.0.1:8000/api/reg/gen" , function (r) {
-                console.log(r);
-                if(r.code == "0"){
-                    vm.machineCode = r.rows[0].data.code;
-                    console.log(vm.machineCode);
-                    vm.machineCode = vm.machineCode.replace("+","%2B");
-                    sessionStorage.setItem("machineCode",vm.machineCode);
-                }
-            });
+
+                $.ajax({
+                    url:"http://127.0.0.1:8000/api/reg/gen",
+                    success:function(r){
+                        if(r.code == "0"){
+                            vm.machineCode = r.rows[0].data.code;
+                            console.log(vm.machineCode);
+                            vm.machineCode = vm.machineCode.replace("+","%2B");
+                            sessionStorage.setItem("machineCode",vm.machineCode);
+                        }
+                    },
+                    error:function(XMLHttpRequest, textStatus, errorThrown){
+                        alert("获取机器码失败,请联系管理员");
+                    }
+                })
+
+                // $.get("http://127.0.0.1:8000/api/reg/gen" , function (r) {
+                //     console.log(r);
+                //     if(r.code == "0"){
+                //         vm.machineCode = r.rows[0].data.code;
+                //         console.log(vm.machineCode);
+                //         vm.machineCode = vm.machineCode.replace("+","%2B");
+                //         sessionStorage.setItem("machineCode",vm.machineCode);
+                //     }
+                // });
+