Ver código fonte

上传头像 实验项目

yu 4 anos atrás
pai
commit
83f9077fe0

+ 39 - 1
components/student/StudentInfo.vue

@@ -5,7 +5,7 @@
 				<image src="../../assets/login/loginPic2.png" class="m_upload_img"></image>
 			</view>
 			<view class="m_hander_item m_hander_item_left" style="display: inline-block;">
-				<button type="default" class="m_btn m_btn_download" size="mini">上传头像</button>
+				<button type="default" class="m_btn m_btn_download" size="mini" @click="onUploadAvatar">上传头像</button>
 			</view>
 		</view>
 		<view class="m_card">
@@ -183,6 +183,44 @@
 					}
 				})
 			}
+		},
+		onUploadAvatar(){
+		
+			uni.chooseFile({
+			    success: (chooseFileRes) => {
+			        const tempFilePaths = chooseFileRes.tempFilePaths;
+			        uni.uploadFile({
+			            url: this.$Api + "/user/uploaduserheadimage", //仅为示例,非真实的接口地址
+			            filePath: tempFilePaths[0],
+			            name: 'file',
+			            formData: {
+							'UserID':this.$UserId,                // 创建用户 id
+			            },
+			            success: (uploadFileRes) => {
+			                console.log('upload ok=',uploadFileRes.data);
+							//刷新avatar
+							uni.request({
+								header: {
+									'Content-Type': 'application/json;charset=UTF-8'
+								},
+							   url: this.$Api + " /user/getuserinfo", //仅为示例,非真实的接口地址
+								method: 'POST',
+								data: {
+									"UserID": UserID,
+								},
+								dataType: 'json',
+								success: (res) => {
+									let data = res.data;
+									userInfo.avatarSrc = data.Image;
+								},
+								fail: (res) => {
+									console.log("fail+**+*", res)
+								}
+							});
+			            }
+			        });
+			    }
+			});
 		}
 	}
 </script>

+ 22 - 8
components/student/table.vue

@@ -14,9 +14,9 @@
 				</thead>
 				<tbody>
 					<tr v-for="(item,index) in tabledata" :key="index">
+						<th>{{item.Id}}</th>
 						<th>{{item.ProjectName}}</th>
-						<th></th>
-						<th></th>
+						<th>{{item.Type}}</th>
 						<th>{{item.CreateUserName}}</th>
 						<th style="position: relative;"><button type="default" @click="find(item)" size="mini" class="m_delete">查看</button></th>
 					</tr>
@@ -64,15 +64,29 @@
 					method: "POST",
 					dataType: "json",
 					success: res => {
-						var {
-							data
-						} = res;
-						this.tabledata = res.Projects
+					
+						this.tabledata = res.data.Projects
+						// console.log('res=',this.tabledata)
 					}
 				})
 			},
-			find(obj) {
-
+			find(item) {
+		
+				uni.downloadFile({
+					url: item.ProjectReviewImage,
+					success: (res) => {
+						if (res.statusCode === 200) {
+							uni.openDocument({
+								filePath: res.tempFilePath, 
+								// 如果文件名包含中文,建议使用escape(res.tempFilePath)转码,防止ios和安卓客户端导致的差异
+								success: function(res) {
+									console.log('打开文档成功');
+								}
+							});
+						}
+					},
+				});
+		
 			}
 		}
 	}

+ 39 - 1
components/user/selfInfo.vue

@@ -15,7 +15,7 @@
 				<view class="self-avatar df">
 					<img :src="userInfo.avatarSrc"></img>
 				</view>
-				<view class="self-btn02 df jcc aic">上传头像</view>
+				<view class="self-btn02 df jcc aic" @click="onUploadAvatar">上传头像</view>
 			</view>
 			<view class="box2 df ">
 				<view class="box2-content">
@@ -310,6 +310,44 @@
 				this.model.Certificate = data.Certificate ? data.Certificate : this.model.Certificate;
 				this.model.CertificateNum = data.CertificateNum;
 			}
