ソースを参照

change:
1. 添加session支持
2. 登录页面制作
xxxx:
1. 登录接口制作

kindring 2 年 前
コミット
2773c9d013

ファイルの差分が大きいため隠しています
+ 0 - 0
assets/icons/svg/product-setting.svg


+ 58 - 26
pages/manger/Login.vue

@@ -1,20 +1,20 @@
 <template>
-  <div class="bgimg w-full h-full flex bg-black">
+  <div id="app" class="bgImg w-full h-full flex bg-black">
     <div class=" w-8/12 h-full hidden md:flex justify-center items-center p-10 bg-blue-400 relative bg-map">
-        <div class="w-full h-full bgimg absolute"></div>
+        <div class="w-full h-full bgImg absolute"></div>
         <div class="w-full h-4/5 bottom-0 absolute flex items-center justify-center relative">
           <div class="lbx absolute">
-            <img src="/public/image/big/lbx.png" alt="lbx">
+            <img src="/image/big/lbx.png" alt="lbx">
           </div>
 
           <div class="jt absolute ">
-            <img src="/public/image/big/jt.png" alt="背景图片">
+            <img src="/image/big/jt.png" alt="背景图片">
           </div>
           <div class="map absolute ">
-            <img src="/public/image/big/map.png" alt="地球">
+            <img src="/image/big/map.png" alt="地球">
           </div>
           <div class="rounded-img absolute ">
-            <img src="/public/image/big/rounded.png" alt="地球">
+            <img src="/image/big/rounded.png" alt="地球">
           </div>
           <div class="w-auto relative bottom-1/5">
             <h1 class="text-7xl text-white">合方圆管理平台</h1>
@@ -26,7 +26,7 @@
     </div>
 <!--    登陆框逻辑-->
     <div class="w-full md:w-3/12   h-full flex justify-center md:justify-start items-center relative">
-      <div class="blur w-full h-full absolute bg-blue-300 opacity-50 bgimg"></div>
+      <div class="blur w-full h-full absolute bg-blue-300 opacity-50 bgImg"></div>
       <div class="login-box w-80 h-auto rounded px-0.5 text-gray-200 relative">
         <h2 class="pt-2 text-xl">欢迎您,请登陆</h2>
 
@@ -63,7 +63,7 @@
             <div class="w-full  text-red-600" v-show="form.captcha.msg" >
               {{form.captcha.msg}}
             </div>
-            <captcha class="w-full h-24 overflow-hidden mt-1.5 rounded" ref="captchaImg" captcha-url="/captcha/"></captcha>
+            <captcha class="w-full h-24 overflow-hidden mt-1.5 rounded" ref="captchaImg" captcha-url="/api/captcha/"></captcha>
           </div>
         </div>
 
@@ -75,9 +75,9 @@
         </div>
         <div class="border-t px-2  ">
           <span class="mr-4 text-blue-300" >
-            <a href="/register">立即注册</a>
+            <a href="/">备案号</a>
           </span>
-          <a href="/hfy_login">主站点</a>
+          <a href="/">首页</a>
         </div>
       </div>
     </div>
@@ -86,25 +86,42 @@
 </template>
 
 <script>
