Browse Source

添加资源图片上传功能

luyanan 8 years ago
parent
commit
bb0ffddf43

+ 1 - 1
src/main/webapp/css/popup.css

@ -33,7 +33,7 @@
33 33
#resouup{ width: 100%;height:100%;box-shadow: none;opacity:0; position: absolute;left:0;top:0px;cursor: pointer;}
34 34
.resouimgmsg{ position: relative; top:10px;left:30px;font-size: 13px;color: #aaa;}
35 35
/*资源图片上传*/
36
.resouimgshow{ display:none; width:100%; height:100%;}
36
.resouimgshow{width:100%; height:100%;}
37 37
.wrap{ height:200px;position:relative; }
38 38
.jy-up-ch{ position: relative; left:20px; bottom:0; width: 200px;}
39 39
.jy-up-ch .bch{ display: block; position: absolute; background-repeat: no-repeat; background-image: url(../images/bch.jpg); }

+ 1 - 1
src/main/webapp/css/workspace.css

@ -42,7 +42,7 @@
42 42
.resoubrief tr td ul li{ width:100%; max-width:160px; text-indent:1.5em; word-break: break-all;text-align: justify; /*text-overflow:ellipsis; overflow:hidden; white-space:nowrap;*/}
43 43
.resoubrief tr td ul li:first-child{text-indent:0;font-size: 15px;color: #ff8400;}
44 44
.resoubrief tr td .resoimgbox{width: 160px; height: 160px; overflow:hidden;}
45
.managebtn{ display:block; background:#aaa;margin:auto;width:120px;font-size:14px;line-height:30px;color:#fff; border-radius:4px; text-align:center; cursor:pointer;}
45
.managebtn{ display:block; background:#ff8400;margin:auto;width:120px;font-size:14px;line-height:30px;color:#fff; border-radius:4px; text-align:center; cursor:pointer;}
46 46

47 47
.righttab{ width:82%;}
48 48
.worktab a{ color:#333;}

+ 12 - 2
src/main/webapp/js/information.brow.js

@ -378,7 +378,7 @@ $(".subsidebar").click(function(){
378 378
					for(var i=0;i<data.data.length;i++){
379 379
						add='<div class="sharesrc">'
380 380
						add+='<div class="shareshow">'
381
	                	add+='<a href=""><img src="" width="100%" height="140"></a>'
381
	                	add+='<a href=""><img src="/images/resource/'+data.data[i].resourceId+'.jpg" width="100%" height="140" class="resourceImg"></a>'
382 382
	                 	add+='<div class="shareopeart"><a class="sharebtn">咨询</a><a class="sharebtn applicant">申请</a></div>'
383 383
	             		add+='</div>'
384 384
	             		add+='<p>资源名称:<span class="presou">'+ data.data[i].resourceName+'</span></p>'
@ -386,6 +386,13 @@ $(".subsidebar").click(function(){
386 386
	        			add+='</div>'
387 387
	        			$("#sharescrollbox").append(add);
388 388
						$('.applicant').eq(i).attr("resourceId",data.data[i].resourceId);
389
						
390
						$(".resourceImg").eq(i).attr("src","/images/resource/"+data.data[i].resourceId+".jpg");
391
						$(".resourceImg").load(function(){})
392
							.error(function(){
393
								$(this).attr("src","/images/default-resource.jpg");
394
							});	
395
						
389 396
						add="";
390 397
					}
391 398
					//资源轮播
@ -464,7 +471,7 @@ $(".subsidebar").click(function(){
464 471
			}
465 472
			var now = nowYear + "-" + nowMonth + "-" + nowDate;
466 473
			$( "#datepicker").val(now);
467
	
474
			
468 475
			//console.log(now);
469 476
			
470 477
			$( "#datepicker" ).datepicker({ "dateFormat":" yy-mm-dd"});
@ -478,6 +485,9 @@ $(".subsidebar").click(function(){
478 485
			//console.log(index1);
479 486
			var m=console.log();
480 487
			var resourceID=$(this).attr("resourceId");
488
			$(".resouImage").attr("src","/images/resource/"+resourceID+".jpg");
489
			
490
			
481 491
			//console.log(resourceID);
482 492
			//
483 493
			$(".log").text(resName);

+ 5 - 29
src/main/webapp/js/popup.js

@ -33,7 +33,7 @@ function ResourceInfo() {
33 33
		PopHtml += '<div class="resouinforcon">';
34 34
		PopHtml += '<div class="resouimg" >';
35 35
		PopHtml += '<span class="resouup"><input type="file" name="file" id="resouup" >上传资源图片</span>';
36
		PopHtml += '<div class="resouimgshow"><img width="100%" height="100%" src="" id="resouImage" /></div></div>';
36
		PopHtml += '<div class="resouimgshow"><img width="100%" height="100%" src="" class="resouImage" /></div></div>';
37 37
		PopHtml += '<span class="resouimgmsg">尺寸240*240,大小在5M以内,<br/>JPG、PNG格式</span>';
38 38
//		PopHtml += '<div class="wrap" id="jcropdiv">';
39 39
//		PopHtml += '<div class="jc-demo-box" data="0"><div id="target" class="jcrop_w" ></div></div>';
@ -150,9 +150,8 @@ function ResourceInfo() {
150 150
	   //资源图像上传
151 151
		$(function (){
152 152
			var id = $.cookie('');
153
			var cacheImageKey=null;
153
			cacheImageKey=null;
154 154
			if(id){
155
				$("#resouImage").attr("src","/images/resource/"+id+".jpg");
156 155

157 156
				$('#resouup').on('change',function(){ 
158 157
					$(".resouimgshow").show();
@ -165,7 +164,7 @@ function ResourceInfo() {
165 164
						success:function($data){
166 165
							if($data.success){
167 166
								cacheImageKey =$data.data[0].cacheKey
168
								$("#resouImage").attr("src","/images/tmp/"+cacheImageKey);
167
								$(".resouImage").attr("src","/images/tmp/"+cacheImageKey);
169 168
							}else{
170 169
								$.MsgBox.Alert("message",$data.msg);
171 170
							}
@ -177,29 +176,6 @@ function ResourceInfo() {
177 176
				});
178 177
				
179 178
			}
180
			$("#inputb").on("click",function(){
181
//				var x = parseInt($("#x").val()/395*100);
182
//				var y = parseInt($("#y").val()/340*100);
183
//				var w = parseInt($("#w").val()/395*100);
184
//				var h = parseInt($("#h").val()/340*100);
185
				if(cacheImageKey){
186
					$.ajax({
187
						url:"../ajax/image/resource",
188
						type:"POST",
189
						data:{"id":id,"fn":cacheImageKey},
190
						dataType:"json",
191
						success:function($data){
192
							if($data.success){
193
								alert("上传成功");
194
								location.reload(true);
195
							}else{
196
								alert($data.msg);
197
							}
198
						}
199
					});
200
				}
201
			});
202

203 179
		})	
204 180
}
205 181
//资源信息 //
@ -228,7 +204,7 @@ function ResourceApply(){
228 204
		PopHtml += '<tr><th class="resouinfotype " scope="row">交付时间</th><td><div class="resouinforcon"><input type="text" readOnly="true" id="datepicker"class="frmtype dealTime"style="width:200px;"></div></td></tr>';
229 205
		PopHtml += '<tr><th class="resouinfotype"  scope="row">具体需求</th><td><div class="resouinforcon"><textarea class="frmtype detail"></textarea></div></td></tr></table>';
230 206
		
231
		PopHtml += '<div class="resouimgbox floatL"><div class="resouinforcon"><div class="resouimg2" ><img src="" width="100%" height="100%"></div></div></div></div>';
207
		PopHtml += '<div class="resouimgbox floatL"><div class="resouinforcon"><div class="resouimg2" ><img src="" width="100%" height="100%"  class="resouImage"></div></div></div></div>';
232 208
		
233 209
		//相关文件上传
234 210
		PopHtml += '<div class="filebox"style="display:none;"> ';
@ -510,7 +486,7 @@ function DetailInfo(){
510 486
		PopHtml += '<tr><th class="resouinfotype" scope="row">备注</th><td><div class="resouinforcon"id="consultContent"></div></td></tr></table>';
511 487
		PopHtml += '</table>';
512 488
		
513
		PopHtml += '<div class="resouimgbox floatL"><div class="resouinforcon"><div class="resoushowimg1" ><img src="" width="100%" height="100%"></div></div></div></div>';
489
		PopHtml += '<div class="resouimgbox floatL"><div class="resouinforcon"><div class="resoushowimg1" ><img src="" width="100%" height="100%"  class="resouImage"></div></div></div></div>';
514 490
		//文件	
515 491
		PopHtml += '<div class="filebox"> ';
516 492
		PopHtml += '<div class="worktit">相关文件<div class="uploadbtn">上传文件</div></div>';

+ 20 - 3
src/main/webapp/js/sciresource.js

@ -94,6 +94,7 @@ $(function(){
94 94
								$("#industry").val(info.data.industry);
95 95
								$("#descp").val(info.data.descp);
96 96
								$("#professor").text(name);
97
								$(".resouImage").attr("src","/images/resource/"+resourceID+".jpg");
97 98
								}
98 99
								else
99 100
								{
@ -115,9 +116,12 @@ $(function(){
115 116
								$data.subject=$("#subject").val();
116 117
								$data.industry=$("#industry").val();
117 118
								$data.descp=$("#descp").val();
119
								$data.fn=cacheImageKey;
118 120
								
119 121
								if (resourceID) {
122
									
120 123
									$data.resourceId = resourceID;
124
									
121 125
								}
122 126
								function getDataput(){		
123 127
									$.ajax({"url" : "/ajax/resource",
@ -145,7 +149,7 @@ $(function(){
145 149
									$(".blackcover").remove();
146 150
									$("body").css("position","static");
147 151
									$.MsgBox.Confirm("消息", "确定修改资源信息吗?", getDataput)
148
									
152
									$data.fn=cacheImageKey;
149 153
								}else{
150 154
									
151 155
									$.ajax({"url" : "/ajax/resource",
@ -189,7 +193,7 @@ $(function(){
189 193
					$("#consd").html("");
190 194
					for(var i=0;i<data.data.length;i++)
191 195
						{
192
							var add='<div class="maintab"><div class="lefttab fl"><table class="resoubrief"><tr><td><div class="resoimgbox"><img id="resourceImg" width="100%" height="100%" src=""></div></td>'
196
							var add='<div class="maintab"><div class="lefttab fl"><table class="resoubrief"><tr><td><div class="resoimgbox"><img class="resourceImg" width="100%" height="100%" src=""></div></td>'
193 197
							add+='</tr><tr><td><ul><li>'+data.data[i].resourceName+'</li><li>'+data.data[i].supportedServices+'</li> '               
194 198
							add+='<li class="li1">'+data.data[i].subject+'</li>'                   
195 199
							add+='</ul></td></tr><tr>'                
@ -203,6 +207,13 @@ $(function(){
203 207
								$(".li1").eq(i).css({"display":"none"});
204 208
							}														
205 209
							$('.resoumag').eq(i+1).attr("resourceId",data.data[i].resourceId);
210
							
211
							$(".resourceImg").eq(i).attr("src","/images/resource/"+data.data[i].resourceId+".jpg");
212
							$(".resourceImg").load(function(){})
213
								.error(function(){
214
									$(this).attr("src","/images/default-resource.jpg");
215
								});	
216
							
206 217
							//console.log($('.resoumag').eq(i+1).attr("resourceId"));
207 218
							//资源所对应的记录
208 219
							(function(i){
@ -1351,7 +1362,7 @@ function ajaxGet(operationId,o,p){
1351 1362
		"success":function(data){
1352 1363
			if(data.success)
1353 1364
				{
1354
				//console.log(data);
1365
				console.log(data);
1355 1366
					$(".log").text(data.data.resource.resourceName);
1356 1367
					$(".timelog").text(changeTime(data.data.createTime));
1357 1368
					$(".contration").text(data.data.operationId);
@ -1364,6 +1375,11 @@ function ajaxGet(operationId,o,p){
1364 1375
					
1365 1376
					$(".sname").text(data.data.applysquare);
1366 1377
					$(".namecon").text(data.data.resource.professor.name);
1378
					$(".resouImage").attr("src","/images/resource/"+data.data.resource.resourceId+".jpg");
1379
					$(".resouImage").load(function(){})
1380
						.error(function(){
1381
							$(this).attr("src","/images/default-resource.jpg");
1382
						});	
1367 1383
					
1368 1384
					if(data.data.payMethod){
1369 1385
						$("#payMethod").val(data.data.payMethod);
@ -1399,6 +1415,7 @@ function ajaxGet1(operationId){
1399 1415
					$(".dealTime").text(changeTime(data.data.deliverTime));
1400 1416
					$(".namecon").text(data.data.resource.professor.name);
1401 1417
					$(".sname").text(data.data.applysquare);
1418
					$(".resouImage").attr("src","/images/resource/"+data.data.resource.resourceId+".jpg");
1402 1419
					if(data.data.payMethod){
1403 1420
						$("#payMethod").text(data.data.payMethod);
1404 1421
					}

+ 8 - 2
src/main/webapp/js/search.js

@ -131,7 +131,7 @@ $(function(){
131 131
 							for(var i=0;i<$da.length;i++)
132 132
 							{
133 133
 								var add='<div class="item">'
134
 			                    add+='<a class="resourcephoto" href=""><img src="images/default-resource.jpg" width="100%" height="100%"></a>'
134
 			                    add+='<a class="resourcephoto" href=""><img src="" class="resourceImg" width="100%" height="100%"></a>'
135 135
 			                    add+='<div class="synopsis">'
136 136
 			                    add+='<div><a class="resouname" href="">'+$da[i].resourceName+'</a></div>'
137 137
 			                    add+='<div class="belongname">'+$da[i].professor.name+'<img class="modicon" src="images/rz.png" width="28"></div>'
@ -150,7 +150,13 @@ $(function(){
150 150
 								}	                                              
151 151
 			                    add+='<div class="operbox"><span class="operbtn consultbtn">咨询</span><span class="operbtn applybtn appl" resourceId='+$da[i].resourceId+' resourceName='+$da[i].resourceName+' professor='+$da[i].professor.name+'>申请</span></div>'
152 152
 			                	add+='</div>'
153
 			                	$("#professorList").append(add);					
153
 			                	$("#professorList").append(add);
154
 			                    
155
 			                   $(".resourceImg").eq(i).attr("src","/images/resource/"+$da[i].resourceId+".jpg");
156
 								$(".resourceImg").load(function(){})
157
 									.error(function(){
158
 										$(this).attr("src","/images/default-resource.jpg");
159
 									});	
154 160
 							}
155 161
 							if(isbind == true){
156 162
								$(".tcdPageCode").createPage({