+		},
+		onUploadAvatar(){
+		
+			uni.chooseFile({
+			    success: (chooseFileRes) => {
+			        const tempFilePaths = chooseFileRes.tempFilePaths;
+			        uni.uploadFile({
+			            url: this.$Api + "/user/uploaduserheadimage", //仅为示例,非真实的接口地址
+			            filePath: tempFilePaths[0],
+			            name: 'file',
+			            formData: {
+							'UserID':this.$UserId,                // 创建用户 id
+			            },
+			            success: (uploadFileRes) => {
+			                console.log('upload ok=',uploadFileRes.data);
+							//刷新avatar
+							uni.request({
+								header: {
+									'Content-Type': 'application/json;charset=UTF-8'
+								},
+							   url: this.$Api + " /user/getuserinfo", //仅为示例,非真实的接口地址
+								method: 'POST',
+								data: {
+									"UserID": UserID,
+								},
+								dataType: 'json',
+								success: (res) => {
+									let data = res.data;
+									userInfo.avatarSrc = data.Image;
+								},
+								fail: (res) => {
+									console.log("fail+**+*", res)
+								}
+							});
+			            }
+			        });
+			    }
+			});
 		}
 	}
 </script>

+ 0 - 17
components/user/stuTestDetails.vue

@@ -40,9 +40,7 @@
 					<view class="title-text">成绩分布</view>
 				</view>
 				<view class="box2-table-box-cjfb df fdr aic">
-					<!-- <radar class=""></radar> -->
 					<canvas canvas-id="canvasRadar" class="charts myRadar radarChat"></canvas>
-					<!-- <web-view class='webview' :src="url" v-if="url.length"></web-view> -->
 					<!-- 五维图暂缓 -->
 				</view>
 			</view>
@@ -143,7 +141,6 @@
 		},
 		data() {
 			return {
-				// url:'https://www.yuyekeji.cn/H5/radar.html',
 				cWidth:'',
 				cHeight:'',
 				pixelRatio:1,
@@ -189,20 +186,6 @@
 			//#endif
 			this.cWidth=uni.upx2px(900);
 			this.cHeight=uni.upx2px(900);
-			
-			// //px转vw
-			// @function px2vw($px) {
-			// 	@return $px/1920*100vw;
-			// }
-			// //px转vh
-			// @function px2vh($px) {
-			// 	@return $px/1080*100vh;
-			// }
-			// this.cWidth=uni.px2vw(100);
-			// this.cHeight=uni.px2vw(100);
-	
-			// let data = {"categories":["原理认知","实景勘察","虚拟技术搭建","虚拟艺术创作","教师评分(加分项目)"],"series":[{"name":"成绩分布","data":[90,110,165,195,187]}]}
-			// _self.showRadar("canvasRadar",data);
 		},
 		methods: {
 			//点击添加个人信息

+ 39 - 4
components/user/user.vue

@@ -18,7 +18,7 @@
 					<view class="user-left-avatar df">
 						<img :src="userInfo.avatarSrc"></img>
 					</view>
-					<view class="user-left-btn df jcc aic">上传头像</view>
+					<view class="user-left-btn df jcc aic" @click="onUploadAvatar">上传头像</view>
 				</view>
 				<view class="user-left-line"></view>
 				<view class="user-left-menu">
@@ -228,7 +228,6 @@
 										console.log("fail+**+*", res)
 									}
 								});
-								
 							}
 						}
 						//200失败
@@ -241,8 +240,6 @@
 						console.log("fail+**+*", res)
 					}
 				});
-				
-				
 			},
 			scroll(e) {
 				//记录scroll  位置
@@ -352,6 +349,44 @@
 					}
 				});
 				
+			},
+			onUploadAvatar(){
+
+				uni.chooseFile({
+				    success: (chooseFileRes) => {
+				        const tempFilePaths = chooseFileRes.tempFilePaths;
+				        uni.uploadFile({
+				            url: this.$Api + "/user/uploaduserheadimage", //仅为示例,非真实的接口地址
+				            filePath: tempFilePaths[0],
+				            name: 'file',
+				            formData: {
+								'UserID':this.$UserId,                // 创建用户 id
+				            },
+				            success: (uploadFileRes) => {
+				                console.log('upload ok=',uploadFileRes.data);
+								//刷新avatar
+								uni.request({
+									header: {
+										'Content-Type': 'application/json;charset=UTF-8'
+									},
+								   url: this.$Api + " /user/getuserinfo", //仅为示例,非真实的接口地址
+									method: 'POST',
+									data: {
+										"UserID": UserID,
+									},
+									dataType: 'json',
+									success: (res) => {
+										let data = res.data;
+										userInfo.avatarSrc = data.Image;
+									},
+									fail: (res) => {
+										console.log("fail+**+*", res)
+									}
+								});
+				            }
+				        });
+				    }
+				});
 			}
 		}
 	}