Michael Wang 6 жил өмнө
parent
commit
71b6daba31

+ 1 - 16
src/App.vue

@@ -1,27 +1,12 @@
 <template>
   <div id="app">
-    <img src="./assets/logo.png">
-    <div>
-      <p>
-        If Element is successfully added to this project, you'll see an
-        <code v-text="'<el-button>'"></code>
-        below
-      </p>
-      <el-button>el-button</el-button>
-    </div>
-    <HelloWorld msg="Welcome to Your Vue.js App" />
     <router-view></router-view>
   </div>
 </template>
 
 <script>
-import HelloWorld from "./components/HelloWorld.vue";
-
 export default {
-  name: "app",
-  components: {
-    HelloWorld
-  }
+  name: "app"
 };
 </script>
 

BIN
src/assets/logo.png


+ 0 - 60
src/components/HelloWorld.vue

@@ -1,60 +0,0 @@
-<template>
-  <div class="hello">
-    <h1>{{ msg }}</h1>
-    <p>
-      For a guide and recipes on how to configure / customize this project,<br>
-      check out the
-      <a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
-    </p>
-    <h3>Installed CLI Plugins</h3>
-    <ul>
-      <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
-      <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa" target="_blank" rel="noopener">pwa</a></li>
-      <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
-      <li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-unit-jest" target="_blank" rel="noopener">unit-jest</a></li>
-    </ul>
-    <h3>Essential Links</h3>
-    <ul>
-      <li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
-      <li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
-      <li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
-      <li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
-      <li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
-    </ul>
-    <h3>Ecosystem</h3>
-    <ul>
-      <li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
-      <li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
-      <li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
-      <li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
-      <li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
-    </ul>
-  </div>
-</template>
-
-<script>
-export default {
-  name: "HelloWorld",
-  props: {
-    msg: String
-  }
-};
-</script>
-
-<!-- Add "scoped" attribute to limit CSS to this component only -->
-<style scoped>
-h3 {
-  margin: 40px 0 0;
-}
-ul {
-  list-style-type: none;
-  padding: 0;
-}
-li {
-  display: inline-block;
-  margin: 0 10px;
-}
-a {
-  color: #42b983;
-}
-</style>

BIN
src/modules/portal/assets/images/login_footer_logo.jpg


BIN
src/modules/portal/assets/images/login_main_bg_full.png


BIN
src/modules/portal/assets/images/login_main_left_tree.png


BIN
src/modules/portal/assets/images/new_login_logo.png


+ 177 - 0
src/modules/portal/components/Login.vue

