Browse Source

登录登出100%+添加资讯100%

master
chengxuke 4 years ago
parent
commit
77ba890f6a
6 changed files with 35 additions and 9 deletions
  1. 1
    0
      package.json
  2. 4
    1
      src/api/info.js
  3. 3
    3
      src/libs/axios.js
  4. 2
    1
      src/main.js
  5. 10
    0
      src/router/routers.js
  6. 15
    4
      src/view/manager/Information/index.vue

+ 1
- 0
package.json View File

@@ -23,6 +23,7 @@
23 23
     "iview": "^3.2.2",
24 24
     "iview-area": "^1.5.17",
25 25
     "js-cookie": "^2.2.0",
26
+    "qs": "^6.9.4",
26 27
     "simplemde": "^1.11.2",
27 28
     "sortablejs": "^1.7.0",
28 29
     "tree-table-vue": "^1.1.0",

+ 4
- 1
src/api/info.js View File

@@ -1,10 +1,13 @@
1 1
 import axios from '@/libs/api.request'
2
+const qs = require('qs')
3
+
2 4
 // 添加
3 5
 export const addInfo = (data) => {
6
+  var form = qs.stringify({ ...data })
4 7
   return axios.request({
5 8
     url: 'https://aicpapitest.xhkjedu.com/news/add',
6 9
     method: 'POST',
7
-    data
10
+    form
8 11
   })
9 12
 }
10 13
 // 获取资讯分类列表

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

@@ -21,15 +21,15 @@ class HttpRequest {
21 21
   }
22 22
   getInsideConfig () {
23 23
     // if (getToken()) {
24
+    var id = JSON.parse(localStorage.getItem('userInfo')).content.userid
25
+
24 26
     const config = {
25
-      // baseURL: this.baseUrl,
26 27
       'Header': {
27 28
         'Content-Type': 'application/x-www-form-urlencoded'
28 29
       },
29
-      // 'cookie': [],
30 30
       'token': getToken(),
31 31
       'device': 'web',
32
-      'uid': '1'
32
+      'uid': id
33 33
     }
34 34
     // }
35 35
 

+ 2
- 1
src/main.js View File

@@ -15,7 +15,7 @@ import '@/assets/icons/iconfont.css'
15 15
 import '@/assets/iconfont/iconfont.css'
16 16
 // import Vue from 'vue'
17 17
 import VueCropper from 'vue-cropper'
18
-
18
+import qs from 'qs'
19 19
 import TreeTable from 'tree-table-vue'
20 20
 import VOrgTree from 'v-org-tree'
21 21
 import 'v-org-tree/dist/v-org-tree.css'
@@ -24,6 +24,7 @@ Vue.use(VueCropper)
24 24
 
25 25
 // 路由问题/
26 26
 // import Router from 'vue-router'
27
+Vue.prototype.$qs = qs
27 28
 Vue.prototype.$echarts = echarts
28 29
 // const routerPush = Router.prototype.push
29 30
 // Router.prototype.push = function push (location) {

+ 10
- 0
src/router/routers.js View File

@@ -116,6 +116,16 @@ export default [
116 116
         component: () => import('@/view/manager/Information/index.vue')
117 117
       }
118 118
       // {
119
+      //   path: 'Information',
120
+      //   name: 'Information',
121
+      //   meta: {
122
+      //     icon: 'ios-create',
123
+      //     title: '资讯管理'
124
+      //   },
125
+      //   // component: () => import('@/view/components/editor/editor.vue')
126
+      //   component: () => import('@/view/manager/Information/index.vue')
127
+      // }
128
+      // {
119 129
       //   path: 'editor_page',
120 130
       //   name: 'editor_page',
121 131
       //   meta: {

+ 15
- 4
src/view/manager/Information/index.vue View File

@@ -2,7 +2,7 @@
2 2
   <div class='wrap'>
3 3
     <h3><i style="margin-right:10px"  class="ivu-icon ivu-icon- iconfont icon-jiantoujinggao"></i>资讯管理</h3>
4 4
     <div class="infoContent">
5
-       <i-form :model="form" :label-width="80">
5
+       <i-form :model="form" ref="form" :label-width="80">
6 6
           <Form-item label="标题">
7 7
               <i-input v-model="form.ntitle" placeholder="请输入资讯标题"></i-input>
8 8
           </Form-item>
@@ -78,6 +78,7 @@
78 78
 
79 79
 <script>
80 80
 import Editor from '_c/editor'
81
+import { getToken } from '@/libs/util'
81 82
 // import store from '@/store'
82 83
 
83 84
 // import Cropper from '@/components/picture/index.vue'
@@ -111,13 +112,20 @@ export default {
111 112
         edid: '',
112 113
         schoolid: '',
113 114
         createid: '',
114
-        ntagname: undefined
115
+        ntagname: undefined,
116
+        token: '',
117
+        uid: '',
118
+        device: 'web'
119
+
115 120
       }
116 121
     }
117 122
   },
118 123
   mounted () {
119 124
     this.userInfo = JSON.parse(localStorage.getItem('userInfo'))
120 125
     // console.log(this.userInfo.content)
126
+    this.form.token = getToken()
127
+    // console.log(this.from.token)
128
+    this.form.uid = this.userInfo.content.userid
121 129
     this.form.schoolid = this.userInfo.content.schoolid
122 130
     this.form.edid = this.userInfo.content.edid
123 131
     this.form.nlevel = this.userInfo.content.schoolstate
@@ -222,10 +230,13 @@ export default {
222 230
     },
223 231
     // 添加
224 232
     submit () {
225
-      console.log(this.form)
233
+      // console.log(this.form)
226 234
       addInfo(this.form).then(res => {
227
-        console.log(res)
235
+        if (res.data.code === 0) {
236
+          this.$Message.success('添加成功')
237
+        }
228 238
       })
239
+      // this.$refs.form.resetFields()
229 240
     }
230 241
   }
231 242
 

Loading…
Cancel
Save