Selaa lähdekoodia

修改获取用户id的方式

sunjh 6 vuotta sitten
vanhempi
commit
7d4c91d2eb

+ 14 - 1
src/components/Mine.vue

@@ -77,6 +77,8 @@ import ProjectItem from '@/components/commons/ProjectItem'
 import Http from '@/js/http.js'
 import Apis from '@/js/api.js'
 import {notify} from '@/constants/index'
+import {storageGet} from '@/js/index'
+
 export default {
   name: 'Mine',
   components: {TaskItem, ProjectItem},
@@ -88,9 +90,17 @@ export default {
       user: {}
     }
   },
+  mounted () {
+    this.$nextTick(() => {
+      this.init()
+    })
+  },
   methods: {
+    init () {
+      this.setUserInfo()
+    },
     loadData () {
-      Http.get(Apis.PAGE.MY_CROWD_TEST_PAGE.replace('{userId}', 3), {}).then((res) => {
+      Http.get(Apis.PAGE.MY_CROWD_TEST_PAGE.replace('{userId}', this.user.userVO.id), {}).then((res) => {
         if (res.unfinishedTasks != null && res.unfinishedTasks.length > 0) {
           this.unFinishedTaskList = res.unfinishedTasks
         }
@@ -104,6 +114,9 @@ export default {
           this.user = res.userVO
         }
       })
+    },
+    setUserInfo () {
+      this.user = storageGet('user')
     }
   },
   created: function () {

+ 8 - 2
src/components/cheat/AgencyAdd.vue

@@ -176,12 +176,13 @@
 import Http from '@/js/http'
 import Apis from '@/js/api'
 import {notify} from '@/constants/index'
-import {getAllAbilities, getAllAgencyResourceTypes} from '@/js/index'
+import {getAllAbilities, getAllAgencyResourceTypes,storageGet} from '@/js/index'
 
 export default {
   name: 'AgencyAdd',
   data () {
     return {
+      user:{},
       userId: 0,
       isModifyMode: true,
       dialogVisible: false,
@@ -262,6 +263,7 @@ export default {
     init () {
       this.setServiceTypes()
       this.setResourceTypes()
+      this.setUserInfo()
     },
     //加载数据
     loadData: function () {
@@ -326,7 +328,7 @@ export default {
         headers: {'Content-Type': 'multipart/form-data'},
       }
       formData.append('file', param.file)
-      Http.upload(Apis.FILE.UPLOAD_IMAGE.replace('{userId}', 3), formData, config).then((res) => {
+      Http.upload(Apis.FILE.UPLOAD_IMAGE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
         this.agency.photoUrl = res.data
         console.log(res.data)
         notify('success', '上传成功')
@@ -426,6 +428,10 @@ export default {
         }
       }
       return true
+    },
+    //获取用户信息
+    setUserInfo(){
+      this.user = storageGet('user')
     }
   },
   created: function () {

+ 9 - 4
src/components/cheat/ProjectAdd.vue

@@ -224,13 +224,14 @@
 import Http from '@/js/http.js'
 import Apis from '@/js/api.js'
 import {notify} from '@/constants/index'
-import {getAllPlatformTypes, getAllServiceTypes} from '@/js/index'
+import {getAllPlatformTypes, getAllServiceTypes,storageGet} from '@/js/index'
 
 export default {
   name: 'ProjectAdd',
   data () {
     return {
       userId: 0,
+      user:{},
       dialogVisible: false,
       isModifyMode: true,
       serviceType: [],
@@ -425,6 +426,7 @@ export default {
     init () {
       this.setServiceType()
       this.setPlatformType()
+      this.setUserinfo()
     },
     //加载数据
     loadData: function () {
@@ -435,7 +437,7 @@ export default {
     submitInfo () {
       //this.isModifyMode = false
       const newProject = {
-        userId: 3,
+        userId: this.user.userVO.id,
         name: this.project.name,
         description: this.project.description,
         contactName: this.project.contactName,
@@ -496,7 +498,7 @@ export default {
         headers: {'Content-Type': 'multipart/form-data'},
       }
       formData.append('file', param.file)
-      Http.upload(Apis.FILE.REQUIREMENT_FILE.replace('{userId}', 3), formData, config).then((res) => {
+      Http.upload(Apis.FILE.REQUIREMENT_FILE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
         console.log('上传成功')
         this.project.requireDocUrl = res.data
         console.log(res.data)
@@ -512,7 +514,7 @@ export default {
         headers: {'Content-Type': 'multipart/form-data'},
       }
       formData.append('file', param.file)
-      Http.upload(Apis.FILE.APK.replace('{userId}', 3), formData, config).then((res) => {
+      Http.upload(Apis.FILE.APK.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
         console.log('上传成功')
         this.project.fileUrl = res.data
         console.log(res)
@@ -590,6 +592,9 @@ export default {
         price: '',
         datetime: ''
       }
+    },
+    setUserinfo(){
+      this.user = storageGet('user')
     }
   },
   created: function () {

+ 12 - 6
src/components/project/Project.vue

@@ -298,7 +298,8 @@ import {
   getAllPlatformTypes,
   getAllServiceTypes,
   getProvinceCodeByProvinceName,
-  getProvinceNameByProvinceCode
+  getProvinceNameByProvinceCode,
+  storageGet,
 } from '@/js/index'
 
 export default {
@@ -320,6 +321,7 @@ export default {
     }
     return {
       projectId: 0,
+      user: {},
       tabPosition: 'top',
       institutionArray: [],
       isModifyMode: false,
@@ -455,6 +457,7 @@ export default {
       this.setServiceType()
       this.setPlatformType()
       this.setInstitutions()
+      this.setUserInfo()
       this.loadData()
       // this.project.platform.map(item => {
       //   this.platformType.push(PlatformType[item])
@@ -463,7 +466,7 @@ export default {
     //提交修改
     submitForm (formName) {
       const newProject = {
-        userId: 3,
+        userId: this.user.userVO.id,
         name: this.project.name,
         type: this.project.type,
         platform: this.project.platform,
@@ -527,7 +530,7 @@ export default {
     //接收项目
     submitProjectRequest () {
       const data = {
-        userId: 3,
+        userId: this.user.userVO.id,
         projectId: this.projectId
       }
       Http.post(Apis.USER.SUBMIT_PROJECT_REQUEST, data).then((res) => {
@@ -537,7 +540,7 @@ export default {
     //申请项目
     applyProject () {
       const data = {
-        userId: 3,
+        userId: this.user.userVO.id,
         projectId: this.projectId
       }
       Http.post(Apis.USER.ACCEPT_PROJECT, data).then((res) => {
@@ -655,7 +658,7 @@ export default {
         headers: {'Content-Type': 'multipart/form-data'},
       }
       formData.append('file', param.file)
-      Http.upload(Apis.FILE.REQUIREMENT_FILE.replace('{userId}', 3), formData, config).then((res) => {
+      Http.upload(Apis.FILE.REQUIREMENT_FILE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
         console.log('上传成功')
         this.project.requireDocUrl = res.data
         console.log(res.data)
@@ -668,7 +671,7 @@ export default {
         headers: {'Content-Type': 'multipart/form-data'},
       }
       formData.append('file', param.file)
-      Http.upload(Apis.FILE.APK.replace('{userId}', 3), formData, config).then((res) => {
+      Http.upload(Apis.FILE.APK.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
         console.log('上传成功')
         this.project.fileUrl = res.data
         console.log(res)
@@ -682,6 +685,9 @@ export default {
     },
     setInstitutions () {
       this.institutionArray = getAllInstitutions()
+    },
+    setUserInfo () {
+      this.user = storageGet('user')
     }
   }
 }

+ 16 - 5
src/components/project/ProjectCreate.vue

@@ -151,7 +151,13 @@ import provincecity from '@/components/commons/ProvinceCity'
 import provinceCityJSON from '@/constants/provinceCity.json'
 import ResourceType from '@/constants/enum/resource-type'
 import {notify} from '@/constants/index'
-import {getAllInstitutions, getAllPlatformTypes, getAllServiceTypes, getProvinceNameByProvinceCode} from '@/js/index'
+import {
+  getAllInstitutions,
+  getAllPlatformTypes,
+  getAllServiceTypes,
+  getProvinceNameByProvinceCode,
+  storageGet
+} from '@/js/index'
 
 export default {
   name: 'ProjectCreate',
@@ -170,13 +176,14 @@ export default {
       }
     }
     return {
+      user: {},
       tabPosition: 'top',
       institutionArray: [],
       platforms: [],
       serviceType: [],
       resourceType: ResourceType,
       project: {
-        userId: 3,
+        userId: 0,
         name: '',
         contactName: '',
         contactPhone: '',
@@ -306,6 +313,7 @@ export default {
       this.setServiceType()
       this.setPlatforms()
       this.setInstitution()
+      this.setUserInfo()
       // this.project.platform.map(item => {
       //   this.platformType.push(PlatformType[item])
       // })
@@ -314,7 +322,7 @@ export default {
       //console.log(this.project)
       const newLocation = getProvinceNameByProvinceCode(this.project.location.provinceCode, this.project.location.cityCode)
       const newProject = {
-        userId: 3,
+        userId: this.user.userVO.id,
         name: this.project.name,
         type: this.project.type,
         platform: this.project.platform,
@@ -422,7 +430,7 @@ export default {
         headers: {'Content-Type': 'multipart/form-data'},
       }
       formData.append('file', param.file)
-      Http.upload(Apis.FILE.REQUIREMENT_FILE.replace('{userId}', 3), formData, config).then((res) => {
+      Http.upload(Apis.FILE.REQUIREMENT_FILE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
         //console.log('上传成功')
         this.project.requireDocUrl = res.data
         console.log(this.project.doc)
@@ -437,7 +445,7 @@ export default {
         headers: {'Content-Type': 'multipart/form-data'},
       }
       formData.append('file', param.file)
-      Http.upload(Apis.FILE.APK.replace('{userId}', 3), formData, config).then((res) => {
+      Http.upload(Apis.FILE.APK.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
         console.log('上传成功')
         this.project.fileUrl = res.data
         console.log(res)
@@ -451,6 +459,9 @@ export default {
     },
     setInstitution () {
       this.institutionArray = getAllInstitutions()
+    },
+    setUserInfo () {
+      this.user = storageGet('user')
     }
   }
 }

+ 7 - 2
src/components/report/Report.vue

@@ -87,13 +87,14 @@
 import Http from '@/js/http.js'
 import Apis from '@/js/api.js'
 import {notify} from '@/constants/index'
-import {getAllReportTypes} from '@/js/index'
+import {getAllReportTypes, storageGet} from '@/js/index'
 
 export default {
   name: 'Report-Create',
   components: {},
   data () {
     return {
+      user: {},
       reportId: 0,
       projectId: '',
       taskId: '',
@@ -141,6 +142,7 @@ export default {
       this.projectId = this.$route.params.projectId
       this.taskId = this.$route.params.taskId
       this.setReportType()
+      this.setUserInfo()
       this.loadData()
     },
     modifyForm () {
@@ -270,7 +272,7 @@ export default {
         headers: {'Content-Type': 'multipart/form-data'},
       }
       formData.append('file', param.file)
-      Http.upload(Apis.FILE.UPLOAD_REPORT_FILE.replace('{userId}', 3), formData, config).then((res) => {
+      Http.upload(Apis.FILE.UPLOAD_REPORT_FILE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
         console.log('上传成功')
         this.report.fileUrl = res.data
         console.log(res)
@@ -278,6 +280,9 @@ export default {
     },
     setReportType () {
       this.reportType = getAllReportTypes()
+    },
+    setUserInfo () {
+      this.user = storageGet('user')
     }
   }
 }

+ 7 - 2
src/components/report/ReportCreate.vue

@@ -73,13 +73,14 @@
 import Http from '@/js/http.js'
 import Apis from '@/js/api.js'
 import {notify} from '@/constants/index'
-import {getAllReportTypes} from '@/js/index'
+import {getAllReportTypes, storageGet} from '@/js/index'
 
 export default {
   name: 'ReportCreate',
   components: {},
   data () {
     return {
+      user: {},
       reportType: [],
       scope: 0,
       projectId: '',
@@ -129,6 +130,7 @@ export default {
       this.dependencyCode = this.$route.params.dependencyCode
       this.projectId = this.$route.params.projectId
       this.taskId = this.$route.params.taskId
+      this.setUserInfo()
       this.setReportType()
     },
     submitForm (formName) {
@@ -216,7 +218,7 @@ export default {
         headers: {'Content-Type': 'multipart/form-data'},
       }
       formData.append('file', param.file)
-      Http.upload(Apis.FILE.UPLOAD_REPORT_FILE.replace('{userId}', 3), formData, config).then((res) => {
+      Http.upload(Apis.FILE.UPLOAD_REPORT_FILE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
         console.log('上传成功')
         this.report.fileUrl = res.data
         console.log(res)
@@ -224,6 +226,9 @@ export default {
     },
     setReportType () {
       this.reportType = getAllReportTypes
+    },
+    setUserInfo () {
+      this.user = storageGet('user')
     }
   }
 }

+ 10 - 4
src/components/task/Task.vue

@@ -136,7 +136,8 @@ import {
   getAllInstitutions,
   getAllServiceTypes,
   getProvinceCodeByProvinceName,
-  getProvinceNameByProvinceCode
+  getProvinceNameByProvinceCode,
+  storageGet
 } from '@/js/index'
 
 export default {
@@ -147,6 +148,7 @@ export default {
   },
   data () {
     return {
+      user: {},
       isModifyMode: false,
       institutionArray: [],
       tabPosition: 'top',
@@ -246,6 +248,7 @@ export default {
     init () {
       this.taskId = this.$route.params.taskId
       this.projectId = this.$route.params.projectId
+      this.setUserInfo()
       this.loadData(this.projectId, this.taskId)
       this.setInstitutions()
     },
@@ -325,7 +328,7 @@ export default {
     },
     applyTask () {
       const data = {
-        userId: 3,
+        userId: this.user.userVO.id,
         projectId: this.projectId,
         taskId: this.taskId
       }
@@ -335,7 +338,7 @@ export default {
     },
     submitTaskRequest () {
       const data = {
-        userId: 3,
+        userId: this.user.userVO.id,
         projectId: this.projectId,
         taskId: this.taskId
       }
@@ -421,7 +424,7 @@ export default {
         headers: {'Content-Type': 'multipart/form-data'},
       }
       formData.append('file', param.file)
-      Http.upload(Apis.FILE.REQUIREMENT_FILE.replace('{userId}', 3), formData, config).then((res) => {
+      Http.upload(Apis.FILE.REQUIREMENT_FILE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
         console.log('上传成功')
         this.task.requireDocUrl = res.data
         console.log(res.data)
@@ -432,6 +435,9 @@ export default {
     },
     setInstitutions () {
       this.institutionArray = getAllInstitutions()
+    },
+    setUserInfo () {
+      this.user = storageGet('user')
     }
   },
   // created () {

+ 7 - 2
src/components/task/TaskCreate.vue

@@ -94,7 +94,7 @@ import Http from '@/js/http.js'
 import Apis from '@/js/api.js'
 import ResourceType from '@/constants/enum/resource-type.js'
 import {notify} from '@/constants/index'
-import {getAllInstitutions, getAllServiceTypes, getProvinceNameByProvinceCode} from '@/js/index'
+import {getAllInstitutions, getAllServiceTypes, getProvinceNameByProvinceCode, storageGet} from '@/js/index'
 
 export default {
   name: 'Task',
@@ -103,6 +103,7 @@ export default {
   },
   data () {
     return {
+      user: {},
       projectId: 0,
       institutionArray: [],
       tabPosition: 'top',
@@ -200,6 +201,7 @@ export default {
       this.projectId = this.$route.params.projectId
       this.setServiceType()
       this.setInstitutions()
+      this.setUserInfo()
     },
     updateLocation (location) {
       var provinceName = ''
@@ -315,7 +317,7 @@ export default {
         headers: {'Content-Type': 'multipart/form-data'},
       }
       formData.append('file', param.file)
-      Http.upload(Apis.FILE.REQUIREMENT_FILE.replace('{userId}', 3), formData, config).then((res) => {
+      Http.upload(Apis.FILE.REQUIREMENT_FILE.replace('{userId}', this.user.userVO.id), formData, config).then((res) => {
         console.log('上传成功')
         this.task.requireDocUrl = res.data
         console.log(res.data)
@@ -326,6 +328,9 @@ export default {
     },
     setInstitutions () {
       this.institutionArray = getAllInstitutions()
+    },
+    setUserInfo () {
+      this.user = storageGet('user')
     }
   }
 }

+ 13 - 1
src/js/index.js

@@ -19,7 +19,19 @@ export const getUserIdentity = () => {
 
 //获取用户信息
 export const getCurrentUser = () => {
-  return Http.get(Apis.USER.GET_CURRENT_USER)
+  const data = {
+    userVO: {
+      id: 3,
+      name: '郭超',
+      mobile:'110',
+      email:'12345@qq.com',
+    },
+    agency: '',
+  }
+  return new Promise((resolve) => {
+    resolve(data)
+  })
+  //return Http.get(Apis.USER.GET_CURRENT_USER)
 }
 
 //上传文档