@@ -0,0 +1,177 @@
+<template>
+  <div>
+    <header class="login-header">
+      <a href="javascript:void(0)">
+        <img v-if="!jwptCustomize" src="../assets/images/login_footer_logo.jpg">
+        <img v-if="jwptCustomize" src="../assets/images/new_login_logo.png">
+      </a>
+      <ul>
+        <li>
+          <span></span>
+        </li>
+        <li>
+          <h1 v-if="!jwptCustomize">考试云平台</h1>
+          <h1 v-if="jwptCustomize" style="line-height: 36px; font-size: 24px">{{title}}</h1>
+        </li>
+      </ul>
+    </header>
+    <!--main-->
+    <main class="login-main">
+      <div class="main_bg"></div>
+      <div class="main_box">
+        <div class="left_tree fl"><img src="../assets/images/login_main_left_tree.png"></div>
+        <div class="right_login fr">
+          <div class="login">
+            <h1>用户登录</h1>
+            <div class="username">
+              <i></i>
+              <input @keyup.enter="login()" type="text" id="accountValue" v-model="loginInfo.accountValue" placeholder="账号" />
+            </div>
+            <div class="password">
+              <em></em>
+              <input @keyup.enter="login()" type="password" id="password" v-model="loginInfo.password" placeholder="密码" />
+            </div>
+            <input type="button" value="登 录" class="btn" @click="login()" />
+          </div>
+        </div>
+      </div>
+    </main>
+
+    <!--footer-->
+    <footer class="login-footer">
+      <div class="main">
+        <div>Copyright &copy; 2016
+          <a href="javascript:void(0)">讯飞启明</a>.</div>
+      </div>
+    </footer>
+  </div>
+</template>
+
+<script>
+import { mapActions } from "vuex";
+import { USER_SIGNIN } from "../store/user";
+import { core_api } from "../constants/constants.js";
+
+export default {
+  data() {
+    return {
+      pending: false,
+      errorInfo: "",
+      title: "考试云平台",
+      jwptCustomize: false,
+      loginInfo: {
+        rootOrgId: "",
+        domain: "",
+        accountType: "COMMON_LOGIN_NAME",
+        accountValue: "",
+        password: ""
+      }
+    };
+  },
+  methods: {
+    ...mapActions([USER_SIGNIN]),
+
+    checkAccountValue() {
+      this.errorInfo = "";
+      if (!this.loginInfo.accountValue) {
+        this.errorInfo += "账号不能为空!\n";
+      }
+      if (this.errorInfo) {
+        this.$notify({
+          showClose: true,
+          message: this.errorInfo,
+          type: "error"
+        });
+        return false;
+      }
+      return true;
+    },
+
+    checkPassword() {
+      this.errorInfo = "";
+      if (!this.loginInfo.password) {
+        this.errorInfo += "密码不能为空!\n";
+      }
+      if (this.errorInfo) {
+        this.$notify({
+          showClose: true,
+          message: this.errorInfo,
+          type: "error"
+        });
+        return false;
+      }
+      return true;
+    },
+
+    login() {
+      if (!this.checkAccountValue()) {
+        return;
+      }
+      if (!this.checkPassword()) {
+        return;
+      }
+      if (this.pending) {
+        return;
+      }
+      this.pending = true;
+      var url = core_api + "/auth/login";
+      this.$http
+        .post(url, this.loginInfo)
+        .then(response => {
+          console.log(response);
+          var user = response.body;
+          this.USER_SIGNIN(user);
+          user.loginUrl = "http://" + window.location.host + "/#/login";
+          user.indexUrl = "http://" + window.location.host + "/#/index";
+          window.name = JSON.stringify(user);
+          this.$router.replace({ path: "/index" });
+          this.$notify({
+            message: "登录成功",
+            type: "success"
+          });
+          this.pending = false;
+        })
+        .catch(response => {
+          if (response.status == 500) {
+            this.$notify({
+              showClose: true,
+              message: response.body.desc,
+              type: "error"
+            });
+          }
+          this.pending = false;
+        });
+    },
+    jwptCustomizeMethod() {
+      // 普通高校考试综合管理平台 定制
+      if (location.host === "jwpt.ecs.qmth.com.cn") {
+        document.title = "普通高校-题库";
+        this.title = " | 普通高校-题库";
+        this.jwptCustomize = true;
+      }
+    }
+  },
+
+  created() {
+    this.loginInfo.domain = window.location.host;
+    sessionStorage.clear();
+    var params = this.$route.query;
+
+    this.loginInfo.rootOrgId = params.orgId;
+    console.log("rootOrgId=" + this.loginInfo.rootOrgId);
+
+    this.jwptCustomizeMethod();
+  },
+  watch: {
+    $route(to, from) {
+      this.loginInfo.rootOrgId = to.query.orgId;
+    }
+  }
+};
+</script>
+
+<style lang="css">
+.h1 {
+  font-family: "Micrsoft YaHei";
+}
+</style>

+ 12 - 0
src/modules/portal/constants/constants.js

@@ -0,0 +1,12 @@
+export const core_api = "/api/ecs_core"; //基础信息API
+export const exam_work_api = "/api/ecs_exam_work"; //考务信息系统API
+export const marking_api = "/api/ecs_marking"; //阅卷API
+export const data_process_api = "/api/ecs_data_process"; //数据中间层API
+export const oe_api = "/api/ecs_oe"; //网考API
+export const question_api = "/api/ecs_ques"; //题库API
+
+export const core_url = "http://localhost:8848"; //基础信息系统url
+export const exam_work_url = "http://localhost:8858"; //考务信息系统url
+export const marking_url = "http://localhost:8888"; //阅卷系统url
+export const oe_url = "http://localhost:8878"; //网考系统url
+export const question_url = "http://localhost:8868"; //题库系统url

+ 23 - 0
src/modules/portal/routes/routes.js

@@ -0,0 +1,23 @@
+import Login from "../components/Login.vue";
+
+export default [
+  {
+    path: "/",
+    name: "Login",
+    component: Login
+  },
+  {
+    path: "/login",
+    name: "Login",
+    component: Login
+  }
+  // {
+  //   path: "/about",
+  //   name: "about",
+  //   // route level code-splitting
+  //   // this generates a separate chunk (about.[hash].js) for this route
+  //   // which is lazy-loaded when the route is visited.
+  //   component: () =>
+  //     import(/* webpackChunkName: "about" */ "./views/About.vue")
+  // }
+];

+ 26 - 0
src/modules/portal/store/user.js

@@ -0,0 +1,26 @@
+import Vue from "vue";
+
+export const USER_SIGNIN = "USER_SIGNIN"; //登录成功
+export const USER_SIGNOUT = "USER_SIGNOUT"; //退出登录
+
+export default {
+  state: JSON.parse(sessionStorage.getItem("user")) || {},
+  mutations: {
+    [USER_SIGNIN](state, user) {
+      sessionStorage.setItem("user", JSON.stringify(user));
+      Object.assign(state, user);
+    },
+    [USER_SIGNOUT](state) {
+      sessionStorage.removeItem("user");
+      Object.keys(state).forEach(k => Vue.delete(state, k));
+    }
+  },
+  actions: {
+    [USER_SIGNIN]({ commit }, user) {
+      commit(USER_SIGNIN, user);
+    },
+    [USER_SIGNOUT]({ commit }) {
+      commit(USER_SIGNOUT);
+    }
+  }
+};

