Selaa lähdekoodia

跳转工程机系统

FengChaoYu 3 vuotta sitten
vanhempi
commit
fb4f40a3d0
3 muutettua tiedostoa jossa 88 lisäystä ja 13 poistoa
  1. 9 10
      src/api/setting.js
  2. 77 2
      src/layout/components/Navbar.vue
  3. 2 1
      src/utils/request.js

+ 9 - 10
src/api/setting.js

@@ -135,20 +135,19 @@ export function getOplogList(params) {
   })
 }
 
-// 获取操作日志模块列表
-export function getModuleList(params) {
+// 检查工程机帐号是否有效
+export function checkEngineAccount() {
   return request({
-    url: '/admin/operation/log/module',
-    method: 'get',
-    params
+    url: '/admin/user/engin/checkuser',
+    method: 'post'
   })
 }
 
-// 获取轮播图列表
-export function getBannerList(params) {
+// 绑定工程机帐号
+export function bindEngineAccount(params) {
   return request({
-    url: '/carouselMap/list/page',
-    method: 'get',
+    url: '/admin/user/engin/bind',
+    method: 'post',
     params
   })
 }
@@ -386,4 +385,4 @@ export function editAgreement(params) {
     method: 'post',
     params
   })
-}
+}

+ 77 - 2
src/layout/components/Navbar.vue

@@ -10,7 +10,7 @@
 
       <div class="right-menu-item hover-effect">
         <el-tooltip effect="dark" content="工程机登录" placement="bottom">
-            <a class="el-icon-s-platform" style="font-size: 24px; line-height: 50px;" href="https://mpkf.weixin.qq.com/" target="_blank"></a>
+            <i class="el-icon-s-platform" style="font-size: 24px; line-height: 50px;" @click="toEngine"></i>
         </el-tooltip>
       </div>
 
@@ -39,6 +39,28 @@
         </el-dropdown-menu>
       </el-dropdown>
     </div>
+
+    <el-dialog title="绑定工程机系统" :visible.sync="dialogFormVisible" :modal="false" width="30%">
+      <el-form ref="engineForm" :model="engineForm" :rules="engineFormRules">
+        <el-form-item label="账号" :label-width="formLabelWidth" prop="account">
+          <el-input v-model="engineForm.account" placeholder="请输入账号" autocomplete="off"></el-input>
+        </el-form-item>
+        <el-form-item label="密码" :label-width="formLabelWidth" prop="password">
+          <el-input v-model="engineForm.password" placeholder="请输入密码" autocomplete="off" show-password></el-input>
+        </el-form-item>
+        <input type="hidden" value="zfire" name="vcode" >
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="dialogFormVisible = false">取 消</el-button>
+        <el-button type="primary" @click="submitForm">确 定</el-button>
+      </div>
+    </el-dialog>
+    <form v-show="false" :action="userInfo.enginSysUrl" method="POST">
+      <input type="hidden" :value="userInfo.enginUserName" name="username" />
+      <input type="hidden" :value="userInfo.enginPassword" name="password" />
+      <input type="hidden" value="zfire" name="vcode" >
+      <input type="submit" ref="engineSubmit">
+    </form>
   </div>
 </template>
 
@@ -49,12 +71,29 @@ import Hamburger from '@/components/Hamburger'
 import Screenfull from '@/components/Screenfull'
 import NavMenu from '@/components/NavMenu'
 import {getNoticeListCount} from "@/api/notice";
+import { checkEngineAccount, bindEngineAccount } from '@/api/setting'
+import request from '@/utils/request'
 
 export default {
   data() {
     return {
       timer: '',
-      noticeCount: 0
+      noticeCount: 0,
+      userInfo: '',
+      engineForm: {
+        account: '',
+        password: ''
+      },
+      engineFormRules: {
+        account: [
+          { required: true, message: '请输入工程机账号', trigger: 'blur' }
+        ],
+        password: [
+          { required: true, message: '请输入工程机密码', trigger: 'blur' }
+        ]
+      },
+      formLabelWidth: '100px',
+      dialogFormVisible: false
     }
   },
   mounted() {
@@ -64,6 +103,7 @@ export default {
     this.timer = setInterval(function () {
       that.initNotice()
     }, 3000)
+    this.userInfo = JSON.parse(localStorage.getItem("greemall_user"))
   },
   beforeDestroy() {
     window.clearInterval(this.timer)
@@ -109,6 +149,41 @@ export default {
     },
     goNotice() {
       this.$router.push('/notice/index')
+    },
+    toEngine() {
+      const userInfoCopy = this.userInfo
+      if (userInfoCopy && userInfoCopy.bindEngin) {
+        checkEngineAccount().then(res => {
+          if (res.code === 200) {
+            this.$refs.engineSubmit.click()
+          } else {
+            this.$errorMsg("账号密码错误,请重新绑定")
+            this.dialogFormVisible = true
+          }
+        })
+      } else {
+        this.dialogFormVisible = true
+      }
+    },
+    submitForm() {
+      this.$refs.engineForm.validate(valid => {
+        if (valid) {
+          const params = {
+            enginUserName: this.engineForm.account,
+            enginPassword: this.engineForm.password
+          }
+          bindEngineAccount(params).then(res => {
+            if (res.code === 200) {
+              this.$successMsg("绑定成功,正在打开工程机系统")
+              this.$store.dispatch('user/getInfo').then(() => {
+                this.userInfo.enginUserName = this.engineForm.account
+                this.userInfo.enginPassword = this.engineForm.password
+                this.$refs.engineSubmit.click()
+              })
+            }
+          })
+        }
+      })
     }
   }
 }

+ 2 - 1
src/utils/request.js

@@ -9,6 +9,7 @@ const service = axios.create({
   // withCredentials: true, // send cookies when cross-domain requests
   timeout: 300000 // request timeout
 })
+const whiteCodes = [200, 4444]
 
 // request interceptor
 service.interceptors.request.use(
@@ -46,7 +47,7 @@ service.interceptors.response.use(
     const res = response.data
 
     // if the custom code is not 20000, it is judged as an error.
-    if (res.code !== 200) {
+    if (whiteCodes.indexOf(res.code) < 0) {
       Message({
         message: res.message || 'Error',
         type: 'error',