yu 4 лет назад
Родитель
Сommit
1709b3e905
5 измененных файлов с 133 добавлено и 17 удалено
  1. 3 0
      App.vue
  2. 121 16
      components/home/simulationCore.vue
  3. 5 0
      components/home/sy.vue
  4. 1 0
      components/login/login.vue
  5. 3 1
      pages/home.vue

+ 3 - 0
App.vue

@@ -7,6 +7,9 @@
 <script>
 	import Home from './pages/home.vue'
 	export default {
+		globalData:{
+			bLogin:false,
+		},
 		data() {
 			return {}
 		},

+ 121 - 16
components/home/simulationCore.vue

@@ -33,13 +33,13 @@
 					</thead>
 					<tbody>
 						<tr v-for="(item,index) in projectData" :key="index">
+							<th>{{item.Id}}</th>
 							<th>{{item.ProjectName}}</th>
-							<th>{{item.ProjectName}}</th>
-							<th>类型</th>
-							<th>介绍</th>
-							<th>进度</th>
-							<th class="m_yl"><button type="default" size="mini" class="m_edit">预览</button></th>
-							<th style="position: relative;"><button type="default" @click="projectRemove(item)" size="mini" class="m_delete">删除</button></th>
+							<th>{{item.Type}}</th>
+							<th>{{item.Intro}}</th>
+							<th>{{item.Progress}}</th>
+							<th class="m_yl"><button type="default" size="mini" class="m_edit" @click="preview(item)">预览</button></th>
+							<th style="position: relative;"><button type="default" @click="deleteMember(item)" size="mini" class="m_delete">删除</button></th>
 						</tr>
 					</tbody>
 				</table>
@@ -57,27 +57,132 @@
 				projectData: []
 			}
 		},
-		created() {
-			this.getlist();
-		},
+		
 		methods: {
-			getlist() {
+			init(){
+				console.log('simulationCore init');
+				// uni.chooseImage({
+				//     success: (chooseImageRes) => {
+				//         const tempFilePaths = chooseImageRes.tempFilePaths;
+				//         uni.uploadFile({
+				//             url: 'http://39.105.166.141:8085/project/createprojectnew', //仅为示例,非真实的接口地址
+				//             filePath: tempFilePaths[0],
+				//             name: 'file',
+				//             formData: {
+				// 				'CreateUserID':'1e9c969f-8990-40f2-8a8c-ecbafc5720b2',                // 创建用户 id
+				// 				'ProjectName':'test22',           // 项目名称
+				// 				'Describe':'aaa22',              // 项目描述
+				// 				'Type':'bbbbb22',                 // 科幻 现实 历史 主旋律 纪录片
+				//             },
+				//             success: (uploadFileRes) => {
+				//                 console.log('upload ok=',uploadFileRes.data);
+				//             }
+				//         });
+				//     }
+				// });
+				this.getProjectsID();
+			},
+			getProjectsID() {
+				// console.log('userID=',this.$UserId)
 				uni.request({
-					url: this.$Api + "/project/getprojectcontent",
+					url: this.$Api + "/project/getprojects",
 					data: {
 						"UserID": this.$UserId
 					},
 					method: "POST",
 					dataType: "json",
 					success: res => {
-						var {
-							data
-						} = res;
-						this.projectData = data.Project;
-
+						// console.log('res=',res)
+						// console.log('Projects=',res.data.Projects)
+						let Projects = res.data.Projects;
+						for(let i=0;i<Projects.length;i++)
+						{
+							let data = {};
+							data.Id = Projects[i].Id;
+							data.ProjectName = Projects[i].ProjectName;
+							data.Type = '后台缺';
+							data.Intro = '后台缺';
+							data.Progress = '后台缺';
+							data.File = [];
+							data.Member = [];
+							this.projectData.push(data);
+						}
+						
+						for(let i=0;i<this.projectData.length;i++)
+						{
+							this.getProjectsCtcontent(i);
+						}
+					}
+				})
+			},
+			getProjectsCtcontent(index) {
+				// console.log('UserID=',this.$UserId)
+				// console.log('ProjectID=',this.projectData[index].Id)
+				uni.request({
+					url: this.$Api + "/project/getprojectcontent",
+					data: {
+						"UserID": this.$UserId,
+						"ProjectID": this.projectData[index].Id
+					},
+					method: "POST",
+					dataType: "json",
+					success: res => {
+						// console.log('res=',res)
+						this.projectData[index].Type = res.data.ProjectItem.Type;
+						this.getMember(index);
+					}
+				})
+			},
+			getMember(index) {
+				uni.request({
+					url: this.$Api + "/project/getmember",
+					data: {
+						"ProjectID": this.projectData[index].Id
+					},
+					method: "POST",
+					dataType: "json",
+					success: res => {
+						// console.log('res=',res)
+						// console.log('Projects=',res.data.Users[0].User.Id)
+						for(let i=0;i<res.data.Users.length;i++)
+						{
+							console.log('Projects=',res.data.Users[i].User.Id)
+							this.projectData[index].Member.push(res.data.Users[i].User.Id);
+						}
 					}
 				})
 			},
+			preview(item){
+				uni.downloadFile({
+					url: item.File,
+					success: (res) => {
+						if (res.statusCode === 200) {
+							uni.openDocument({
+								filePath: res.tempFilePath, 
+								// 如果文件名包含中文,建议使用escape(res.tempFilePath)转码,防止ios和安卓客户端导致的差异
+								success: function(res) {
+									console.log('打开文档成功');
+								}
+							});
+						}
+					},
+				});
+			},
+			deleteMember(item){
+				uni.request({
+					url: this.$Api + "/project/deletemember",
+					data: {
+						"userID" : this.$UserId,
+						"DeleteUserID":item.Id
+					},
+					method: "POST",
+					dataType: "json",
+					success: res => {
+						console.log('res=',res)
+						// this.projectData.splice(index,index);
+					}
+				})
+			}
 		}
 	}
 </script>

+ 5 - 0
components/home/sy.vue

@@ -89,6 +89,11 @@
 				this.$forceUpdate()
 			},
 			onClick_menu(index) {
+			
+				if(!getApp().globalData.bLogin) {
+					alert('请先登录')
+					return
+				};
 				this.showIndex = index;
 			},
 			onClick_menu_btn(index) {

+ 1 - 0
components/login/login.vue

@@ -44,6 +44,7 @@
 			},
 			onLogin: function() {
 				// console.log("登录成功login");
+				getApp().globalData.bLogin = true;
 				this.$emit("onLogin");
 				this.visibleChooseRole = false;
 				this.visibleLoginByPWD = false;

+ 3 - 1
pages/home.vue

@@ -157,7 +157,7 @@
 				this.showPage(pageIndex);
 			},
 			onLogin: function() {
-				// console.log("登陆成功home");
+				console.log("登陆成功home");
 				this.$refs.TopMenu.switchLoginState(true);
 				this.showPage(4);
 			},
@@ -445,6 +445,7 @@
 					case 2: //管理中心
 						targetPage = 11;
 						topMiddleState = topMenuS.home3;
+						this.$refs.simulationcore.init();
 						break;
 					case 3: //拍摄基地
 						targetPage = 12;
@@ -455,6 +456,7 @@
 				}
 				this.showPage(targetPage);
 				this.$refs.TopMenu.switchMiddleState(topMiddleState, index);
+				
 				this.$forceUpdate();
 			},
 			//项目管理平台