-import Captcha from "@components/user/captcha";
-import apis from '@/apis/apis'
-import handle from "@/utils/handle";
-import business from "@/utils/business";
-import LightButton from "@components/public/lightButton";
-import fieldIsAllow from "@/utils/fieldIsAllow"
-import userData from  "@/saves/users";
+
+import Vue from 'vue'
+// 引用ant-design-vue的input组件
+import antInput from 'ant-design-vue/lib/input';
+import 'ant-design-vue/dist/antd.css'
+
+
+// import apis from '@/apis/apis'
+import handle from "~/until/handle";
+import business from "~/until/business";
+import fieldIsAllow from "~/until/fieldIsAllow"
+import userData from  "~/until/saves/users";
+
+import Captcha from "~/components/public/captcha";
+import LightButton from "~/components/public/lightButton";
+import {login_types} from "../../store/login";
+
+Vue.use(antInput);
+
 export default {
   name: 'App',
   components: {
     LightButton,
-    Captcha
+    Captcha,
+  },
+  async asyncData(ctx) {
+
   },
   beforeCreate() {
-    // 修改页面title
-    document.title = '合方圆-登陆';
+    // 修改页面title nuxt
+    // this.$store.commit('setPageTitle', '合方圆管理平台');
+
   },
   data(){
     return {
+      test: 'test',
       // 是否为固定
       labelCol: { span: 4 },
       wrapperCol: { span: 16 },
@@ -130,6 +147,9 @@ export default {
     }
   },
   computed:{
+    captcha () {
+      return this.$store.state.login.captcha
+    }
   },
   beforeMount(){
   },
@@ -138,8 +158,13 @@ export default {
     if(url){
       this.jumpUrl = url;
     }
+
   },
   methods:{
+    setCaptcha(captcha){
+      // this.$store..commit(login_types.mutations.SET_CAPTCHA, captcha);
+      this.$store.commit('login/'+login_types.mutations.SET_CAPTCHA, captcha);
+    },
     resetForm(){
       this.form.owner = '';
       this.form.password = '';
@@ -147,6 +172,8 @@ export default {
     },
     checkFormItem(field){
       console.log(field);
+
+      this.setCaptcha(this.form[field].val);
       if (field){
         this.form[field].msg = fieldIsAllow({
           [field]:this.form[field].val,
@@ -171,7 +198,12 @@ export default {
       let owner = this.form.owner.val;
       let passwd = this.form.password.val;
       let captcha = this.form.captcha.val;
-      let [err,response] = await handle(apis.user.login(owner,passwd,captcha));
+      // apis.user.login(owner,passwd,captcha)
+      let [err,response] = await handle(this.$axios.post('/api/user/login',{
+        owner,
+        passwd,
+        captcha,
+      }));
       let rcodeMean = business.checkResponseRcode(response,err);
       if(rcodeMean.ok){
         let res = rcodeMean.res;
@@ -215,14 +247,14 @@ export default {
 </script>
 
 <style>
-body{
+html,body{
   margin: 0;
   padding: 0;
   height: 100vh;
   font-family: sans-serif;
 }
-.bgimg{
-  background: url("/public/image/big/bg.jpg") center no-repeat;
+.bgImg{
+  background: url("/image/big/bg.png") center no-repeat;
 }
 #app {
   font-family: Avenir, Helvetica, Arial, sans-serif;
@@ -230,8 +262,8 @@ body{
   -moz-osx-font-smoothing: grayscale;
   text-align: center;
   color: #2c3e50;
-  width: 100%;
-  height: 100%;
+  width: 100vw;
+  height: 100vh;
 }
 .login-box{
   transform: translate(-50%, -0%);

+ 7 - 0
server/control/c_user.js

@@ -0,0 +1,7 @@
+const {handle} = require('../tools/handle');
+const log = require("../logger").logger("c_user","info");
+const d_user = require("../database/d_user");
+
+function login(owner,passwd){
+  return d_user.login(owner,passwd);
+}

+ 56 - 0
server/router/r_user.js

@@ -0,0 +1,56 @@
+const router = require('express').Router();
+const {paramFail, ServerError, success, controlError, searchSuccess} = require("../tools/result");
+const c = require("../control/c_user");
+const typeTool = require("../tools/typeTool");
+const {toSqlString} = require("../tools/searchSql");
+const log = require("../logger").logger("r_solution","info");
+
+router.post('/login', async (req, res) => {
+  try{
+    let err, userData;
+    let {account, passwd, captcha} = req.body;
+    if(!account || !passwd || !captcha){
+      paramFail(res, "account or password or captcha is required");
+      return;
+    }
+    // 检查验证码
+    if (captcha.toLowerCase() !== req.session.captcha) return paramFail(res,`验证码错误` );
+
+    // 转义解码参数
+    let safePasswd = toSqlString(passwd);
+    account = toSqlString(account);
+    passwd = decode.decodePasswd(passwd);
+
+
+
+    // 生成登陆记录
+    let loginData = {
+      loginIp: req.ip.match(/\d+\.\d+\.\d+\.\d+/),
+      account: account,
+      passwd: safePasswd,
+      loginTime: time.getUnixTimeStamp(),
+      isLogin: false
+    }
+    // 加密模块
+    // 尝试查找账户
+    [err,userData] = await c_user.userLogin(account, passwd);
+    if(err){
+      log.warn(`[用户登录] 登陆失败 ${err.message}`);
+      paramFail(res, `登陆失败 ${err.message}`);
+    }else{
+      loginData.isLogin = true;
+      loginData.userId = userData['userId'];
+      // 存储用户状态到session
+      req.session[progressField.session_hfy] = userData;
+      res.json({
+        rcode: codeMap.ok,
+        data: userData
+      });
+    }
+    let [Err,isOk] = await c_user.saveLoginData(loginData);
+  }catch (e) {
+    ServerError(res, null, e.message);
+  }
+});
+
+module.exports =  router ;

BIN
static/image/big/amiddboxttop.png


BIN
static/image/big/box-c.png


BIN
static/image/big/box-t.png


BIN
static/image/big/box.png


BIN
static/image/big/box.psd


BIN
static/image/big/div-lb.png


BIN
static/image/big/div-lt.png


BIN
static/image/big/div-rb.png


BIN
static/image/big/div-rt.png


BIN
static/image/big/hj.png


BIN
static/image/big/info-img-1.png


BIN
static/image/big/info-img-2.png


BIN
static/image/big/info-img-3.png


BIN
static/image/big/info-img-4.png


BIN
static/image/big/info-text.png


BIN
static/image/big/info-title.png


BIN
static/image/big/map_bg-sub.png


BIN
static/image/big/map_bg.png


BIN
static/image/big/map_bg.psd


BIN
static/image/big/title-hover.png


BIN
static/image/big/title-select.png


BIN
static/image/big/title.png


BIN
static/image/big/title.psb


BIN
static/image/big/title.psd


+ 21 - 21
store/login.js

@@ -1,13 +1,20 @@
-export const types = {
-  SET_USER_INFO: 'SET_USER_INFO',
-  SET_IS_LOGIN: 'SET_IS_LOGIN',
-  SET_CAPTCHA: 'SET_CAPTCHA'
+export const login_types = {
+  mutations: {
+    userLogin: 'userLogin',
+    userLogout: 'userLogout',
+    SET_IS_LOGIN: 'SET_IS_LOGIN',
+    SET_CAPTCHA: 'SET_CAPTCHA'
+  },
+  actions: {
+    tryLogin: 'tryLogin',
+  },
+
 }
 export const state = function (){
   return {
     userInfo: {
       id: '',
-        name: '',
+      name: '',
     },
     isLogin: false,
     captcha: '1'
@@ -15,31 +22,24 @@ export const state = function (){
 }
 
 export const mutations = {
-  [types.SET_USER_INFO](state, userInfo) {
+  [login_types.mutations.userLogin](state, userInfo) {
     state.userInfo = userInfo;
+    state.isLogin = true;
+  },
+  [login_types.mutations.userLogout](state) {
+    state.userInfo = {};
+    state.isLogin = false;
   },
-  [types.SET_IS_LOGIN](state, isLogin) {
+  [login_types.mutations.SET_IS_LOGIN](state, isLogin) {
     state.isLogin = isLogin;
   },
-  [types.SET_CAPTCHA](state, captcha) {
+  [login_types.mutations.SET_CAPTCHA](state, captcha) {
     state.captcha = captcha;
   }
 }
 
 export const actions = {
-  setUserInfo({ commit }, userInfo) {
-    commit(types.SET_USER_INFO, userInfo);
-  },
-  async nuxtServerInit ({ commit }, { req }) {
-    console.log(req.session);
-    if (req.session.user) {
-      commit(types.SET_USER_INFO, req.session.user)
-    }
-    commit(types.SET_CAPTCHA, 'req.session.captcha')
-    if (req.session.captcha) {
-      commit(types.SET_CAPTCHA, req.session.captcha)
-    }
-  }
+
 }
 
 export const getters = {

+ 2 - 0
until/FcCrypto/FcCrypto.js

@@ -0,0 +1,2 @@
+// 加密模块,使用
+::

+ 1 - 1
until/business.js

@@ -1,5 +1,5 @@
 // 统一处理业务逻辑
-import code from '@/maps/rcodeMap'
+import code from '~/map/rcodeMap'
 let rcodeHandleMap = {
 };
 function registerHandle(rcode,handle){

+ 1 - 1
until/fieldIsAllow.js

@@ -1,4 +1,4 @@
-import {toString} from "@/utils/typeTool";
+import {toString} from "./typeTool";
 
 let requiredRuleItem = {require: true,message:'该项为必填项'}
 let phoneRule = [{

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません