Browse Source

登录接口90%+资讯接口70%

master
chengxuke 4 years ago
parent
commit
7ba57db568

+ 3
- 1
package.json View File

@@ -11,6 +11,7 @@
11 11
     "test:e2e": "vue-cli-service test:e2e"
12 12
   },
13 13
   "dependencies": {
14
+    "ali-oss": "^6.8.0",
14 15
     "axios": "^0.18.0",
15 16
     "clipboard": "^2.0.0",
16 17
     "codemirror": "^5.38.0",
@@ -27,8 +28,9 @@
27 28
     "tree-table-vue": "^1.1.0",
28 29
     "v-org-tree": "^1.0.6",
29 30
     "vue": "^2.5.10",
31
+    "vue-cropper": "^0.5.2",
30 32
     "vue-i18n": "^7.8.0",
31
-    "vue-router": "^3.0.1",
33
+    "vue-router": "^3.0.7",
32 34
     "vuedraggable": "^2.16.0",
33 35
     "vuex": "^3.0.1",
34 36
     "wangeditor": "^3.1.1",

+ 12
- 0
src/api/info.js View File

@@ -0,0 +1,12 @@
1
+import axios from '@/libs/api.request'
2
+export const addInfo = (data) => {
3
+  // const data = {
4
+  //   loginname,
5
+  //   loginpwd
6
+  // }
7
+  return axios.request({
8
+    url: 'https://aicpapitest.xhkjedu.com/newstype/add',
9
+    method: 'POST',
10
+    data
11
+  })
12
+}

+ 68
- 65
src/api/user.js View File

@@ -1,27 +1,30 @@
1 1
 import axios from '@/libs/api.request'
2 2
 
3
-export const login = ({ userName, password }) => {
4
-  const data = {
5
-    userName,
6
-    password
7
-  }
3
+export const login = ({ loginname, loginpwd }) => {
4
+  // const data = {
5
+  //   loginname,
6
+  //   loginpwd
7
+  // }
8 8
   return axios.request({
9
-    url: 'login',
10
-    data,
11
-    method: 'post'
12
-  })
13
-}
14
-
15
-export const getUserInfo = (token) => {
16
-  return axios.request({
17
-    url: 'get_info',
9
+    url: 'https://aicpapitest.xhkjedu.com/user/login',
10
+    method: 'POST',
18 11
     params: {
19
-      token
20
-    },
21
-    method: 'get'
12
+      loginname,
13
+      loginpwd
14
+    }
22 15
   })
23 16
 }
24 17
 
18
+// export const getUserInfo = (token) => {
19
+//   return axios.request({
20
+//     url: 'get_info',
21
+//     params: {
22
+//       token
23
+//     },
24
+//     method: 'get'
25
+//   })
26
+// }
27
+
25 28
 export const logout = (token) => {
26 29
   return axios.request({
27 30
     url: 'logout',
@@ -29,56 +32,56 @@ export const logout = (token) => {
29 32
   })
30 33
 }
31 34
 
32
-export const getUnreadCount = () => {
33
-  return axios.request({
34
-    url: 'message/count',
35
-    method: 'get'
36
-  })
37
-}
35
+// export const getUnreadCount = () => {
36
+//   return axios.request({
37
+//     url: 'message/count',
38
+//     method: 'get'
39
+//   })
40
+// }
38 41
 
39
-export const getMessage = () => {
40
-  return axios.request({
41
-    url: 'message/init',
42
-    method: 'get'
43
-  })
44
-}
42
+// export const getMessage = () => {
43
+//   return axios.request({
44
+//     url: 'message/init',
45
+//     method: 'get'
46
+//   })
47
+// }
45 48
 
46
-export const getContentByMsgId = msg_id => {
47
-  return axios.request({
48
-    url: 'message/content',
49
-    method: 'get',
50
-    params: {
51
-      msg_id
52
-    }
53
-  })
54
-}
49
+// export const getContentByMsgId = msg_id => {
50
+//   return axios.request({
51
+//     url: 'message/content',
52
+//     method: 'get',
53
+//     params: {
54
+//       msg_id
55
+//     }
56
+//   })
57
+// }
55 58
 
56
-export const hasRead = msg_id => {
57
-  return axios.request({
58
-    url: 'message/has_read',
59
-    method: 'post',
60
-    data: {
61
-      msg_id
62
-    }
63
-  })
64
-}
59
+// export const hasRead = msg_id => {
60
+//   return axios.request({
61
+//     url: 'message/has_read',
62
+//     method: 'post',
63
+//     data: {
64
+//       msg_id
65
+//     }
66
+//   })
67
+// }
65 68
 
66
-export const removeReaded = msg_id => {
67
-  return axios.request({
68
-    url: 'message/remove_readed',
69
-    method: 'post',
70
-    data: {
71
-      msg_id
72
-    }
73
-  })
74
-}
69
+// export const removeReaded = msg_id => {
70
+//   return axios.request({
71
+//     url: 'message/remove_readed',
72
+//     method: 'post',
73
+//     data: {
74
+//       msg_id
75
+//     }
76
+//   })
77
+// }
75 78
 
76
-export const restoreTrash = msg_id => {
77
-  return axios.request({
78
-    url: 'message/restore',
79
-    method: 'post',
80
-    data: {
81
-      msg_id
82
-    }
83
-  })
84
-}
79
+// export const restoreTrash = msg_id => {
80
+//   return axios.request({
81
+//     url: 'message/restore',
82
+//     method: 'post',
83
+//     data: {
84
+//       msg_id
85
+//     }
86
+//   })
87
+// }

+ 21
- 0
src/assets/iconfont/iconfont.css View File

@@ -0,0 +1,21 @@
1
+@font-face {font-family: "iconfont";
2
+  src: url('iconfont.eot?t=1590049832161'); /* IE9 */
3
+  src: url('iconfont.eot?t=1590049832161#iefix') format('embedded-opentype'), /* IE6-IE8 */
4
+  url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAKYAAsAAAAABkgAAAJLAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCCcApYaQE2AiQDCAsGAAQgBYRtBywbiwXILrBt2JMANbENY7CSLm0QeAPx8LTft3NnZk0lLnhWb3gn8oliFbJYCZRu1TP53f9amz2V0OakicVL4kDSvjJ/xWcHe52UeSRSgRAhNHRy9n+7XLBlHAi0RVKC9LIXQLUB19RPoAepHdDcOikqORJwYNOBduDoyTaSkW8Yu+AFPifQbNyYdvR4cw8Vhb0uEPdcW4dKIaYorNgo1DccLeKlOo3pUfrGi+j78c92NJLUZXbbiRsHC9Y/OWW5VtVcCQhxAjpdh4xVoBBnGnPH5AXj8ppzBdPgWM3BT1UVeMVRXYL9dXZjKxiF6mfSeNpHbUygJLODwMgkeUitrZe7H/fw03zebO3jTbz6+OTzCF9/evzhwUDn/vClE0TUp6BmDf4OrAGq+XMe0RD86Pt6e++/XMDXr1YUqRbDAqBxR/7gh2gGjhRDZ3tS0TSNgWRw0tqEZs2o4FC3v6n2vrOXQqO+ewg0GMuQNZolC7uKOi12Ua/RATRbcTrdogfLi9KEZe8AodMXknZfkHX6IQv7izr9/lGvMzKanYueK1vMx+3aESZdyELjDV0zjpTrk1rcfEv2U6BzXhfxj8SZm8TF+ma5eKKIeIkd2bO9FFGoOA7xCF6jIIgx4dgjU6aOSLKabdxokmlqxiHUHMGIThALMrxBLlMsooLpolb5/C1iexLQcUdHXfkRYRl3frQwNR9AnszRoI5HeSfzzLYkhIIUFguhI1hEAoEYSpoXeYhJTDkTMomVmTNJDTVPt7eGP1DFerAdKZzqLG1vAQAAAA==') format('woff2'),
5
+  url('iconfont.woff?t=1590049832161') format('woff'),
6
+  url('iconfont.ttf?t=1590049832161') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */
7
+  url('iconfont.svg?t=1590049832161#iconfont') format('svg'); /* iOS 4.1- */
8
+}
9
+
10
+.iconfont {
11
+  font-family: "iconfont" !important;
12
+  font-size: 16px;
13
+  font-style: normal;
14
+  -webkit-font-smoothing: antialiased;
15
+  -moz-osx-font-smoothing: grayscale;
16
+}
17
+
18
+.icon-21:before {
19
+  content: "\e620";
20
+}
21
+

BIN
src/assets/iconfont/iconfont.eot View File


+ 29
- 0
src/assets/iconfont/iconfont.svg View File

@@ -0,0 +1,29 @@
1
+<?xml version="1.0" standalone="no"?>
2
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
+<!--
4
+2013-9-30: Created.
5
+-->
6
+<svg>
7
+<metadata>
8
+Created by iconfont
9
+</metadata>
10
+<defs>
11
+
12
+<font id="iconfont" horiz-adv-x="1024" >
13
+  <font-face
14
+    font-family="iconfont"
15
+    font-weight="500"
16
+    font-stretch="normal"
17
+    units-per-em="1024"
18
+    ascent="896"
19
+    descent="-128"
20
+  />
21
+    <missing-glyph />
22
+    
23
+    <glyph glyph-name="21" unicode="&#58912;" d="M128 341.33333300000004h768a42.666667 42.666667 0 0 1 0 85.333334H128a42.666667 42.666667 0 0 1 0-85.333334zM469.333333 768v-768a42.666667 42.666667 0 0 1 85.333334 0V768a42.666667 42.666667 0 0 1-85.333334 0z"  horiz-adv-x="1024" />
24
+
25
+    
26
+
27
+
28
+  </font>
29
+</defs></svg>

BIN
src/assets/iconfont/iconfont.ttf View File


BIN
src/assets/iconfont/iconfont.woff View File


+ 11
- 6
src/components/cropper/index.less View File

@@ -1,12 +1,13 @@
1 1
 .bg{
2
-  background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC")
2
+  // background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC")
3 3
 }
4 4
 .cropper-wrapper{
5
-  width: 600px;
6
-  height: 340px;
5
+  width: 200px;
6
+  height: 200px;
7 7
   .img-box{
8
-    height: 340px;
9
-    width: 430px;
8
+    height: 200px;
9
+    width: 200px;
10
+    background: white;
10 11
     border: 1px solid #ebebeb;
11 12
     display: inline-block;
12 13
     .bg;
@@ -25,11 +26,15 @@
25 26
       height: 150px !important;
26 27
       width: 100% !important;
27 28
       overflow: hidden;
28
-      border: 1px solid #ebebeb;
29
+      // border: 1px solid #ebebeb;
29 30
       .bg;
30 31
     }
31 32
     .button-box{
32 33
       padding: 10px 0 0;
34
+      .ivu-btn-default {
35
+        margin-top: -12px;
36
+        margin-left: -12px;
37
+      }
33 38
     }
34 39
   }
35 40
 }

+ 8
- 5
src/components/cropper/index.vue View File

@@ -4,14 +4,14 @@
4 4
       <img class="cropper-image" :id="imgId" alt="">
5 5
     </div>
6 6
     <div class="right-con">
7
-      <div v-if="preview" class="preview-box" :id="previewId"></div>
7
+      <!-- <div v-if="preview" class="preview-box" :id="previewId"></div> -->
8 8
       <div class="button-box">
9 9
         <slot>
10 10
           <Upload action="image/upload" :before-upload="beforeUpload">
11
-            <Button style="width: 150px;" type="primary">上传图片</Button>
11
+            <Button icon="ivu-icon ivu-icon- iconfont icon-21"  style="width: 220px;height:220px" ></Button>
12 12
           </Upload>
13 13
         </slot>
14
-        <div v-show="insideSrc">
14
+        <!-- <div v-show="insideSrc">
15 15
           <Button type="primary" @click="rotate">
16 16
             <Icon type="md-refresh" :size="18"/>
17 17
           </Button>
@@ -40,7 +40,7 @@
40 40
             <Icon type="md-arrow-round-forward" :size="18"/>
41 41
           </Button>
42 42
           <Button style="width: 150px;margin-top: 10px;" type="primary" @click="crop">{{ cropButtonText }}</Button>
43
-        </div>
43
+        </div> -->
44 44
       </div>
45 45
     </div>
46 46
   </div>
@@ -73,7 +73,8 @@ export default {
73 73
   data () {
74 74
     return {
75 75
       cropper: null,
76
-      insideSrc: ''
76
+      insideSrc: '',
77
+      file: ''
77 78
     }
78 79
   },
79 80
   computed: {
@@ -96,6 +97,8 @@ export default {
96 97
     beforeUpload (file) {
97 98
       const reader = new FileReader()
98 99
       reader.readAsDataURL(file)
100
+      console.log(file)
101
+      this.file = file
99 102
       reader.onload = (event) => {
100 103
         this.insideSrc = event.srcElement.result
101 104
       }

+ 29
- 22
src/components/login-form/login-form.vue View File

@@ -1,22 +1,22 @@
1 1
 <template>
2 2
 <div>
3 3
   <div class="formLine">
4
-    <form ref="loginForm" :model="loginForm" :rules="rules">
5
-      <div class='formElement'>
4
+    <Form ref="loginForm" :model="form" :rules="rules">
5
+      <Form-item  class='formElement' prop='loginname'>
6 6
         <!-- <img width="15px" src="../../assets/img/User.png" alt="" /> -->
7
-        <input style="padding-left:50px;" id="userName" type="text" v-model="loginForm.userName" placeholder="用户名" autocomplete="off">
8
-      </div>
9
-      <div class="formElement">
7
+        <input style="padding-left:50px;" id="userName" type="text" v-model="form.loginname" placeholder="用户名" autocomplete="off" />
8
+      </Form-item>
9
+      <Form-item  class="formElement"  prop='loginpwd'>
10 10
         <!-- <img src="../../assets/img/Key.png" alt="" /> -->
11
-        <input  style="padding-left:50px"  id="password" type="password" v-model="loginForm.password" placeholder="密码" autocomplete="off">
12
-      </div>
11
+        <input  style="padding-left:50px"  id="password" type="password" v-model="form.loginpwd" placeholder="密码" autocomplete="off">
12
+      </Form-item>
13 13
       <div class="formOther">
14 14
         <Checkbox v-model="single">记住密码</Checkbox>
15 15
       </div>
16 16
       <div class="formOther">
17 17
        <Button @click="handleSubmit" type="primary" long>登录</Button>
18 18
       </div>
19
-    </form>
19
+    </Form>
20 20
   </div>
21 21
    <div class="bottom">
22 22
             <a>注册</a>
@@ -28,7 +28,7 @@
28 28
 export default {
29 29
   name: 'LoginForm',
30 30
   props: {
31
-    userNameRules: {
31
+    loginnameRules: {
32 32
       type: Array,
33 33
       default: () => {
34 34
         return [
@@ -36,7 +36,7 @@ export default {
36 36
         ]
37 37
       }
38 38
     },
39
-    passwordRules: {
39
+    loginpwdRules: {
40 40
       type: Array,
41 41
       default: () => {
42 42
         return [
@@ -48,9 +48,9 @@ export default {
48 48
   data () {
49 49
     return {
50 50
       single: false,
51
-      loginForm: {
52
-        userName: 'super_admin',
53
-        password: '0000'
51
+      form: {
52
+        loginname: '13140197098',
53
+        loginpwd: '123456'
54 54
       }
55 55
     }
56 56
   },
@@ -64,32 +64,38 @@ export default {
64 64
   },
65 65
   methods: {
66 66
     handleSubmit () {
67
-      console.log(this.$refs.loginForm)
67
+      // console.log(this.$refs.loginForm)
68 68
       // this.$router.push('home')
69
-      // this.$refs.loginForm.validate((valid) => {
70
-      //   if (valid) {
71
-      this.$emit('on-success-valid', {
72
-        userName: this.loginForm.userName,
73
-        password: this.loginForm.password
69
+      this.$refs.loginForm.validate((valid) => {
70
+        // console.log(valid)
71
+        if (valid) {
72
+          this.$emit('on-success-valid', {
73
+            loginname: this.form.loginname,
74
+            loginpwd: this.form.loginpwd
75
+          })
76
+        }
74 77
       })
75
-      //   }
76
-      // })
77 78
     }
78 79
   }
79 80
 }
80 81
 </script>
81 82
 <style lang='less' scoped>
83
+// #userName>.ivu-form-item-content{
84
+//   width: 290px!important;
85
+// }
82 86
 #userName{
83 87
   background: url(../../assets/img/User.png) no-repeat left center;
84 88
   background-size: 20px 20px;
85 89
   background-position: 15px;
86 90
   height: 40px;
91
+  width: 295px;
87 92
 
88 93
 }
89 94
 #password{
90 95
   background: url(../../assets/img/Key.png) no-repeat left center;
91 96
   background-size: 20px 20px;
92 97
   background-position: 15px;
98
+  width: 295px;
93 99
 
94 100
 }
95 101
 .formLine{
@@ -100,7 +106,8 @@ export default {
100 106
     height: 40px;
101 107
     display: flex;
102 108
     align-items: center;
103
-    margin-bottom: 15px;
109
+    margin-bottom: 22px;
110
+
104 111
     input{
105 112
       border:none;
106 113
       width: 100%;

+ 1
- 1
src/components/main/components/navbar/index.vue View File

@@ -41,7 +41,7 @@ export default {
41 41
   props: {
42 42
     userAvatar: {
43 43
       type: String,
44
-      default: ''
44
+      default: 'https://file.iviewui.com/dist/a0e88e83800f138b94d2414621bd9704.png'
45 45
     }
46 46
   },
47 47
   methods: {

+ 7
- 2
src/components/main/components/side-menu/side-menu.less View File

@@ -5,6 +5,11 @@
5 5
   .ivu-menu-item,.ivu-menu-submenu{
6 6
     color: #3D8EFE;
7 7
   }
8
+  .ivu-menu-vertical .ivu-menu-submenu-title-icon{
9
+    position: absolute;
10
+    top: 50%;
11
+    right: -4px;
12
+  }
8 13
   .ivu-menu-submenu>.ivu-menu>.ivu-menu-item{
9 14
     color: grey;
10 15
   }
@@ -71,10 +76,10 @@
71 76
         width: 100%;
72 77
       }
73 78
       .ivu-tooltip-popper .ivu-tooltip-content{
74
-        .ivu-tooltip-arrow{
79
+        // .ivu-tooltip-arrow{
75 80
           // border-right-color: #fff;
76 81
           // border-right-color:blue;
77
-        }
82
+        // }
78 83
         .ivu-tooltip-inner{
79 84
           background: #fff;
80 85
           color: #495060;

+ 1
- 1
src/components/main/main.vue View File

@@ -186,7 +186,7 @@ export default {
186 186
       })
187 187
     }
188 188
     // 获取未读消息条数
189
-    this.getUnreadMessageCount()
189
+    // this.getUnreadMessageCount()
190 190
   }
191 191
 }
192 192
 </script>

+ 104
- 0
src/components/picture/index.vue View File

@@ -0,0 +1,104 @@
1
+<template>
2
+  <div>
3
+    <div class="demo-upload-list" v-for="(item,index) in uploadList" :key='index'>
4
+      ![](item.url)
5
+      <div class="demo-upload-list-cover">
6
+        <Icon type="ios-trash-outline" @click.native="handleRemove(item)"></Icon>
7
+      </div>
8
+    </div>
9
+    <Upload ref="upload" :show-upload-list="false" :format="['jpg','jpeg','png']" :max-size="2048" :before-upload="handleBeforeUpload" :on-format-error="handleFormatError" :on-exceeded-size="handleMaxSize" type="drag" action="//jsonplaceholder.typicode.com/posts/" style="display: inline-block;width:58px;">
10
+      <div style="width: 58px;height:58px;line-height: 58px;">
11
+        <Icon type="camera" size="20"></Icon>
12
+      </div>
13
+    </Upload>
14
+  </div>
15
+</template>
16
+<script>
17
+export default {
18
+  methods: {
19
+    data () {
20
+      return {
21
+        uploadList: []
22
+      }
23
+    },
24
+    handleBeforeUpload (file) {
25
+    // 创建一个 FileReader 对象
26
+      let reader = new FileReader()
27
+      // readAsDataURL 方法用于读取指定 Blob 或 File 的内容
28
+      // 当读操作完成,readyState 变为 DONE,loadend 被触发,此时 result 属性包含数据:URL(以 base64 编码的字符串表示文件的数据)
29
+      // 读取文件作为 URL 可访问地址
30
+      reader.readAsDataURL(file)
31
+
32
+      const _this = this
33
+      reader.onloadend = function (e) {
34
+        file.url = reader.result
35
+        console.log(file.url)
36
+        this.$emit('imgSrc', file.url)
37
+
38
+        _this.uploadList.push(file)
39
+      }
40
+    },
41
+    handleRemove (file) {
42
+      this.uploadList.splice(this.uploadList.indexOf(file), 1)
43
+    },
44
+    handleFormatError (file) {
45
+      this.$Notice.warning({
46
+        title: '文件格式不正确',
47
+        desc: '文件 ' + file.name + ' 格式不正确,请上传 jpg 或 png 格式的图片。'
48
+      })
49
+    },
50
+    handleMaxSize (file) {
51
+      this.$Notice.warning({
52
+        title: '超出文件大小限制',
53
+        desc: '文件 ' + file.name + ' 太大,不能超过 2M。'
54
+      })
55
+    }
56
+  }
57
+}
58
+</script>
59
+<style scoped>
60
+.demo-upload-list {
61
+  display: inline-block;
62
+  width: 60px;
63
+  height: 60px;
64
+  text-align: center;
65
+  line-height: 60px;
66
+  border: 1px solid transparent;
67
+  border-radius: 4px;
68
+  overflow: hidden;
69
+  background: #fff;
70
+  position: relative;
71
+  box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
72
+  margin-right: 4px;
73
+}
74
+
75
+.demo-upload-list img {
76
+  width: 100%;
77
+  height: 100%;
78
+}
79
+
80
+.demo-upload-list-cover {
81
+  display: none;
82
+  position: absolute;
83
+  top: 0;
84
+  bottom: 0;
85
+  left: 0;
86
+  right: 0;
87
+  background: rgba(0, 0, 0, .6);
88
+}
89
+
90
+.demo-upload-list:hover .demo-upload-list-cover {
91
+  display: block;
92
+}
93
+
94
+.demo-upload-list-cover i {
95
+  color: #fff;
96
+  font-size: 20px;
97
+  cursor: pointer;
98
+  margin: 0 2px;
99
+}
100
+
101
+.ivu-icon {
102
+  line-height: 58px;
103
+}
104
+</style>

+ 2
- 2
src/config/index.js View File

@@ -17,8 +17,8 @@ export default {
17 17
    * @description api请求基础路径
18 18
    */
19 19
   baseUrl: {
20
-    dev: 'https://www.easy-mock.com/mock/5add9213ce4d0e69998a6f51/iview-admin/',
21
-    pro: 'https://produce.com'
20
+    dev: 'https://aicpapitest.xhkjedu.com',
21
+    pro: 'https://api2.xhkjedu.com/mock/7'
22 22
   },
23 23
   /**
24 24
    * @description 默认打开的首页的路由name值,默认为home

+ 1
- 0
src/libs/api.request.js View File

@@ -3,4 +3,5 @@ import config from '@/config'
3 3
 const baseUrl = process.env.NODE_ENV === 'development' ? config.baseUrl.dev : config.baseUrl.pro
4 4
 
5 5
 const axios = new HttpRequest(baseUrl)
6
+
6 7
 export default axios

+ 8
- 3
src/libs/axios.js View File

@@ -19,11 +19,16 @@ class HttpRequest {
19 19
   }
20 20
   getInsideConfig () {
21 21
     const config = {
22
-      baseURL: this.baseUrl,
23
-      headers: {
24
-        //
22
+      // baseURL: this.baseUrl,
23
+      'Header': {
24
+        'Content-Type': 'application/x-www-form-urlencoded'
25 25
       }
26
+      // 'cookie': [],
27
+      // 'token': '',
28
+      // 'device': 'web',
29
+      // 'uid': '1'
26 30
     }
31
+    // console.log(config)
27 32
     return config
28 33
   }
29 34
   destroy (url) {

+ 115
- 0
src/libs/store.js View File

@@ -0,0 +1,115 @@
1
+// import { validatenull } from '@/utils/validate'
2
+// import website from '@/config/website'
3
+
4
+// const keyName = website.key + '-'
5
+/**
6
+ * 存储localStorage
7
+ */
8
+export const setStore = (params = {}) => {
9
+  let {
10
+    name,
11
+    content,
12
+    type
13
+  } = params
14
+  let obj = {
15
+    dataType: typeof (content),
16
+    content: content,
17
+    type: type,
18
+    datetime: new Date().getTime()
19
+  }
20
+  if (type) window.sessionStorage.setItem(name, JSON.stringify(obj))
21
+  else window.localStorage.setItem(name, JSON.stringify(obj))
22
+}
23
+
24
+/**
25
+ * 获取localStorage
26
+ */
27
+// export const getStore = (params = {}) => {
28
+//   let {
29
+//     name,
30
+//     debug
31
+//   } = params
32
+//   name = keyName + name
33
+//   let obj = {}
34
+//   let content
35
+//   obj = window.sessionStorage.getItem(name)
36
+//   if (validatenull(obj)) obj = window.localStorage.getItem(name)
37
+//   if (validatenull(obj)) return
38
+//   try {
39
+//     obj = JSON.parse(obj)
40
+//   } catch {
41
+//     return obj
42
+//   }
43
+//   if (debug) {
44
+//     return obj
45
+//   }
46
+//   if (obj.dataType === 'string') {
47
+//     content = obj.content
48
+//   } else if (obj.dataType === 'number') {
49
+//     content = Number(obj.content)
50
+//   } else if (obj.dataType === 'boolean') {
51
+//     content = this.eval(obj.content)
52
+//   } else if (obj.dataType === 'object') {
53
+//     content = obj.content
54
+//   }
55
+//   return content
56
+// }
57
+
58
+/**
59
+ * 删除localStorage
60
+ */
61
+export const removeStore = (params = {}) => {
62
+  let {
63
+    name,
64
+    type
65
+  } = params
66
+  // name = keyName + name
67
+  if (type) {
68
+    window.sessionStorage.removeItem(name)
69
+  } else {
70
+    window.localStorage.removeItem(name)
71
+  }
72
+}
73
+
74
+/**
75
+ * 获取全部localStorage
76
+ */
77
+export const getAllStore = (params = {}) => {
78
+  let list = []
79
+  let {
80
+    type
81
+  } = params
82
+  if (type) {
83
+    for (let i = 0; i <= window.sessionStorage.length; i++) {
84
+      list.push({
85
+        name: window.sessionStorage.key(i),
86
+        content: getStore({
87
+          name: window.sessionStorage.key(i),
88
+          type: 'session'
89
+        })
90
+      })
91
+    }
92
+  } else {
93
+    for (let i = 0; i <= window.localStorage.length; i++) {
94
+      list.push({
95
+        name: window.localStorage.key(i),
96
+        content: getStore({
97
+          name: window.localStorage.key(i)
98
+        })
99
+      })
100
+    }
101
+  }
102
+  return list
103
+}
104
+
105
+/**
106
+ * 清空全部localStorage
107
+ */
108
+export const clearStore = (params = {}) => {
109
+  let { type } = params
110
+  if (type) {
111
+    window.sessionStorage.clear()
112
+  } else {
113
+    window.localStorage.clear()
114
+  }
115
+}

+ 2
- 0
src/libs/util.js View File

@@ -144,11 +144,13 @@ export const getHomeRoute = (routers, homeName = 'home') => {
144 144
  * @description 如果该newRoute已经存在则不再添加
145 145
  */
146 146
 export const getNewTagList = (list, newRoute) => {
147
+  // ---------------------------------------------
147 148
   const { name, path, meta } = newRoute
148 149
   let newList = [...list]
149 150
   if (newList.findIndex(item => item.name === name) >= 0) return newList
150 151
   else newList.push({ name, path, meta })
151 152
   return newList
153
+  // ------------------------------
152 154
 }
153 155
 
154 156
 /**

+ 2
- 1
src/locale/lang/en-US.js View File

@@ -43,5 +43,6 @@ export default {
43 43
   tree_table_page: 'Tree Table',
44 44
   org_tree_page: 'Org Tree',
45 45
   drag_drawer_page: 'Draggable Drawer',
46
-  tree_select_page: 'Tree Selector'
46
+  tree_select_page: 'Tree Selector',
47
+  Information: 'Information'
47 48
 }

+ 2
- 1
src/locale/lang/zh-CN.js View File

@@ -43,5 +43,6 @@ export default {
43 43
   tree_table_page: '树状表格',
44 44
   org_tree_page: '组织结构树',
45 45
   drag_drawer_page: '可拖动抽屉',
46
-  tree_select_page: '树状下拉选择器'
46
+  tree_select_page: '树状下拉选择器',
47
+  Information: '资讯'
47 48
 }

+ 15
- 2
src/main.js View File

@@ -12,15 +12,28 @@ import { directive as clickOutside } from 'v-click-outside-x'
12 12
 import installPlugin from '@/plugin'
13 13
 import './index.less'
14 14
 import '@/assets/icons/iconfont.css'
15
+import '@/assets/iconfont/iconfont.css'
16
+// import Vue from 'vue'
17
+import VueCropper from 'vue-cropper'
18
+
15 19
 import TreeTable from 'tree-table-vue'
16 20
 import VOrgTree from 'v-org-tree'
17 21
 import 'v-org-tree/dist/v-org-tree.css'
18 22
 import echarts from 'echarts'
19
-Vue.prototype.$echarts = echarts
23
+Vue.use(VueCropper)
20 24
 
25
+// 路由问题/
26
+// import Router from 'vue-router'
27
+Vue.prototype.$echarts = echarts
28
+// const routerPush = Router.prototype.push
29
+// Router.prototype.push = function push (location) {
30
+//   return routerPush.call(this, location).catch(error => error)
31
+// }
21 32
 // 实际打包时应该不引入mock
22 33
 /* eslint-disable */
23
-if (process.env.NODE_ENV !== 'production') require('@/mock')
34
+// -----------------------------------------------------------------------
35
+// if (process.env.NODE_ENV !== 'production') require('@/mock')
36
+// ------------------------------------------------------------------------
24 37
 
25 38
 Vue.use(iView, {
26 39
   i18n: (key, value) => i18n.t(key, value)

+ 1
- 1
src/mock/index.js View File

@@ -5,7 +5,7 @@ import { getMessageInit, getContentByMsgId, hasRead, removeReaded, restoreTrash,
5 5
 
6 6
 // 配置Ajax请求延时,可用来测试网络延迟大时项目中一些效果
7 7
 Mock.setup({
8
-  timeout: 1000
8
+  timeout: 0
9 9
 })
10 10
 
11 11
 // 登录相关和获取用户信息

+ 9
- 4
src/router/index.js View File

@@ -7,7 +7,12 @@ import { setToken, getToken, canTurnTo, setTitle } from '@/libs/util'
7 7
 import config from '@/config'
8 8
 const { homeName } = config
9 9
 
10
+// const routerPush = Router.prototype.push
11
+// Router.prototype.push = function push (location) {
12
+//   return routerPush.call(this, location).catch(error => console.log(error))
13
+// }
10 14
 Vue.use(Router)
15
+
11 16
 const router = new Router({
12 17
   routes,
13 18
   mode: 'history'
@@ -39,15 +44,15 @@ router.beforeEach((to, from, next) => {
39 44
     if (store.state.user.hasGetInfo) {
40 45
       turnTo(to, store.state.user.access, next)
41 46
     } else {
42
-      store.dispatch('getUserInfo').then(user => {
43
-        // 拉取用户信息,通过用户权限和跳转的页面的name来判断是否有权限访问;access必须是一个数组,如:['super_admin'] ['super_admin', 'admin']
47
+      // store.dispatch('getUserInfo').then(user => {
48
+      if (store.state.userInfo) {
44 49
         turnTo(to, user.access, next)
45
-      }).catch(() => {
50
+      } else {
46 51
         setToken('')
47 52
         next({
48 53
           name: 'login'
49 54
         })
50
-      })
55
+      }
51 56
     }
52 57
   }
53 58
 })

+ 230
- 194
src/router/routers.js View File

@@ -1,6 +1,19 @@
1 1
 import Main from '@/components/main'
2
-// import parentView from '@/components/parent-view'
3 2
 
3
+// import Vue from 'vue'
4
+// import VueRouter from 'vue-router'
5
+// Vue.use(VueRouter)
6
+// import parentView from '@/components/parent-view'
7
+// const routerMethods = ['push', 'replace']
8
+// routerMethods.forEach(method => {
9
+//   const originalCall = VueRouter.prototype[method]
10
+//   VueRouter.prototype[method] = function (location, onResolve, onReject) {
11
+//     if (onResolve || onReject) {
12
+//       return originalCall.call(this, location, onResolve, onReject)
13
+//     }
14
+//     return originalCall.call(this, location).catch(err => err)
15
+//   }
16
+// })
4 17
 /**
5 18
  * iview-admin中meta除了原生参数外可配置的参数:
6 19
  * meta: {
@@ -16,6 +29,10 @@ import Main from '@/components/main'
16 29
  *  beforeCloseName: (-) 设置该字段,则在关闭当前tab页时会去'@/router/before-close.js'里寻找该字段名对应的方法,作为关闭前的钩子函数
17 30
  * }
18 31
  */
32
+// const routerPush = VueRouter.prototype.push
33
+// VueRouter.prototype.push = function push (location) {
34
+//   return routerPush.call(this, location).catch(error => error)
35
+// }
19 36
 
20 37
 export default [
21 38
   {
@@ -30,7 +47,7 @@ export default [
30 47
   {
31 48
     path: '/',
32 49
     name: '_home',
33
-    redirect: '/home',
50
+    redirect: 'home',
34 51
     component: Main,
35 52
     meta: {
36 53
       // hideInMenu: true,
@@ -86,8 +103,27 @@ export default [
86 103
           icon: 'md-trending-up',
87 104
           title: '学员管理'
88 105
         },
89
-        component: () => import('@/view/manager/student.vue')
106
+        component: () => import('@/view/manager/student/student.vue')
90 107
       },
108
+      {
109
+        path: 'Information',
110
+        name: 'Information',
111
+        meta: {
112
+          icon: 'ios-create',
113
+          title: '资讯'
114
+        },
115
+        // component: () => import('@/view/components/editor/editor.vue')
116
+        component: () => import('@/view/manager/Information/index.vue')
117
+      }
118
+      // {
119
+      //   path: 'editor_page',
120
+      //   name: 'editor_page',
121
+      //   meta: {
122
+      //     icon: 'ios-create',
123
+      //     title: '富文本编辑器'
124
+      //   },
125
+      //   component: () => import('@/view/components/editor/editor.vue')
126
+      // }
91 127
       // {
92 128
       //   path: 'tree_select_page',
93 129
       //   name: 'tree_select_page',
@@ -97,15 +133,15 @@ export default [
97 133
       //   },
98 134
       //   component: () => import('@/view/components/tree-select/index.vue')
99 135
       // },
100
-      {
101
-        path: 'count_to_page',
102
-        name: 'count_to_page',
103
-        meta: {
104
-          icon: 'md-trending-up',
105
-          title: '招生管理'
106
-        },
107
-        component: () => import('@/view/components/count-to/count-to.vue')
108
-      }
136
+      // {
137
+      //   path: 'count_to_page',
138
+      //   name: 'count_to_page',
139
+      //   meta: {
140
+      //     icon: 'md-trending-up',
141
+      //     title: '招生管理'
142
+      //   },
143
+      //   component: () => import('@/view/components/count-to/count-to.vue')
144
+      // }
109 145
       // {
110 146
       //   path: 'drag_list_page',
111 147
       //   name: 'drag_list_page',
@@ -197,7 +233,7 @@ export default [
197 233
       //   component: () => import('@/view/components/icons/icons.vue')
198 234
       // }
199 235
     ]
200
-  },
236
+  }
201 237
   // {
202 238
   //   path: '/update',
203 239
   //   name: 'update',
@@ -227,132 +263,132 @@ export default [
227 263
   //     }
228 264
   //   ]
229 265
   // },
230
-  {
231
-    path: '/excel',
232
-    name: 'excel',
233
-    meta: {
234
-      icon: 'ios-stats',
235
-      title: '统计信息'
236
-    },
237
-    component: Main,
238
-    children: [
239
-      {
240
-        path: 'upload-excel',
241
-        name: 'upload-excel',
242
-        meta: {
243
-          icon: 'md-add',
244
-          title: '月报'
245
-        },
246
-        component: () => import('@/view/excel/upload-excel.vue')
247
-      },
248
-      {
249
-        path: 'export-excel',
250
-        name: 'export-excel',
251
-        meta: {
252
-          icon: 'md-download',
253
-          title: '日报'
254
-        },
255
-        component: () => import('@/view/excel/export-excel.vue')
256
-      }
257
-    ]
258
-  },
259
-  {
260
-    path: '/tools_methods',
261
-    name: 'tools_methods',
262
-    meta: {
263
-      hideInBread: true
264
-    },
265
-    component: Main,
266
-    children: [
267
-      {
268
-        path: 'tools_methods_page',
269
-        name: 'tools_methods_page',
270
-        meta: {
271
-          icon: 'ios-hammer',
272
-          title: '工具方法',
273
-          beforeCloseName: 'before_close_normal'
274
-        },
275
-        component: () => import('@/view/tools-methods/tools-methods.vue')
276
-      }
277
-    ]
278
-  },
279
-  {
280
-    path: '/i18n',
281
-    name: 'i18n',
282
-    meta: {
283
-      hideInBread: true
284
-    },
285
-    component: Main,
286
-    children: [
287
-      {
288
-        path: 'i18n_page',
289
-        name: 'i18n_page',
290
-        meta: {
291
-          icon: 'md-planet',
292
-          title: 'i18n - {{ i18n_page }}'
293
-        },
294
-        component: () => import('@/view/i18n/i18n-page.vue')
295
-      }
296
-    ]
297
-  },
298
-  {
299
-    path: '/error_store',
300
-    name: 'error_store',
301
-    meta: {
302
-      hideInBread: true
303
-    },
304
-    component: Main,
305
-    children: [
306
-      {
307
-        path: 'error_store_page',
308
-        name: 'error_store_page',
309
-        meta: {
310
-          icon: 'ios-bug',
311
-          title: '错误收集'
312
-        },
313
-        component: () => import('@/view/error-store/error-store.vue')
314
-      }
315
-    ]
316
-  },
317
-  {
318
-    path: '/error_logger',
319
-    name: 'error_logger',
320
-    meta: {
321
-      hideInBread: true,
322
-      hideInMenu: true
323
-    },
324
-    component: Main,
325
-    children: [
326
-      {
327
-        path: 'error_logger_page',
328
-        name: 'error_logger_page',
329
-        meta: {
330
-          icon: 'ios-bug',
331
-          title: '错误收集'
332
-        },
333
-        component: () => import('@/view/single-page/error-logger.vue')
334
-      }
335
-    ]
336
-  },
337
-  {
338
-    path: '/directive',
339
-    name: 'directive',
340
-    meta: {
341
-      hideInBread: true
342
-    },
343
-    component: Main,
344
-    children: [
345
-      {
346
-        path: 'directive_page',
347
-        name: 'directive_page',
348
-        meta: {
349
-          icon: 'ios-navigate',
350
-          title: '指令'
351
-        },
352
-        component: () => import('@/view/directive/directive.vue')
353
-      }
354
-    ]
355
-  },
266
+  // {
267
+  //   path: '/excel',
268
+  //   name: 'excel',
269
+  //   meta: {
270
+  //     icon: 'ios-stats',
271
+  //     title: '统计信息'
272
+  //   },
273
+  //   component: Main,
274
+  //   children: [
275
+  //     {
276
+  //       path: 'upload-excel',
277
+  //       name: 'upload-excel',
278
+  //       meta: {
279
+  //         icon: 'md-add',
280
+  //         title: '月报'
281
+  //       },
282
+  //       component: () => import('@/view/excel/upload-excel.vue')
283
+  //     },
284
+  //     {
285
+  //       path: 'export-excel',
286
+  //       name: 'export-excel',
287
+  //       meta: {
288
+  //         icon: 'md-download',
289
+  //         title: '日报'
290
+  //       },
291
+  //       component: () => import('@/view/excel/export-excel.vue')
292
+  //     }
293
+  //   ]
294
+  // }
295
+  // {
296
+  //   path: '/tools_methods',
297
+  //   name: 'tools_methods',
298
+  //   meta: {
299
+  //     hideInBread: true
300
+  //   },
301
+  //   component: Main,
302
+  //   children: [
303
+  //     {
304
+  //       path: 'tools_methods_page',
305
+  //       name: 'tools_methods_page',
306
+  //       meta: {
307
+  //         icon: 'ios-hammer',
308
+  //         title: '工具方法',
309
+  //         beforeCloseName: 'before_close_normal'
310
+  //       },
311
+  //       component: () => import('@/view/tools-methods/tools-methods.vue')
312
+  //     }
313
+  //   ]
314
+  // },
315
+  // {
316
+  //   path: '/i18n',
317
+  //   name: 'i18n',
318
+  //   meta: {
319
+  //     hideInBread: true
320
+  //   },
321
+  //   component: Main,
322
+  //   children: [
323
+  //     {
324
+  //       path: 'i18n_page',
325
+  //       name: 'i18n_page',
326
+  //       meta: {
327
+  //         icon: 'md-planet',
328
+  //         title: 'i18n - {{ i18n_page }}'
329
+  //       },
330
+  //       component: () => import('@/view/i18n/i18n-page.vue')
331
+  //     }
332
+  //   ]
333
+  // },
334
+  // {
335
+  //   path: '/error_store',
336
+  //   name: 'error_store',
337
+  //   meta: {
338
+  //     hideInBread: true
339
+  //   },
340
+  //   component: Main,
341
+  //   children: [
342
+  //     {
343
+  //       path: 'error_store_page',
344
+  //       name: 'error_store_page',
345
+  //       meta: {
346
+  //         icon: 'ios-bug',
347
+  //         title: '错误收集'
348
+  //       },
349
+  //       component: () => import('@/view/error-store/error-store.vue')
350
+  //     }
351
+  //   ]
352
+  // },
353
+  // {
354
+  //   path: '/error_logger',
355
+  //   name: 'error_logger',
356
+  //   meta: {
357
+  //     hideInBread: true,
358
+  //     hideInMenu: true
359
+  //   },
360
+  //   component: Main,
361
+  //   children: [
362
+  //     {
363
+  //       path: 'error_logger_page',
364
+  //       name: 'error_logger_page',
365
+  //       meta: {
366
+  //         icon: 'ios-bug',
367
+  //         title: '错误收集'
368
+  //       },
369
+  //       component: () => import('@/view/single-page/error-logger.vue')
370
+  //     }
371
+  //   ]
372
+  // },
373
+  // {
374
+  //   path: '/directive',
375
+  //   name: 'directive',
376
+  //   meta: {
377
+  //     hideInBread: true
378
+  //   },
379
+  //   component: Main,
380
+  //   children: [
381
+  //     {
382
+  //       path: 'directive_page',
383
+  //       name: 'directive_page',
384
+  //       meta: {
385
+  //         icon: 'ios-navigate',
386
+  //         title: '指令'
387
+  //       },
388
+  //       component: () => import('@/view/directive/directive.vue')
389
+  //     }
390
+  //   ]
391
+  // },
356 392
   // {
357 393
   //   path: '/multilevel',
358 394
   //   name: 'multilevel',
@@ -413,59 +449,59 @@ export default [
413 449
   //     }
414 450
   //   ]
415 451
   // },
416
-  {
417
-    path: '/argu',
418
-    name: 'argu',
419
-    meta: {
420
-      hideInMenu: true
421
-    },
422
-    component: Main,
423
-    children: [
424
-      {
425
-        path: 'params/:id',
426
-        name: 'params',
427
-        meta: {
428
-          icon: 'md-flower',
429
-          title: route => `{{ params }}-${route.params.id}`,
430
-          notCache: true,
431
-          beforeCloseName: 'before_close_normal'
432
-        },
433
-        component: () => import('@/view/argu-page/params.vue')
434
-      },
435
-      {
436
-        path: 'query',
437
-        name: 'query',
438
-        meta: {
439
-          icon: 'md-flower',
440
-          title: route => `{{ query }}-${route.query.id}`,
441
-          notCache: true
442
-        },
443
-        component: () => import('@/view/argu-page/query.vue')
444
-      }
445
-    ]
446
-  },
447
-  {
448
-    path: '/401',
449
-    name: 'error_401',
450
-    meta: {
451
-      hideInMenu: true
452
-    },
453
-    component: () => import('@/view/error-page/401.vue')
454
-  },
455
-  {
456
-    path: '/500',
457
-    name: 'error_500',
458
-    meta: {
459
-      hideInMenu: true
460
-    },
461
-    component: () => import('@/view/error-page/500.vue')
462
-  },
463
-  {
464
-    path: '*',
465
-    name: 'error_404',
466
-    meta: {
467
-      hideInMenu: true
468
-    },
469
-    component: () => import('@/view/error-page/404.vue')
470
-  }
452
+//   {
453
+//     path: '/argu',
454
+//     name: 'argu',
455
+//     meta: {
456
+//       hideInMenu: true
457
+//     },
458
+//     component: Main,
459
+//     children: [
460
+//       {
461
+//         path: 'params/:id',
462
+//         name: 'params',
463
+//         meta: {
464
+//           icon: 'md-flower',
465
+//           title: route => `{{ params }}-${route.params.id}`,
466
+//           notCache: true,
467
+//           beforeCloseName: 'before_close_normal'
468
+//         },
469
+//         component: () => import('@/view/argu-page/params.vue')
470
+//       },
471
+//       {
472
+//         path: 'query',
473
+//         name: 'query',
474
+//         meta: {
475
+//           icon: 'md-flower',
476
+//           title: route => `{{ query }}-${route.query.id}`,
477
+//           notCache: true
478
+//         },
479
+//         component: () => import('@/view/argu-page/query.vue')
480
+//       }
481
+//     ]
482
+//   },
483
+//   {
484
+//     path: '/401',
485
+//     name: 'error_401',
486
+//     meta: {
487
+//       hideInMenu: true
488
+//     },
489
+//     component: () => import('@/view/error-page/401.vue')
490
+//   },
491
+//   {
492
+//     path: '/500',
493
+//     name: 'error_500',
494
+//     meta: {
495
+//       hideInMenu: true
496
+//     },
497
+//     component: () => import('@/view/error-page/500.vue')
498
+//   },
499
+//   {
500
+//     path: '*',
501
+//     name: 'error_404',
502
+//     meta: {
503
+//       hideInMenu: true
504
+//     },
505
+//     component: () => import('@/view/error-page/404.vue')
506
+//   }
471 507
 ]

+ 33
- 20
src/store/module/user.js View File

@@ -1,15 +1,15 @@
1 1
 import {
2
-  login,
3
-  logout,
4
-  getUserInfo,
5
-  getMessage,
6
-  getContentByMsgId,
7
-  hasRead,
8
-  removeReaded,
9
-  restoreTrash,
10
-  getUnreadCount
2
+  login
3
+  // logout,
4
+  // getMessage,
5
+  // getContentByMsgId,
6
+  // hasRead,
7
+  // removeReaded,
8
+  // restoreTrash,
9
+  // getUnreadCount
11 10
 } from '@/api/user'
12 11
 import { setToken, getToken } from '@/libs/util'
12
+import { setStore } from '@/libs/store'
13 13
 
14 14
 export default {
15 15
   state: {
@@ -42,6 +42,10 @@ export default {
42 42
       state.token = token
43 43
       setToken(token)
44 44
     },
45
+    setUserInfo (state, userInfo) {
46
+      state.userInfo = userInfo
47
+      setStore({ name: 'userInfo', content: state.userInfo })
48
+    },
45 49
     setHasGetInfo (state, status) {
46 50
       state.hasGetInfo = status
47 51
     },
@@ -74,16 +78,23 @@ export default {
74 78
   },
75 79
   actions: {
76 80
     // 登录
77
-    handleLogin ({ commit }, { userName, password }) {
78
-      userName = userName.trim()
81
+    handleLogin ({ commit }, { loginname, loginpwd }) {
82
+      // userName = loginname.trim()
83
+      // loginname = loginname
84
+      // console.log(loginname, loginpwd)
79 85
       return new Promise((resolve, reject) => {
86
+        // console.log(loginname, loginpwd)
80 87
         login({
81
-          userName,
82
-          password
88
+          loginname,
89
+          loginpwd
83 90
         }).then(res => {
84
-          const data = res.data
91
+          // console.log(res)
92
+          const data = res.data.obj[0]
85 93
           commit('setToken', data.token)
86
-          resolve()
94
+          commit('setUserInfo', data)
95
+          commit('setHasGetInfo', true)
96
+
97
+          resolve(res)
87 98
         }).catch(err => {
88 99
           reject(err)
89 100
         })
@@ -111,11 +122,13 @@ export default {
111 122
         try {
112 123
           getUserInfo(state.token).then(res => {
113 124
             const data = res.data
114
-            commit('setAvatar', data.avatar)
115
-            commit('setUserName', data.name)
116
-            commit('setUserId', data.user_id)
117
-            commit('setAccess', data.access)
118
-            commit('setHasGetInfo', true)
125
+            // --------------------------------------------
126
+            // commit('setAvatar', data.avatar)
127
+            // commit('setUserName', data.name)
128
+            // commit('setUserId', data.user_id)
129
+            // commit('setAccess', data.access)
130
+            // commit('setHasGetInfo', true)
131
+            // ---------------------------------------------------
119 132
             resolve(data)
120 133
           }).catch(err => {
121 134
             reject(err)

+ 24
- 6
src/view/login/login.vue View File

@@ -19,6 +19,8 @@
19 19
 <script>
20 20
 import LoginForm from '_c/login-form'
21 21
 import { mapActions } from 'vuex'
22
+// import { initRouter } from '@/libs/router-util'
23
+
22 24
 export default {
23 25
   components: {
24 26
     LoginForm
@@ -28,14 +30,30 @@ export default {
28 30
       'handleLogin',
29 31
       'getUserInfo'
30 32
     ]),
31
-    handleSubmit ({ userName, password }) {
32
-      this.handleLogin({ userName, password }).then(res => {
33
-        this.getUserInfo().then(res => {
34
-          this.$router.push({
35
-            name: this.$config.homeName
36
-          })
33
+    handleSubmit (e) {
34
+      // var time = new Date().getTime()
35
+      // console.log(time)
36
+      // var _self = this
37
+      // let login = e.loginname
38
+      const { loginname, loginpwd } = e
39
+      this.handleLogin({ loginname, loginpwd }).then(res => {
40
+        // console.log(res)
41
+        // initRouter()
42
+        console.log(this.$config.homeName)
43
+        this.$router.push({
44
+          name: this.$config.homeName
37 45
         })
46
+
47
+        // var time2 = new Date().getTime()
48
+        // console.log(time2)
49
+        // this.getUserInfo().then(res => {
50
+        // console.log(res)
51
+        // var time3 = new Date().getTime()
52
+        // console.log(time3)
38 53
       })
54
+      // })
55
+      // var time2 = new Date().getTime()
56
+      // console.log(time2)
39 57
     }
40 58
   }
41 59
 }

+ 189
- 0
src/view/manager/Information/index.vue View File

@@ -0,0 +1,189 @@
1
+<template>
2
+  <div class='wrap'>
3
+    <h3>资讯管理</h3>
4
+    <div class="infoContent">
5
+       <i-form :model="form" :label-width="80">
6
+          <Form-item label="标题">
7
+              <i-input v-model="formItem.title" placeholder="请输入资讯标题"></i-input>
8
+          </Form-item>
9
+          <Form-item label="分类" class="classify" prop='ntypename'>
10
+              <i-select v-model="form.ntypename" placeholder="请选择资讯分类">
11
+                  <i-option value="beijing">北京市</i-option>
12
+                  <i-option value="shanghai">上海市</i-option>
13
+                  <i-option value="shenzhen">深圳市</i-option>
14
+              </i-select>
15
+          </Form-item>
16
+           <Form-item label="是否置顶" class="radio" prop='ntypeorder'>
17
+              <Radio-group  v-model="form.ntypeorder">
18
+                <Radio label='0'><span>否</span> </Radio>
19
+                <Radio   label='1'><span>是</span> </Radio>
20
+              </Radio-group>
21
+          </Form-item>
22
+          <Form-item label="是否广告位" class="radio" style="margin-left:30px">
23
+              <Radio-group :model.sync="formItem.adSlot">
24
+                <Radio value="0" label='否'></Radio>
25
+                <Radio value="1"  label='是'></Radio>
26
+            </Radio-group>
27
+          </Form-item>
28
+          <Form-item label="标签" >
29
+              <i-input :value.sync="formItem.tag" placeholder="请输入标签"></i-input>
30
+          </Form-item>
31
+          <Form-item label="资讯内容" >
32
+            <editor ref="editor" :value="formItem.content" @on-change="handleChange"/>
33
+          </Form-item>
34
+          <Form-item label="封面图" >
35
+            <div class="upload">
36
+                <Upload v-if="flag" ref="upload" :show-upload-list="false" :format="['jpg','jpeg','png']" :max-size="2048" :before-upload="handleBeforeUpload" :on-format-error="handleFormatError" :on-exceeded-size="handleMaxSize" type="drag" action="//jsonplaceholder.typicode.com/posts/" style="display: inline-block;width:58px;">
37
+                  <div style="width: 58px;height:58px;line-height: 58px;">
38
+                    <i  class="ivu-icon ivu-icon- iconfont icon-21"></i>
39
+                  </div>
40
+                </Upload>
41
+                 <img style="height:200px;width:200px" v-else :src="uploadImg" alt="">
42
+                <!-- <Upload
43
+                  multiple
44
+                  action="//jsonplaceholder.typicode.com/posts/">
45
+                  <i-button type="ghost" icon="ivu-icon ivu-icon- iconfont icon-21"></i-button>
46
+              </Upload> -->
47
+            </div>
48
+          </Form-item>
49
+          <Form-item >
50
+           <Button @click="submit" type="primary" middle>提交</Button>
51
+          </Form-item>
52
+       </i-form>
53
+    </div>
54
+  </div>
55
+</template>
56
+
57
+<script>
58
+import Editor from '_c/editor'
59
+import store from '@/store'
60
+
61
+// import Cropper from '@/components/picture/index.vue'
62
+import { addInfo } from '@/api/info.js'
63
+
64
+export default {
65
+  components: {
66
+    Editor
67
+    // Cropper
68
+  },
69
+  data () {
70
+    return {
71
+      exampleImageSrc: '',
72
+      uploadImg: '',
73
+      flag: true,
74
+      form: {
75
+        ntypename: '',
76
+        ntypeorder: 1,
77
+        createid: ''
78
+      },
79
+      formItem: {
80
+        title: '',
81
+        classify: '',
82
+        top: '0',
83
+        adSlot: '0',
84
+        tag: '',
85
+        content: ''
86
+      }
87
+    }
88
+  },
89
+  mounted () {
90
+    // console.log(store.state.user.userInfo)
91
+    this.form.createid = store.state.user.userInfo.edid
92
+  },
93
+  methods: {
94
+    // ---------------------------------------------------------------
95
+    handleBeforeUpload (file) {
96
+    // 创建一个 FileReader 对象
97
+      let reader = new FileReader()
98
+      // readAsDataURL 方法用于读取指定 Blob 或 File 的内容
99
+      // 当读操作完成,readyState 变为 DONE,loadend 被触发,此时 result 属性包含数据:URL(以 base64 编码的字符串表示文件的数据)
100
+      // 读取文件作为 URL 可访问地址
101
+      reader.readAsDataURL(file)
102
+
103
+      const _this = this
104
+      reader.onloadend = function (e) {
105
+        file.url = reader.result
106
+        console.log(file.url)
107
+        _this.uploadImg = file.url
108
+        _this.flag = false
109
+      }
110
+    },
111
+    handleFormatError (file) {
112
+      this.$Notice.warning({
113
+        title: '文件格式不正确',
114
+        desc: '文件 ' + file.name + ' 格式不正确,请上传 jpg 或 png 格式的图片。'
115
+      })
116
+    },
117
+    handleMaxSize (file) {
118
+      this.$Notice.warning({
119
+        title: '超出文件大小限制',
120
+        desc: '文件 ' + file.name + ' 太大,不能超过 2M。'
121
+      })
122
+    },
123
+    // ------------------------------------------------------------------
124
+    // handleImg (e) {
125
+    //   console.log(e)
126
+    // },
127
+    handleChange (e) {
128
+      console.log(e)
129
+    },
130
+    submit () {
131
+      console.log(this.form)
132
+      addInfo(this.formItem).then(res => {
133
+        console.log(res)
134
+      })
135
+    },
136
+    handleCroped (blob) {
137
+      const formData = new FormData()
138
+      formData.append('croppedImg', blob)
139
+      uploadImg(formData).then(() => {
140
+        this.$Message.success('Upload success~')
141
+      })
142
+    }
143
+  }
144
+
145
+}
146
+</script>
147
+
148
+<style lang='less' scoped>
149
+.wrap{
150
+  padding: 0;
151
+  h3{
152
+    background: #ffffff;
153
+    padding: 10px;
154
+    border-bottom: 10px solid #F5F7F9;
155
+  }
156
+  .infoContent{
157
+    padding: 20px;
158
+    .classify{
159
+      display: inline-block;
160
+      width: 500px;
161
+    }
162
+    .radio{
163
+            display: inline-block;
164
+
165
+    }
166
+    .upload{
167
+      height: 200px;
168
+      width: 200px;
169
+      border:1px solid grey;
170
+      .ivu-upload{
171
+        display: flex;
172
+        justify-content: center;
173
+        align-items: center;
174
+      }
175
+      .ivu-btn-ghost{
176
+        width: 200px;
177
+        height: 200px;
178
+        color: #3D8EFE;
179
+        font-size: 40px;
180
+        border: none;
181
+      }
182
+      .icon-21:before {
183
+        font-size: 40px;
184
+      }
185
+    }
186
+
187
+  }
188
+}
189
+</style>

Loading…
Cancel
Save