Browse Source

发现问题提问图片上传

luyanan 7 years ago
parent
commit
ee4018932d
3 changed files with 62 additions and 61 deletions
  1. 3 2
      css/genindex.css
  2. 4 3
      discover.html
  3. 55 56
      js/discover.js

+ 3 - 2
css/genindex.css

@ -923,7 +923,7 @@ div.zoomMask{position:absolute;background:url("../images/g-resource-mask.png") r
923 923
924 924
.list_hander{margin:10px 0;position: relative;}
925 925
.list_hander .goSpan span{margin:0 6px 0 0;width: 102px;}
926
.list_hander .goSpan span.answered{background:none;border:1px solid #ff9900;color:#ff9900}
926
.list_hander .goSpan span.answered{background:none;border:1px solid #ff9900;color:#ff9900;cursor:auto;}
927 927
.list_hander .goSpan span.answerDel{background:none;border:1px solid #FF0000;color:#FF0000}
928 928
.list_hander .operateBlock{margin:10px 0 0 10px;}
929 929
.list_hander .tip-offs>span{cursor: pointer;margin-left: 10px;}
@ -984,4 +984,5 @@ div.zoomMask{position:absolute;background:url("../images/g-resource-mask.png") r
984 984
.queStep .artAbout>li>dl>dd{width: 30.8%;height: 140px;}
985 985
.queStep ul.artAbout .uploadFile .uploadblock{padding:0;font-size:16px;line-height:22px;height: 140px;}
986 986
.queStep ul.artAbout .uploadFile .uploadtip{font-size:12px;line-height:18px;}
987
987
.queStep .artAbout>li>dl>dd .imgItem{width:187px;height: 138px;}
988
.queStep .artAbout>li>dl>dd .imgItem img{max-width:187px;max-height: 138px;}

+ 4 - 3
discover.html

@ -8,11 +8,12 @@
8 8
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.png" media="screen" />
9 9
<link href="css/bootstrap.min.css" rel="stylesheet">
10 10
<link type="text/css" href="css/common.css" rel="stylesheet">
11
<link rel="stylesheet" type="text/css" href="./css/webuploader/webuploader.css">
11
<link rel="stylesheet" type="text/css" href="./css/webuploader/webuploader2.css">
12 12
<link type="text/css" href="css/genindex.css" rel="stylesheet">
13 13
<script type="text/javascript" src="js/jquery-1.11.1.js"></script>
14 14
<style type="text/css">
15
	ul.artAbout #filePicker{width:187px;height:140px;bottom:0;left:0;margin-left:0;cursor:pointer;}
15
	ul.artAbout #filePicker{width:187px;height:140px;bottom:0;left:0;margin-left:0;cursor:pointer;}
16
	ul.artAbout #filePicker .webuploader-pick{width:187px;height:140px;}
16 17
</style>
17 18
</head>
18 19
<body>
@ -75,7 +76,7 @@
75 76
		        				<div class="uploadblock">
76 77
		        					<span class="" id="filePicker">上传图片</span>
77 78
		        					<!--未上传图片时-->
78
		        					<div class="upFront" style="top:34px;" id="uploader">
79
		        					<div class="upFront" style="top:40px;" id="uploader">
79 80
			        					<p>上传图片</p>
80 81
			        					<p class="uploadtip">JPG/JPEG/PNG格式<br/>大小2M以内</p>
81 82
		        					</div>

+ 55 - 56
js/discover.js

@ -62,7 +62,8 @@ $(function() {
62 62
			}
63 63
		})
64 64
		
65
		var uploader = WebUploader.create({
65
		var imgStr=[];
66
		var uploader =new WebUploader.create({
66 67
			auto: true,
67 68
			fileNumLimit: 3,
68 69
			swf: '../js/webuploader/Uploader.swf',
@ -81,56 +82,58 @@ $(function() {
81 82
		});
82 83
	
83 84
		// 当有文件添加进来的时候
84
//		uploader.on('fileQueued', function(file) {
85
//			fileId = file.id;
86
//			var $len = $("#fileList").find("img").length;
87
//			if($len == 0 || $len == 1) {
88
//				var oRemove = $("#fileList").find("dd");
89
//				oRemove.eq(oRemove.length - 1).remove();
90
//			} 
91
//			var $li = $(
92
//					'<dd>' +
93
//						'<div class="imgItem" id="' + file.id + '">'+
94
//							'<img />' +
95
//						'</div>'+
96
//					'</dd>'
97
//				),
98
//				$btns = $('<div class="file-panel">' +
99
//					'<span class="cancel"></span>' +
100
//					'</div>').appendTo($li),
101
//				$img = $li.find('img');
102
//			var $list = $("#fileList");
103
//			if($len == 1) {
104
//				$list.find("dd").eq(0).after($li)
105
//			} else if($len == 2) {
106
//				$list.find("dd").eq(1).after($li)
107
//			} else {
108
//				$list.prepend($li);
109
//			}
110
//	
111
//			// 创建缩略图
112
//			// 如果为非图片文件,可以不用调用此方法。
113
//			// thumbnailWidth x thumbnailHeight 为 100 x 100
114
//			uploader.makeThumb(file, function(error, src) {
115
//				if(error) {
116
//					$img.replaceWith('<span>不能预览</span>');
117
//					return;
118
//				}
119
//				$img.attr('src', src);
120
//			}, 1, 1);
121
//		});
122
//		uploader.onError = function(code) {
123
//			console.log(code)
124
//			$.MsgBox.Alert('提示', '请上传jpg、jpeg、png格式的图片,大小不超过2M')
125
//		};
126
//		uploader.on('uploadSuccess', function(file, data) {
127
//			if(data.success) {
128
//					uploader.removeFile(fileId);
129
//					var cacheImageKey = temp.push(data.data[0].cacheKey);
130
//			}else{
131
//				$.MsgBox.Alert('提示', '只支持jpeg/jpg/png格式的图片');
132
//			}
133
//		});
85
		uploader.on('fileQueued', function(file) {
86
			fileId = file.id;
87
			var $len = $("#fileList").find("img").length;
88
			if($len == 0 || $len == 1) {
89
				var oRemove = $("#fileList").find("dd");
90
				oRemove.eq(oRemove.length - 1).remove();
91
			} 
92
			var $li = $(
93
					'<dd>' +
94
						'<div class="imgItem" id="' + file.id + '">'+
95
							'<img />' +
96
						'</div>'+
97
					'</dd>'
98
				),
99
				$btns = $('<div class="file-panel">' +
100
					'<span class="cancel"></span>' +
101
					'</div>').appendTo($li),
102
				$img = $li.find('img');
103
			var $list = $("#fileList");
104
			if($len == 1) {
105
				$list.find("dd").eq(0).after($li)
106
			} else if($len == 2) {
107
				$list.find("dd").eq(1).after($li)
108
			} else {
109
				$list.prepend($li);
110
			}
111
	
112
			// 创建缩略图
113
			// 如果为非图片文件,可以不用调用此方法。
114
			// thumbnailWidth x thumbnailHeight 为 100 x 100
115
			uploader.makeThumb(file, function(error, src) {
116
				if(error) {
117
					$img.replaceWith('<span>不能预览</span>');
118
					return;
119
				}
120
				$img.attr('src', src);
121
			}, 1, 1);
122
		});
123
		uploader.onError = function(code) {
124
			console.log(code)
125
			$.MsgBox.Alert('提示', '请上传jpg、jpeg、png格式的图片,大小不超过2M')
126
		};
127
		uploader.on('uploadSuccess', function(file, data) {
128
			if(data.success) {
129
					uploader.removeFile(fileId);
130
					//console.log(data)
131
					var orldUrl = imgStr.push(data.data[0].uri);
132
					
133
			}else{
134
				$.MsgBox.Alert('提示', '只支持jpeg/jpg/png格式的图片');
135
			}
136
		});
134 137
		/*删除图片*/
135 138
		$("#fileList").on("click", ".cancel", function() {
136 139
			var flag=$(this).attr("flag");
@ -138,7 +141,7 @@ $(function() {
138 141
			if(flag==1) {
139 142
				array.splice(oNum,1);
140 143
			}else{
141
				temp.splice(oNum,1);
144
				imgStr.splice(oNum,1);
142 145
			}
143 146
			$(this).parent().parent().remove();
144 147
			
@ -179,10 +182,6 @@ $(function() {
179 182
		$("#pubSte").on("click",function(){
180 183
			var title=$("#queTit").val();
181 184
			var cnt=$("#queCnt").val();
182
			var imgStr=[];
183
//			$(".imgU").each(function() {
184
//				imgStr.push(this.getAttribute("data-preview-src"));
185
//			});
186 185
			var subjects = $("#keyWordlist>li");
187 186
			var subjectAll = "";
188 187
			if(subjects.length > 0) {