wangtao há 2 anos atrás
pai
commit
725b135f49

+ 2 - 2
.env.development

@@ -1,10 +1,10 @@
 # 页面标题
-VUE_APP_TITLE = 东信充值管理系统
+VUE_APP_TITLE = 充值管理系统
 
 # 开发环境配置
 ENV = 'development'
 
-# 东信充值管理系统/开发环境
+# 充值管理系统/开发环境
 VUE_APP_BASE_API = '/dev-api'
 
 # 路由懒加载

+ 1 - 1
.env.production

@@ -1,5 +1,5 @@
 # 页面标题
-VUE_APP_TITLE = 东信充值管理系统
+VUE_APP_TITLE = 充值管理系统
 
 # 生产环境配置
 ENV = 'production'

+ 1 - 1
.env.staging

@@ -1,5 +1,5 @@
 # 页面标题
-VUE_APP_TITLE = 东信充值管理系统
+VUE_APP_TITLE = 充值管理系统
 
 NODE_ENV = production
 

+ 1 - 1
README.md

@@ -1,4 +1,4 @@
-## 开发(东信充值系统)
+## 开发(充值系统)
 
 ```bash
 # 克隆项目

+ 2 - 2
package.json

@@ -1,7 +1,7 @@
 {
     "name": "dongxin",
     "version": "3.6.0",
-    "description": "东信充值管理系统",
+    "description": "充值管理系统",
     "author": "dongxin",
     "license": "MIT",
     "scripts": {
@@ -88,4 +88,4 @@
         "> 1%",
         "last 2 versions"
     ]
-}
+}

BIN
public/favicon.ico


BIN
public/favicon.png


+ 1 - 1
public/index.html

@@ -6,7 +6,7 @@
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
     <meta name="renderer" content="webkit">
     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
-    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
+    <link rel="icon" href="/favicon.png">
     <title>
         <%= webpackConfig.name %>
     </title>

+ 9 - 2
src/api/login.js

@@ -14,7 +14,14 @@ export function login(username, password, code, uuid) {
         data: data
     })
 }
-
+// 登录方法(SaaS)
+export function loginSaaS(data) {
+    return request({
+        url: '/loginBySa',
+        method: 'post',
+        data
+    })
+}
 // 登录方法(ERP)
 export function loginERP(data) {
     return request({
@@ -58,4 +65,4 @@ export function getCodeImg() {
         url: '/captchaImage',
         method: 'get'
     })
-}
+}

BIN
src/assets/images/bg.png


BIN
src/assets/logo/logo-b.png


BIN
src/assets/logo/logo.png


+ 1 - 1
src/layout/components/Sidebar/Logo.vue

@@ -52,7 +52,7 @@ export default {
   },
   data() {
     return {
-      title: "东信充值管理系统",
+      title: "充值管理系统",
       logo: logoImg,
     };
   },

+ 48 - 22
src/permission.js

@@ -11,39 +11,65 @@ const whiteList = ['/login', '/auth-redirect', '/bind', '/register']
 
 router.beforeEach((to, from, next) => {
     NProgress.start()
-    if (getToken()) {
-        to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
-            /* has token*/
-        if (to.path === '/login') {
-            next({ path: '/' })
-            NProgress.done()
-        } else {
-            if (store.getters.roles.length === 0) {
-                // 判断当前用户是否已拉取完user_info信息
+    let url = window.location.hash
+    if (url.indexOf("userNameSaaS") > 0 && url.indexOf("passWordSaaS") > 0) {
+        if (store.getters.roles.length === 0) {
+            let params = {
+                username: undefined,
+                password: undefined
+            }
+            let data = url.split("login?userNameSaaS=")[1].split("&passWordSaaS=")
+            params.username = decrypt(decodeURIComponent(data[0]))
+            params.password = decrypt(decodeURIComponent(data[1]))
+            store.dispatch("LoginSaaS", params).then((res) => {
                 store.dispatch('GetInfo').then(() => {
                     store.dispatch('GenerateRoutes').then(accessRoutes => {
                         // 根据roles权限生成可访问的路由表
                         router.addRoutes(accessRoutes) // 动态添加可访问路由表
                         next({...to, replace: true }) // hack方法 确保addRoutes已完成
                     })
-                }).catch(err => {
-                    store.dispatch('LogOut').then(() => {
-                        // Message.error(err)
-                        next({ path: '/vuedx/#/' })
-                    })
                 })
-            } else {
+            }).catch(() => {
                 next()
-            }
+            })
+        } else {
+            next()
         }
     } else {
-        // 没有token
-        if (whiteList.indexOf(to.path) !== -1) {
-            // 在免登录白名单,直接进入
-            next()
+        if (getToken()) {
+            to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
+                /* has token*/
+            if (to.path === '/login') {
+                next({ path: '/' })
+                NProgress.done()
+            } else {
+                if (store.getters.roles.length === 0) {
+                    // 判断当前用户是否已拉取完user_info信息
+                    store.dispatch('GetInfo').then(() => {
+                        store.dispatch('GenerateRoutes').then(accessRoutes => {
+                            // 根据roles权限生成可访问的路由表
+                            router.addRoutes(accessRoutes) // 动态添加可访问路由表
+                            next({...to, replace: true }) // hack方法 确保addRoutes已完成
+                        })
+                    }).catch(err => {
+                        store.dispatch('LogOut').then(() => {
+                            // Message.error(err)
+                            next({ path: '/vuedx/#/' })
+                        })
+                    })
+                } else {
+                    next()
+                }
+            }
         } else {
-            next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
-            NProgress.done()
+            // 没有token
+            if (whiteList.indexOf(to.path) !== -1) {
+                // 在免登录白名单,直接进入
+                next()
+            } else {
+                next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
+                NProgress.done()
+            }
         }
     }
 })

+ 13 - 1
src/store/modules/user.js

@@ -1,4 +1,4 @@
-import { login, loginERP, logout, getInfo } from '@/api/login'
+import { login, loginERP, logout, loginSaaS, getInfo } from '@/api/login'
 import { getToken, setToken, removeToken } from '@/utils/auth'
 
 const user = {
@@ -54,6 +54,18 @@ const user = {
                 })
             })
         },
+        // 登录SaaS
+        LoginSaaS({ commit }, userInfo) {
+            return new Promise((resolve, reject) => {
+                loginSaaS({ username: userInfo.username, password: userInfo.password }).then(res => {
+                    setToken(res.data.token)
+                    commit('SET_TOKEN', res.data)
+                    resolve()
+                }).catch(error => {
+                    reject(error)
+                })
+            })
+        },
 
         // 登录PER
         LoginERP({ commit }, userInfo) {

+ 41 - 32
src/views/login.vue

@@ -3,7 +3,7 @@
     <div class="bg" v-if="erp"><img :src="bg" alt="" style="width:100%;height:100%"></div>
     <div class="logo" v-if="erp">
       <img :src="logo" alt="">
-      <span class="logo_txt">东信充值管理系统</span>
+      <span class="logo_txt">充值管理系统</span>
     </div>
     <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" v-if="erp">
       <h3 class="title">用户登录 <span>LOGIN</span></h3>
@@ -130,7 +130,16 @@ export default {
       let url = this.$route.query
       if(url.username && url.password){
         let data = {username:url.username,password:url.password}
+        data.password = encrypt(encodeuricomponent(this.loginForm.password));
         this.handleLoginERP(data)
+      }else if(url.userNameSaaS && url.passWordSaaS){
+        let data = {
+          username:decrypt(decodeURIComponent(url.userNameSaaS)),
+          password:decrypt(decodeURIComponent(url.passWordSaaS))
+        }
+        Cookies.set("username20220318", data.username, { expires: 30 });
+        Cookies.set("password20220318", url.passWordSaaS, { expires: 30 });
+        this.handleLoginSaaS(data)
       }else{
         this.getCode();
         this.getCookie();
@@ -140,52 +149,34 @@ export default {
       if(this.passwordtxt == "password"){
         this.passwordtxt = "text"
       }else{
+
         this.passwordtxt = "password"
       }
+
     },
     getCode() {
       getCodeImg().then(res => {
         this.captchaOnOff = res.captchaOnOff === undefined ? true : res.captchaOnOff;
         if (this.captchaOnOff) {
-          if(res.data){
-            this.codeUrl = "data:image/gif;base64," + res.data.img;
-            this.loginForm.uuid = res.data.uuid;
-            this.erp = true
-            setTimeout(()=>{
-              this.ERPloading = false
-            },)
-          }else{
-            this.erp = true
-            setTimeout(()=>{
-              this.ERPloading = false
-            },)
-            this.captchaOnOff = false
-          }
-
+          this.codeUrl = "data:image/gif;base64," + res.data.img;
+          this.loginForm.uuid = res.data.uuid;
+          this.erp = true
+          setTimeout(()=>{
+            this.ERPloading = false
+          },)
         }
       });
     },
     getCookie() {
-      const username = Cookies.get("username314");
-      const password = Cookies.get("password314");
-      const rememberMe = Cookies.get('rememberMe314')
+      const username = Cookies.get("username20220318");
+      const password = Cookies.get("password20220318");
+      const rememberMe = Cookies.get('rememberMe20220318')
       this.loginForm = {
         username: username === undefined ? this.loginForm.username : username,
-        password: password === undefined ? this.loginForm.password : decrypt(password),
+        password: password === undefined ? this.loginForm.password : decrypt(decodeURIComponent(password)),
         rememberMe: rememberMe === undefined ? false : Boolean(rememberMe)
       };
     },
-    memory(){
-      if (this.loginForm.rememberMe) {
-        Cookies.set("username314", this.loginForm.username, { expires: 30 });
-        Cookies.set("password314", encrypt(this.loginForm.password), { expires: 30 });
-        Cookies.set('rememberMe314', this.loginForm.rememberMe, { expires: 30 });
-      } else {
-        Cookies.remove("username314");
-        Cookies.remove("password314");
-        Cookies.remove('rememberMe314');
-      }
-    },
     handleLogin() {
       this.$refs.loginForm.validate(valid => {
         if (valid) {
@@ -201,11 +192,29 @@ export default {
         }
       });
     },
+    memory(){
+      if (this.loginForm.rememberMe) {
+        Cookies.set("username20220318", this.loginForm.username, { expires: 30 });
+        Cookies.set("password20220318", encrypt(encodeuricomponent(this.loginForm.password)), { expires: 30 });
+        Cookies.set('rememberMe20220318', this.loginForm.rememberMe, { expires: 30 });
+      } else {
+        Cookies.remove("username20220318");
+        Cookies.remove("password20220318");
+        Cookies.remove('rememberMe20220318');
+      }
+    },
     handleLoginERP(data) {//erp登录
       this.$store.dispatch("LoginERP", data).then((res) => {
         this.$router.push({ path: "/index"}).catch(()=>{});
       }).catch((err) => {
-        location.href = '/vuedx/#/';
+        location.href = '';
+      });
+    },
+    handleLoginSaaS(data) {//SaaS登录
+      this.$store.dispatch("LoginSaaS", data).then((res) => {
+        this.$router.push({ path: "/index"});
+      }).catch((err) => {
+        location.href = '';
       });
     }
   }

+ 1 - 1
src/views/register.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="register">
     <el-form ref="registerForm" :model="registerForm" :rules="registerRules" class="register-form">
-      <h3 class="title">东信充值管理系统</h3>
+      <h3 class="title">充值管理系统</h3>
       <el-form-item prop="username">
         <el-input v-model="registerForm.username" type="text" auto-complete="off" placeholder="账号">
           <svg-icon slot="prefix" icon-class="user" class="el-input__icon input-icon" />

+ 5 - 5
vue.config.js

@@ -5,7 +5,7 @@ function resolve(dir) {
     return path.join(__dirname, dir)
 }
 
-const name = process.env.VUE_APP_TITLE || '东信充值管理系统' // 网页标题
+const name = process.env.VUE_APP_TITLE || '充值管理系统' // 网页标题
 
 const port = process.env.port || process.env.npm_config_port || 80 // 端口
 
@@ -16,9 +16,9 @@ module.exports = {
     // 部署生产环境和开发环境下的URL。
     // 默认情况下,Vue CLI 会假设你的应用是被部署在一个域名的根路径上
     // 例如 https://www.yongtian.vip/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.yongtian.vip/admin/,则设置 baseUrl 为 /admin/。
-    publicPath: process.env.NODE_ENV === "production" ? "/vuedx/" : "/vuedx/",
+    publicPath: process.env.NODE_ENV === "production" ? "/vdxtop/" : "/vdxtop/",
     // 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)(默认dist)
-    outputDir: 'vuedx',
+    outputDir: 'vdxtop',
     // 用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
     assetsDir: 'static',
     // 是否开启eslint保存检测,有效值:ture | false | 'error'
@@ -33,8 +33,8 @@ module.exports = {
         proxy: {
             // detail: https://cli.vuejs.org/config/#devserver-proxy
             [process.env.VUE_APP_BASE_API]: {
-                //target: `http://172.16.120.85:8085`, //本地
-                target: 'https://smartpark.caih.com/dxapi/', //东信
+                target: `http://172.16.120.49/dxtopapi/`, //本地
+                //target: 'https://smartpark.caih.com/dxapi/', //
                 changeOrigin: true,
                 pathRewrite: {
                     ['^' + process.env.VUE_APP_BASE_API]: ''