Browse Source

接口调用及联调

孙志雷 6 years ago
parent
commit
5da5f83be5

+ 4 - 0
build/webpack.base.conf.js

@@ -33,6 +33,10 @@ module.exports = {
         ? config.build.assetsPublicPath
         : config.dev.assetsPublicPath
   },
+  externals: {
+    vue: 'Vue',
+    'element-ui':'ELEMENT'
+  },
   resolve: {
     extensions: ['.js', '.vue', '.json'],
     alias: {

+ 2 - 1
config/dev.env.js

@@ -4,5 +4,6 @@ const prodEnv = require('./prod.env')
 
 module.exports = merge(prodEnv, {
   NODE_ENV: '"development"',
-  BASE_API: '"https://easy-mock.com/mock/5950a2419adc231f356a6636/vue-admin"',
+  BASE_API: '"https://whiteboardtest.ai160.com"',
+  // BASE_API: '"https://easy-mock.com/mock/5950a2419adc231f356a6636/vue-admin"',
 })

+ 1 - 1
config/index.js

@@ -57,7 +57,7 @@ module.exports = {
      * then assetsPublicPath should be set to "/bar/".
      * In most cases please use '/' !!!
      */
-    assetsPublicPath: '/',
+    assetsPublicPath: './',
 
     /**
      * Source Maps

+ 2 - 1
config/prod.env.js

@@ -1,5 +1,6 @@
 'use strict'
 module.exports = {
   NODE_ENV: '"production"',
-  BASE_API: '"https://easy-mock.com/mock/5950a2419adc231f356a6636/vue-admin"',
+  BASE_API: '"https://whiteboardtest.ai160.com"',
+  // BASE_API: '"https://easy-mock.com/mock/5950a2419adc231f356a6636/vue-admin"',
 }

+ 4 - 0
index.html

@@ -8,5 +8,9 @@
   <body>
     <div id="app"></div>
     <!-- built files will be auto injected -->
+    <!-- 先引入 Vue -->
+    <script src="https://unpkg.com/vue@2.4.2/dist/vue.js"></script>
+    <!-- 引入组件库 -->
+    <script src="https://unpkg.com/element-ui@1.4.7/lib/index.js"></script>
   </body>
 </html>

+ 18 - 14
src/api/login.js

@@ -1,21 +1,10 @@
 import request from '@/utils/request'
 
-export function login(username, password) {
+export function getInfo(uid) {
   return request({
-    url: '/user/login',
-    method: 'post',
-    data: {
-      username,
-      password
-    }
-  })
-}
-
-export function getInfo(token) {
-  return request({
-    url: '/user/info',
+    url: '/wx/user/getUser',
     method: 'get',
-    params: { token }
+    params: { uid }
   })
 }
 
@@ -25,3 +14,18 @@ export function logout() {
     method: 'post'
   })
 }
+// 获取登录二维码
+export function loginCode() {
+  return request({
+    url: '/wx/qrCode/login',
+    method: 'get'
+  })
+}
+// 登录是否成功
+export function loginSuccess(code) {
+  return request({
+    url: `/wx/user/check`,
+    method: 'get',
+    params: { code }
+  })
+}

+ 46 - 0
src/api/table.js

@@ -1,4 +1,5 @@
 import request from '@/utils/request'
+// import { getToken } from '@/utils/auth'
 
 export function getList(params) {
   return request({
@@ -7,3 +8,48 @@ export function getList(params) {
     params
   })
 }
+// 获取参会人员
+export function joinUser(uid) {
+  return request({
+    url: `/wx/joinUser`,
+    method: 'get',
+    params: {
+      uid,
+      pageNo: '',
+      pageSize: '',
+      taskId: ''
+    }
+  })
+}
+// 获取参会文件
+export function taskFile(taskId) {
+  return request({
+    url: `/wx/taskFile`,
+    method: 'get',
+    params: {
+      taskId
+    }
+  })
+}
+// 添加观看记录
+export function addViewLog(fileId, taskId) {
+  return request({
+    url: `/wx/viewLog`,
+    method: 'post',
+    data: {
+      fileId,
+      taskId
+    }
+  })
+}
+// 观看记录列表
+export function getViewLogList(pageNo, pageSize) {
+  return request({
+    url: `/wx/viewLog`,
+    method: 'get',
+    data: {
+      pageNo,
+      pageSize
+    }
+  })
+}

+ 7 - 6
src/permission.js

@@ -2,7 +2,7 @@ import router from './router'
 import store from './store'
 import NProgress from 'nprogress' // Progress 进度条
 import 'nprogress/nprogress.css'// Progress 进度条样式
-import { Message } from 'element-ui'
+// import { Message } from 'element-ui'
 import { getToken } from '@/utils/auth' // 验权
 
 const whiteList = ['/login'] // 不重定向白名单
@@ -14,13 +14,14 @@ router.beforeEach((to, from, next) => {
       NProgress.done() // if current page is dashboard will not trigger	afterEach hook, so manually handle it
     } else {
       if (store.getters.roles.length === 0) {
+        next()
         store.dispatch('GetInfo').then(res => { // 拉取用户信息
           next()
-        }).catch((err) => {
-          store.dispatch('FedLogOut').then(() => {
-            Message.error(err || 'Verification failed, please login again')
-            next({ path: '/' })
-          })
+        }).catch(() => {
+          // store.dispatch('FedLogOut').then(() => {
+          //   Message.error(err || 'Verification failed, please login again')
+          //   next({ path: '/' })
+          // })
         })
       } else {
         next()

+ 2 - 2
src/router/index.js

@@ -39,9 +39,9 @@ export const constantRouterMap = [
     component: Layout,
     children: [
       {
-        path: 'allFile',
+        path: 'index',
         name: 'allFile',
-        component: () => import('@/views/AllFile/index'),
+        component: () => import('@/views/allFile/index'),
         meta: { title: '全部文件', icon: 'el-icon-document' }
       }
     ]

+ 16 - 1
src/store/getters.js

@@ -4,6 +4,21 @@ const getters = {
   token: state => state.user.token,
   avatar: state => state.user.avatar,
   name: state => state.user.name,
-  roles: state => state.user.roles
+  roles: state => state.user.roles,
+  code: state => {
+    return state.user.code
+  },
+  loginDate: state => {
+    return state.user.loginUser
+  },
+  joinUserList: state => {
+    return state.list.joinUserList
+  },
+  fileList: state => {
+    return state.list.fileList
+  },
+  logList: state => {
+    return state.list.logList
+  }
 }
 export default getters

+ 5 - 4
src/store/index.js

@@ -1,15 +1,16 @@
-import Vue from 'vue'
+// import Vue from 'vue'
 import Vuex from 'vuex'
 import app from './modules/app'
 import user from './modules/user'
+import list from './modules/list'
 import getters from './getters'
-
-Vue.use(Vuex)
+// Vue.use(Vuex)
 
 const store = new Vuex.Store({
   modules: {
     app,
-    user
+    user,
+    list
   },
   getters
 })

+ 65 - 0
src/store/modules/list.js

@@ -0,0 +1,65 @@
+import { joinUser, taskFile, getViewLogList } from '@/api/table'
+import { getToken } from '@/utils/auth'
+
+const user = {
+  state: {
+    uid: getToken(),
+    joinUserList: [],
+    fileList: [],
+    logList: []
+  },
+
+  mutations: {
+    SET_JOINUSERLIST: (state, list) => {
+      state.joinUserList = list
+    },
+    SET_FILELIST: (state, data) => {
+      state.fileList = [...data.localFile, ...data.screenshot]
+    },
+    SET_LOGLIST: (state, data) => {
+      state.logList = data.list
+    }
+  },
+
+  actions: {
+    // 获取参会人员
+    JoinUser({ commit, state }) {
+      return new Promise((resolve, reject) => {
+        joinUser(getToken()).then(response => {
+          const data = response.data
+          commit('SET_JOINUSERLIST', data.list)
+          resolve(data)
+        }).catch(error => {
+          reject(error)
+        })
+      })
+    },
+    // 获取参会文件
+    TaskFile({ commit }, taskId) {
+      return new Promise((resolve, reject) => {
+        taskFile(taskId).then(response => {
+          console.log(response)
+          const data = response.data
+          commit('SET_FILELIST', data)
+          resolve(data)
+        }).catch(error => {
+          reject(error)
+        })
+      })
+    },
+    // 获取浏览信息
+    GetViewLogList({ commit }, pageNo, pageSize) {
+      return new Promise((resolve, reject) => {
+        getViewLogList(pageNo, pageSize).then(response => {
+          const data = response.data
+          commit('SET_LOGLIST', data)
+          resolve(data)
+        }).catch(error => {
+          reject(error)
+        })
+      })
+    }
+  }
+}
+
+export default user

+ 43 - 24
src/store/modules/user.js

@@ -1,12 +1,15 @@
-import { login, logout, getInfo } from '@/api/login'
-import { getToken, setToken, removeToken } from '@/utils/auth'
+import { logout, getInfo, loginCode, loginSuccess } from '@/api/login'
+import { getToken, removeToken } from '@/utils/auth'
 
 const user = {
   state: {
     token: getToken(),
     name: '',
     avatar: '',
-    roles: []
+    roles: [],
+    code: '',
+    codeNum: '',
+    loginUser: {}
   },
 
   mutations: {
@@ -21,36 +24,24 @@ const user = {
     },
     SET_ROLES: (state, roles) => {
       state.roles = roles
+    },
+    SET_CODE: (state, code) => {
+      state.code = code.qrCode
+      state.codeNum = code.code
+    },
+    SET_LOGIN: (state, loginData) => {
+      state.loginUser = loginData.data
     }
   },
 
   actions: {
-    // 登录
-    Login({ commit }, userInfo) {
-      const username = userInfo.username.trim()
-      return new Promise((resolve, reject) => {
-        login(username, userInfo.password).then(response => {
-          const data = response.data
-          setToken(data.token)
-          commit('SET_TOKEN', data.token)
-          resolve()
-        }).catch(error => {
-          reject(error)
-        })
-      })
-    },
 
     // 获取用户信息
     GetInfo({ commit, state }) {
       return new Promise((resolve, reject) => {
-        getInfo(state.token).then(response => {
+        getInfo(getToken()).then(response => {
           const data = response.data
-          if (data.roles && data.roles.length > 0) { // 验证返回的roles是否是一个非空数组
-            commit('SET_ROLES', data.roles)
-          } else {
-            reject('getInfo: roles must be a non-null array !')
-          }
-          commit('SET_NAME', data.name)
+          commit('SET_NAME', data.nickName)
           commit('SET_AVATAR', data.avatar)
           resolve(response)
         }).catch(error => {
@@ -80,6 +71,34 @@ const user = {
         removeToken()
         resolve()
       })
+    },
+    // 获取登录二维码
+    LoginCode({ commit }) {
+      return new Promise((resolve, reject) => {
+        loginCode().then(response => {
+          const data = response.data
+          commit('SET_CODE', data)
+          // console.log(this._actions)
+          // this._actions.loginSuccess[0]()
+          resolve()
+        }).catch(error => {
+          reject(error)
+        })
+      })
+    },
+    // 获取登录二维码
+    loginSuccess({ commit, state }) {
+      return new Promise((resolve, reject) => {
+        loginSuccess(state.codeNum).then(response => {
+          // const data = response.data.data
+          if (response) {
+            commit('SET_LOGIN', response)
+            resolve(response)
+          } else {
+            reject('错误')
+          }
+        })
+      })
     }
   }
 }

+ 1 - 0
src/styles/sidebar.scss

@@ -45,6 +45,7 @@
     .el-menu {
       border: none;
       width: 100% !important;
+      background-color: #F0F4F8;
     }
     .is-active > .el-submenu__title{
       color: #f4f4f5!important;

+ 22 - 22
src/utils/request.js

@@ -1,6 +1,6 @@
 import axios from 'axios'
-import { Message, MessageBox } from 'element-ui'
-import store from '../store'
+import { Message } from 'element-ui'
+// import store from '../store'
 import { getToken } from '@/utils/auth'
 
 // 创建axios实例
@@ -12,8 +12,8 @@ const service = axios.create({
 // request拦截器
 service.interceptors.request.use(
   config => {
-    if (store.getters.token) {
-      config.headers['X-Token'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
+    if (getToken()) {
+      config.headers['uid'] = getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
     }
     return config
   },
@@ -31,7 +31,7 @@ service.interceptors.response.use(
      * code为非20000是抛错 可结合自己业务进行修改
      */
     const res = response.data
-    if (res.code !== 20000) {
+    if (res.code !== 200) {
       Message({
         message: res.message,
         type: 'error',
@@ -39,22 +39,22 @@ service.interceptors.response.use(
       })
 
       // 50008:非法的token; 50012:其他客户端登录了;  50014:Token 过期了;
-      if (res.code === 50008 || res.code === 50012 || res.code === 50014) {
-        MessageBox.confirm(
-          '你已被登出,可以取消继续留在该页面,或者重新登录',
-          '确定登出',
-          {
-            confirmButtonText: '重新登录',
-            cancelButtonText: '取消',
-            type: 'warning'
-          }
-        ).then(() => {
-          store.dispatch('FedLogOut').then(() => {
-            location.reload() // 为了重新实例化vue-router对象 避免bug
-          })
-        })
-      }
-      return Promise.reject('error')
+      // if (res.code === 50008 || res.code === 50012 || res.code === 50014) {
+      //   MessageBox.confirm(
+      //     '你已被登出,可以取消继续留在该页面,或者重新登录',
+      //     '确定登出',
+      //     {
+      //       confirmButtonText: '重新登录',
+      //       cancelButtonText: '取消',
+      //       type: 'warning'
+      //     }
+      //   ).then(() => {
+      //     store.dispatch('FedLogOut').then(() => {
+      //       location.reload() // 为了重新实例化vue-router对象 避免bug
+      //     })
+      //   })
+      // }
+      // return Promise.reject('error')
     } else {
       return response.data
     }
@@ -66,7 +66,7 @@ service.interceptors.response.use(
       type: 'error',
       duration: 5 * 1000
     })
-    return Promise.reject(error)
+    // return Promise.reject(error)
   }
 )
 

+ 33 - 29
src/views/allFile/index.vue

@@ -2,7 +2,7 @@
   <div class="app-container">
     <el-table
       ref="multipleTable"
-      :data="tableData3"
+      :data="joinUserList"
       tooltip-effect="dark"
       style="width: 100%"
       @selection-change="handleSelectionChange"
@@ -11,58 +11,62 @@
         type="selection"
         width="55"/>
       <el-table-column
-        label="已选中4个文件夹/文件">
+        :label=" '选中' +multipleSelection.length.toString() + '文件/文件夹'">
         <template slot-scope="scope">
           <img src="@/icons/image/file_icon.png" alt="file_icon">
         </template>
       </el-table-column>
       <el-table-column
-        prop="name"/>
+        prop="task.title"/>
       <el-table-column
         label="日期"
-        width="120"
+        width="160"
         show-overflow-tooltip>
-        <template slot-scope="scope">{{ scope.row.date }}</template>
+        <template slot-scope="scope">{{ scope.row.task.gmtCreated }}</template>
       </el-table-column>
     </el-table>
   </div>
 </template>
 
 <script>
+import { mapGetters } from 'vuex'
+import { parseTime } from '@/utils/index'
+
 export default {
   data() {
     return {
-      tableData3: [
-        {
-          date: '2016-05-03',
-          name: '王小虎',
-          address: '上海市普陀区金沙江路 1518 弄'
-        },
-        {
-          date: '2016-05-03',
-          name: '王小虎',
-          address: '上海市普陀区金沙江路 1518 弄'
-        }
-      ],
       multipleSelection: []
     }
   },
-
+  computed: {
+    ...mapGetters([
+      'joinUserList'
+    ])
+  },
+  created() {
+    this.getList()
+  },
   methods: {
-    // toggleSelection(rows) {
-    //   if (rows) {
-    //     rows.forEach(row => {
-    //       this.$refs.multipleTable.toggleRowSelection(row)
-    //     })
-    //   } else {
-    //     this.$refs.multipleTable.clearSelection()
-    //   }
-    // },
+    getList() {
+      this.$store.dispatch('JoinUser').then((res) => {
+        console.log(res.list)
+        // 格式化时间
+        res.list.forEach((item, index) => {
+          this.joinUserList[index].task.gmtCreated = parseTime(item.task.gmtCreated)
+        })
+      })
+    },
     handleSelectionChange(val) {
       this.multipleSelection = val
     },
-    detail() {
-      this.$router.push({ path: '/fileDetail/fileDetail' })
+    detail(row, event) {
+      const taskId = row.task.id
+      const title = row.task.title
+      const name = event.target.classList[0]
+      if (name === 'el-checkbox__inner' || name === 'el-checkbox__original') {
+        return false
+      }
+      this.$router.push({ path: `/fileDetail/fileDetail`, query: { 'taskId': taskId, 'title': title }})
     }
   }
 }

+ 70 - 18
src/views/browse/index.vue

@@ -1,34 +1,82 @@
 <template>
   <div class="app-container">
-    最近浏览
+    <el-table
+      ref="multipleTable"
+      :data="logList"
+      tooltip-effect="dark"
+      style="width: 100%"
+      @selection-change="handleSelectionChange"
+      @row-click="detail">
+      <el-table-column
+        type="selection"
+        width="55"/>
+      <el-table-column
+        :label="title">
+        <template slot-scope="scope">
+          <img :src="(scope.row.taskFile.fileType == 'png' || scope.row.taskFile.fileType == 'jpg') ? scope.row.taskFile.path : '../../../static/fileimg/'+scope.row.taskFile.fileType+'.png'" alt="file_icon">
+        </template>
+      </el-table-column>
+      <el-table-column
+        prop="taskFile.fileName"/>
+      <el-table-column
+        label="日期"
+        width="160"
+        show-overflow-tooltip>
+        <template slot-scope="scope">{{ scope.row.taskFile.gmtCreated }}</template>
+      </el-table-column>
+    </el-table>
   </div>
 </template>
 
 <script>
+import { mapGetters } from 'vuex'
+import { parseTime } from '@/utils/index'
+import { addViewLog } from '@/api/table'
+// import axios from 'axios'
+
 export default {
   data() {
     return {
-      form: {
-        name: '',
-        region: '',
-        date1: '',
-        date2: '',
-        delivery: false,
-        type: [],
-        resource: '',
-        desc: ''
-      }
+      title: '',
+      multipleSelection: []
     }
   },
+
+  computed: {
+    ...mapGetters([
+      'logList'
+    ])
+  },
+
+  created() {
+    const taskId = this.$route.query.taskId
+    const title = this.$route.query.title
+    this.title = title
+    this.getFileList(taskId)
+  },
+
   methods: {
-    onSubmit() {
-      this.$message('submit!')
-    },
-    onCancel() {
-      this.$message({
-        message: 'cancel!',
-        type: 'warning'
+    getFileList(taskId) {
+      this.$store.dispatch('GetViewLogList').then((res) => {
+        console.log(this.logList)
+        // 格式化时间和文件格式
+        res.list.forEach((item, index) => {
+          this.logList[index].taskFile.gmtCreated = parseTime(item.taskFile.gmtCreated)
+          this.logList[index].taskFile.fileType = item.taskFile.path.slice(item.taskFile.path.lastIndexOf('.') + 1)
+        })
       })
+    },
+    handleSelectionChange(val) {
+      this.multipleSelection = val
+    },
+    detail(row) {
+      const link = document.createElement('a')
+      link.style.display = 'none'
+      link.href = `https://whiteboardtest.ai160.com/download?path=${row.path}&fileName=${row.fileName}`
+      link.setAttribute('download', 'excel.xlsx')
+      document.body.appendChild(link)
+      link.click()
+      addViewLog(row.id, row.taskId)
     }
   }
 }
@@ -38,5 +86,9 @@ export default {
 .line{
   text-align: center;
 }
+.cell img {
+  width:48px;
+  height: 49px;
+}
 </style>
 

+ 6 - 8
src/views/dashboard/index.vue

@@ -1,20 +1,17 @@
 <template>
   <div class="dashboard-container">
-    <div class="dashboard-text">name:{{ name }}</div>
-    <div class="dashboard-text">roles:<span v-for="role in roles" :key="role">{{ role }}</span></div>
+    欢迎页
   </div>
 </template>
 
 <script>
-import { mapGetters } from 'vuex'
 
 export default {
   name: 'Dashboard',
-  computed: {
-    ...mapGetters([
-      'name',
-      'roles'
-    ])
+  data() {
+    return {
+
+    }
   }
 }
 </script>
@@ -23,6 +20,7 @@ export default {
 .dashboard {
   &-container {
     margin: 30px;
+    text-align: center;
   }
   &-text {
     font-size: 30px;

+ 46 - 29
src/views/fileDetail/index.vue

@@ -2,7 +2,7 @@
   <div class="app-container">
     <el-table
       ref="multipleTable"
-      :data="tableData3"
+      :data="fileList"
       tooltip-effect="dark"
       style="width: 100%"
       @selection-change="handleSelectionChange"
@@ -11,58 +11,71 @@
         type="selection"
         width="55"/>
       <el-table-column
-        label="已选中4个文件夹/文件">
+        :label="title">
         <template slot-scope="scope">
-          <img src="@/icons/image/file_icon.png" alt="file_icon">
+          <img :src="(scope.row.fileType == 'png' || scope.row.fileType == 'jpg') ? scope.row.path : '../../../static/fileimg/'+scope.row.fileType+'.png'" alt="file_icon">
         </template>
       </el-table-column>
       <el-table-column
-        prop="name"/>
+        prop="fileName"/>
       <el-table-column
         label="日期"
-        width="120"
+        width="160"
         show-overflow-tooltip>
-        <template slot-scope="scope">{{ scope.row.date }}</template>
+        <template slot-scope="scope">{{ scope.row.gmtCreated }}</template>
       </el-table-column>
     </el-table>
   </div>
 </template>
 
 <script>
+import { mapGetters } from 'vuex'
+import { parseTime } from '@/utils/index'
+import { addViewLog } from '@/api/table'
+// import axios from 'axios'
+
 export default {
   data() {
     return {
-      tableData3: [
-        {
-          date: '2016-05-03',
-          name: '王小虎',
-          address: '上海市普陀区金沙江路 1518 弄'
-        },
-        {
-          date: '2016-05-03',
-          name: '王小虎',
-          address: '上海市普陀区金沙江路 1518 弄'
-        }
-      ],
+      title: '',
       multipleSelection: []
     }
   },
 
+  computed: {
+    ...mapGetters([
+      'fileList'
+    ])
+  },
+
+  created() {
+    const taskId = this.$route.query.taskId
+    const title = this.$route.query.title
+    this.title = title
+    this.getFileList(taskId)
+  },
+
   methods: {
-    // toggleSelection(rows) {
-    //   if (rows) {
-    //     rows.forEach(row => {
-    //       this.$refs.multipleTable.toggleRowSelection(row)
-    //     })
-    //   } else {
-    //     this.$refs.multipleTable.clearSelection()
-    //   }
-    // },
+    getFileList(taskId) {
+      this.$store.dispatch('TaskFile', taskId).then(() => {
+        // 格式化时间和文件格式
+        this.fileList.forEach((item, index) => {
+          this.fileList[index].gmtCreated = parseTime(item.gmtCreated)
+          this.fileList[index].fileType = item.path.slice(item.path.lastIndexOf('.') + 1)
+        })
+      })
+    },
     handleSelectionChange(val) {
       this.multipleSelection = val
     },
-    detail() {
-      this.$router.push({ path: '/fileDetail/fileDetail' })
+    detail(row) {
+      const link = document.createElement('a')
+      link.style.display = 'none'
+      link.href = `https://whiteboardtest.ai160.com/download?path=${row.path}&fileName=${row.fileName}`
+      link.setAttribute('download', 'excel.xlsx')
+      document.body.appendChild(link)
+      link.click()
+      addViewLog(row.id, row.taskId)
     }
   }
 }
@@ -72,4 +85,8 @@ export default {
 .line{
   text-align: center;
 }
+.cell img {
+  width:48px;
+  height: 49px;
+}
 </style>

+ 3 - 4
src/views/layout/components/Navbar.vue

@@ -14,7 +14,7 @@
       <el-dropdown class="avatar-container" trigger="click">
         <div class="avatar-wrapper">
           <img :src="avatar+'?imageView2/1/w/80/h/80'" class="user-avatar">
-          <span class="name">孙志雷</span>
+          <span class="name">{{ name }}</span>
           <img src="@/icons/image/vip.png" class="vip">
           <i class="el-icon-arrow-down"/>
         </div>
@@ -30,7 +30,6 @@
         </el-dropdown-menu>
       </el-dropdown>
     </div>
-
   </el-menu>
 </template>
 
@@ -45,7 +44,7 @@ export default {
   },
   computed: {
     ...mapGetters([
-      'sidebar',
+      'name',
       'avatar'
     ])
   },
@@ -54,7 +53,7 @@ export default {
     //   this.$store.dispatch('ToggleSideBar')
     // },
     logout() {
-      this.$store.dispatch('LogOut').then(() => {
+      this.$store.dispatch('FedLogOut').then(() => {
         location.reload() // 为了重新实例化vue-router对象 避免bug
       })
     }

+ 45 - 77
src/views/login/index.vue

@@ -1,75 +1,30 @@
 <template>
   <div class="login-container">
-    <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left">
-      <h3 class="title">智能白板</h3>
-      <el-form-item prop="username">
-        <span class="svg-container">
-          <svg-icon icon-class="user" />
-        </span>
-        <el-input v-model="loginForm.username" name="username" type="text" auto-complete="on" placeholder="username" />
-      </el-form-item>
-      <el-form-item prop="password">
-        <span class="svg-container">
-          <svg-icon icon-class="password" />
-        </span>
-        <el-input
-          :type="pwdType"
-          v-model="loginForm.password"
-          name="password"
-          auto-complete="on"
-          placeholder="password"
-          @keyup.enter.native="handleLogin" />
-        <span class="show-pwd" @click="showPwd">
-          <svg-icon icon-class="eye" />
-        </span>
-      </el-form-item>
-      <el-form-item>
-        <el-button :loading="loading" type="primary" style="width:100%;" @click.native.prevent="handleLogin">
-          Sign in
-        </el-button>
-      </el-form-item>
-      <div class="tips">
-        <span style="margin-right:20px;">username: admin</span>
-        <span> password: admin</span>
-      </div>
-    </el-form>
+    <div class="code">
+      <span>微信扫一扫登录</span>
+      <img :src="code" class="code-img">
+    </div>
   </div>
 </template>
 
 <script>
-import { isvalidUsername } from '@/utils/validate'
+import { mapGetters } from 'vuex'
+import { setToken } from '@/utils/auth'
 
 export default {
   name: 'Login',
   data() {
-    const validateUsername = (rule, value, callback) => {
-      if (!isvalidUsername(value)) {
-        callback(new Error('请输入正确的用户名'))
-      } else {
-        callback()
-      }
-    }
-    const validatePass = (rule, value, callback) => {
-      if (value.length < 5) {
-        callback(new Error('密码不能小于5位'))
-      } else {
-        callback()
-      }
-    }
     return {
-      loginForm: {
-        username: 'admin',
-        password: 'admin'
-      },
-      loginRules: {
-        username: [{ required: true, trigger: 'blur', validator: validateUsername }],
-        password: [{ required: true, trigger: 'blur', validator: validatePass }]
-      },
       loading: false,
       pwdType: 'password',
       redirect: undefined
     }
   },
+  computed: {
+    ...mapGetters([
+      'code'
+    ])
+  },
   watch: {
     $route: {
       handler: function(route) {
@@ -78,29 +33,24 @@ export default {
       immediate: true
     }
   },
+  created() {
+    this.getLogincode()
+  },
   methods: {
-    showPwd() {
-      if (this.pwdType === 'password') {
-        this.pwdType = ''
-      } else {
-        this.pwdType = 'password'
-      }
-    },
-    handleLogin() {
-      this.$refs.loginForm.validate(valid => {
-        if (valid) {
-          this.loading = true
-          this.$store.dispatch('Login', this.loginForm).then(() => {
-            this.loading = false
-            this.$router.push({ path: this.redirect || '/' })
-          }).catch(() => {
-            this.loading = false
-          })
-        } else {
-          console.log('error submit!!')
-          return false
-        }
+    getLogincode() {
+      this.$store.dispatch('LoginCode').then(() => {
+        this.queryLogin()
       })
+    },
+    queryLogin() {
+      setTimeout(() => {
+        this.$store.dispatch('loginSuccess').then(res => { // 拉取用户信息
+          setToken(res.data.id)
+          this.$router.push({ path: this.redirect || '/' })
+        }).catch(() => {
+          this.queryLogin()
+        })
+      }, 5000)
     }
   }
 }
@@ -192,5 +142,23 @@ $light_gray:#eee;
     cursor: pointer;
     user-select: none;
   }
+  .code {
+    position: absolute;
+    right: 222px;
+    top: 50%;
+    margin-top: -171px;
+    width: 320px;
+    height: 342px;
+    background: rgba(255,255,255,1);
+    border-radius: 5px;
+    text-align: center;
+    padding-top: 20px;
+    box-sizing: border-box;
+    .code-img {
+      width:218px;
+      height: 218px;
+      margin: 20px 0;
+    }
+  }
 }
 </style>

BIN
static/fileimg/PPT.png


BIN
static/fileimg/doc.png


BIN
static/fileimg/docx.png


BIN
static/fileimg/pdf.png


BIN
static/fileimg/pptx.png


BIN
static/fileimg/xls.png


BIN
static/fileimg/xlsx.png