+ 0 - 28
src/registerServiceWorker.js

@@ -1,28 +0,0 @@
-/* eslint-disable no-console */
-
-import { register } from "register-service-worker";
-
-if (process.env.NODE_ENV === "production") {
-  register(`${process.env.BASE_URL}service-worker.js`, {
-    ready() {
-      console.log(
-        "App is being served from cache by a service worker.\n" +
-          "For more details, visit https://goo.gl/AFskqB"
-      );
-    },
-    cached() {
-      console.log("Content has been cached for offline use.");
-    },
-    updated() {
-      console.log("New content is available; please refresh.");
-    },
-    offline() {
-      console.log(
-        "No internet connection found. App is running in offline mode."
-      );
-    },
-    error(error) {
-      console.error("Error during service worker registration:", error);
-    }
-  });
-}

+ 2 - 17
src/router.js

@@ -1,27 +1,12 @@
 import Vue from "vue";
 import Router from "vue-router";
-import Home from "./views/Home.vue";
+import LoginRoutes from "./modules/portal/routes/routes";
 
 Vue.use(Router);
 
 let router = new Router({
   mode: "history",
-  routes: [
-    {
-      path: "/",
-      name: "home",
-      component: Home
-    },
-    {
-      path: "/about",
-      name: "about",
-      // route level code-splitting
-      // this generates a separate chunk (about.[hash].js) for this route
-      // which is lazy-loaded when the route is visited.
-      component: () =>
-        import(/* webpackChunkName: "about" */ "./views/About.vue")
-    }
-  ]
+  routes: [...LoginRoutes]
 });
 
 // router.beforeEach((to, from, next) => {

+ 5 - 1
src/store.js

@@ -1,10 +1,14 @@
 import Vue from "vue";
 import Vuex from "vuex";
+import user from "./modules/portal/store/user";
 
 Vue.use(Vuex);
 
 export default new Vuex.Store({
   state: {},
   mutations: {},
-  actions: {}
+  actions: {},
+  modules: {
+    user
+  }
 });

+ 0 - 5
src/views/About.vue

@@ -1,5 +0,0 @@
-<template>
-  <div class="about">
-    <h1>This is an about page</h1>
-  </div>
-</template>

+ 0 - 18
src/views/Home.vue

@@ -1,18 +0,0 @@
-<template>
-  <div class="home">
-    <img alt="Vue logo" src="../assets/logo.png">
-    <HelloWorld msg="Welcome to Your Vue.js App"/>
-  </div>
-</template>
-
-<script>
-// @ is an alias to /src
-import HelloWorld from "@/components/HelloWorld.vue";
-
-export default {
-  name: "home",
-  components: {
-    HelloWorld
-  }
-};
-</script>

+ 71 - 0
vue.config.js

@@ -0,0 +1,71 @@
+let proxy = {
+  "/api/ecs_core": {
+    target: "http://192.168.10.39:8848",
+    changeOrigin: true
+  },
+  "/api/ecs_exam_work": {
+    target: "http://192.168.10.39:8858",
+    changeOrigin: true
+  },
+  "/api/ecs_ques": {
+    target: "http://192.168.10.39:8868",
+    changeOrigin: true
+  },
+  "/api/ecs_oe": {
+    target: "http://192.168.10.39:8878",
+    changeOrigin: true
+  },
+  "/api/ecs_marking": {
+    target: "http://192.168.10.39:8888",
+    changeOrigin: true
+  }
+};
+
+// const stu = [
+//   "/api/ecs_oe",
+//   "/api/ecs_oe_student/",
+//   "/api/sys_param",
+//   "/api/exam_record",
+//   "/api/exam_control",
+//   "/api/exam_question",
+//   "/api/exam_score",
+//   "/api/practice_course",
+//   "/api/practice_detail",
+//   "/api/practice_record",
+//   "/api/exam_captures",
+//   "/api/face_capture",
+//   "/api/face_verify",
+//   "/api/offline_exam"
+// ];
+
+// for (const s of stu) {
+//   proxy[s] = {
+//     target: "http://ecs-dev.qmth.com.cn:8003", // 陈恳
+//     changeOrigin: true
+//   };
+// }
+
+// const mock = [{ source: "/api/mock/exam_question", dest: "/examQuestions" }];
+
+// for (const m of mock) {
+//   proxy[m.source] = {
+//     target: "http://localhost:3000/",
+//     changeOrigin: true,
+//     pathRewrite: {
+//       ".*": m.dest
+//     }
+//   };
+// }
+
+var webpack = require("webpack");
+module.exports = {
+  devServer: {
+    proxy
+  },
+  configureWebpack: {
+    plugins: [
+      // Ignore all locale files of moment.js
+      new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/)
+    ]
+  }
+};