Procházet zdrojové kódy

更改请求方式

DESKTOP-H1V7IUO\51019 před 4 roky
rodič
revize
1fe842ffb8

+ 0 - 5
package-lock.json

@@ -9709,11 +9709,6 @@
       "integrity": "sha1-J8dlOb4U2L0Sghmi1zGwkzeQTnk=",
       "dev": true
     },
-    "jquery": {
-      "version": "3.6.0",
-      "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz",
-      "integrity": "sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw=="
-    },
     "js-base64": {
       "version": "2.6.4",
       "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.6.4.tgz",

+ 0 - 1
package.json

@@ -18,7 +18,6 @@
     "echarts": "^4.9.0",
     "element-ui": "^2.14.1",
     "eslint": "^7.32.0",
-    "jquery": "^3.5.1",
     "js-cookie": "^2.2.1",
     "js-md5": "^0.7.3",
     "jsencrypt": "^3.2.1",

+ 3 - 3
src/background.js

@@ -18,8 +18,8 @@ async function createWindow() {
     webPreferences: {
       // Use pluginOptions.nodeIntegration, leave this alone
       // See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
-      nodeIntegration: process.env.ELECTRON_NODE_INTEGRATION,//process.env.ELECTRON_NODE_INTEGRATION
-      contextIsolation: !process.env.ELECTRON_NODE_INTEGRATION,//!process.env.ELECTRON_NODE_INTEGRATION
+      nodeIntegration: true,//process.env.ELECTRON_NODE_INTEGRATION
+      contextIsolation: false,//!process.env.ELECTRON_NODE_INTEGRATION
       // webSecurity: false
     }
   })
@@ -30,7 +30,7 @@ async function createWindow() {
     if (!process.env.IS_TEST) win.webContents.openDevTools()
   } else {
     createProtocol('app')
-    // win.webContents.openDevTools()
+    win.webContents.openDevTools()
     // Load the index.html when not in development
     win.loadURL('app://./index.html')
   }

+ 35 - 19
src/components/cardHome.vue

@@ -80,25 +80,41 @@ export default {
   methods: {
     onSubmit() {
       this.flag = true;
-      this.$http.get("http://0.0.0.0:9000/readChip").then((res) => {
-        console.log(res);
-        if (res.body.code == 200) {
-          this.flag = false;
-          this.dialogVisible = true;
-          // const loading = this.$loading({
-          //   lock: true,
-          //   text: "Loading",
-          //   spinner: "el-icon-loading",
-          //   background: "rgba(0, 0, 0, 0.7)",
-          // });
-          this.chipData = res.body.data;
-          this.formChip.chipNumber = this.chipData.chipNumber;
-          this.formChip.vaccinationCipher = this.chipData.vaccinationCipher;
-          this.formChip.temperatureStr = this.chipData.list;
-          this.upLoad();
-          // loading.close();
-        }
-      });
+      // $.ajax({
+      //   type: "get",
+      //   url: "http://localhost:9000/readChip",
+      //   success: function (res) {
+      //     console.log(res);
+      //   },
+      // });
+      //this.$api +
+      this.$http
+        .get(
+          this.$api + "/readChip",
+          {
+            headers: { "Content-Type": "application/x-www-form-urlencoded" },
+          },
+          { withCredentials: true }
+        )
+        .then((res) => {
+          console.log(res);
+          if (res.body.code == 200) {
+            this.flag = false;
+            this.dialogVisible = true;
+            // const loading = this.$loading({
+            //   lock: true,
+            //   text: "Loading",
+            //   spinner: "el-icon-loading",
+            //   background: "rgba(0, 0, 0, 0.7)",
+            // });
+            this.chipData = res.body.data;
+            this.formChip.chipNumber = this.chipData.chipNumber;
+            this.formChip.vaccinationCipher = this.chipData.vaccinationCipher;
+            this.formChip.temperatureStr = this.chipData.list;
+            this.upLoad();
+            // loading.close();
+          }
+        });
     },
     upLoad() {
       newUpload(qs.stringify(this.formChip)).then((res) => {

+ 16 - 17
src/components/signIn/SignIn.vue

@@ -119,6 +119,7 @@ export default {
         //   { validator: validateYZM, trigger: "blur" },
         // ],
       },
+      id: 1,
     };
   },
   methods: {
@@ -184,29 +185,27 @@ export default {
               // console.log(data.code);
               if (data.code == 200 && data.msg == "成功") {
                 // 记住密码/不记住密码
-                _this.$cookies.set("id", data.data.id);
-                _this.$cookies.set("telephone", _this.ruleForm.telephone);
-                _this.$cookies.set("password", _this.ruleForm.password);
-                _this.$cookies.set("userName", data.data.userName);
-                if (_this.ruleForm.checked) {
-                  //_this.$cookies.set('remPassword',true,{expires:7});
-                  _this.$cookies.set("remPassword", true);
-                } else {
-                  _this.$cookies.set("remPassword", false, { expires: -1 });
-                }
+                // _this.$cookies.set("id", data.data.id);
+                // _this.$cookies.set("telephone", _this.ruleForm.telephone);
+                // _this.$cookies.set("password", _this.ruleForm.password);
+                // _this.$cookies.set("userName", data.data.userName);
+                // if (_this.ruleForm.checked) {
+                //   //_this.$cookies.set('remPassword',true,{expires:7});
+                //   _this.$cookies.set("remPassword", true);
+                // } else {
+                //   _this.$cookies.set("remPassword", false, { expires: -1 });
+                // }
                 // 提示信息
                 _this.$message({
                   message: "登录成功!",
                   type: "success",
                 });
-                if (
-                  _this.$cookies.get("id") != null ||
-                  _this.$cookies.get("id") != undefined
-                ) {
+                console.log(_this.$cookies.get("id"));
+                if (_this.id != null || _this.id != undefined) {
                   let token = data.data.token;
                   localStorage.setItem("cardToken", token);
-                  _this.$cookies.set("factoryList", data.data);
-                  localStorage.setItem("factoryId", data.data.factoryId);
+                  // _this.$cookies.set("factoryList", data.data);
+                  // localStorage.setItem("factoryId", data.data.factoryId);
                   // roleId 1:超级管理员 19:厂家管理员
                   if (
                     data.data.roleId == 3 ||
@@ -215,7 +214,7 @@ export default {
                   ) {
                     _this.$router.push({
                       path: "/cardHome",
-                      query: { roleId: data.data.roleId },
+                      // query: { roleId: data.data.roleId },
                     });
                   } else {
                     _this.$message({

+ 3 - 3
src/main.js

@@ -20,12 +20,12 @@ Vue.use(Element, {
   size: Cookies.get('size') || 'medium' // set element-ui default size
 })
 // Vue.http.options.root = "http://evvmapi.vandh.org/"//根路径
-Vue.http.options.root = 'http://127.0.0.1:9000'
+// Vue.http.options.root = 'http://127.0.0.1:9000'
 // Vue.http.options.root = 'https://api.map.baidu.com/'
-
+Vue.prototype.$api = process.env.NODE_ENV == 'development' ? "/api" : "http://localhost:9000";
 Vue.http.options.emulateJSON = true;
 Vue.prototype.$md5 = md5;
-Vue.http.options.xhr = { withCredentials: true }
+Vue.http.options.xhr = { withCredentials: true,}
 Vue.http.interceptors.push(function (request, next) {//拦截器
   // 跨域携带cookie
   request.credentials = true;

+ 2 - 0
src/router/index.js

@@ -24,6 +24,8 @@ const routes = [
 
 const router = new VueRouter({
   routes,
+  // mode: process.env.IS_ELECTRON ? 'hash' : "history"
+  mode: "hash"
 });
 
 export default router;

+ 1 - 0
src/utils/request.js

@@ -9,6 +9,7 @@ import {
 import errorCode from '@/utils/errorCode'
 
 axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
+axios.defaults.withCredentials = true;
 // 创建axios实例
 const service = axios.create({
   // axios中请求配置有baseURL选项,表示请求URL公共部分

+ 1 - 2
vue.config.js

@@ -37,7 +37,6 @@ module.exports = {
         // target: `http://192.168.2.112:81/`,
         // target:`http://124.70.8.54:82/`,
         target: `http://evvmapi.vandh.org/`,
-
         changeOrigin: true,
         pathRewrite: {
           ['^' + process.env.VUE_APP_BASE_API]: ''
@@ -45,7 +44,7 @@ module.exports = {
       },
       '/api': {
         // target:'http://192.168.2.112:9000/',
-        target: 'http://127.0.0.1:9000',
+        target: 'http://localhost:9000/',
         changeOrigin: true,
         pathRewrite: {
           '/api': ''