miaofuhao лет назад: 7
Родитель
Сommit
24f1bc1f55

+ 79 - 0
WebChat/css/feedback-page.css

@@ -0,0 +1,79 @@
1
+.feedback body {
2
+	background-color: #EFEFF4;
3
+}
4
+.feedback input,
5
+.feedback textarea {
6
+	border: none !important;
7
+}
8
+.feedback textarea {
9
+	height: 100px;
10
+	margin-bottom: 0 !important;
11
+	padding-bottom: 0 !important;
12
+}
13
+.feedback .row {
14
+	width: 100%;
15
+	background-color: #fff;
16
+}
17
+.feedback p {
18
+	padding: 10px 15px 0;
19
+}
20
+.feedback button#submit { 
21
+	width: 90%;
22
+	height: 46px;
23
+	left: 50%;
24
+	-webkit-transform: translate(-50%);
25
+}
26
+.feedback .hidden {
27
+	display: none;
28
+}
29
+.feedback .image-list {
30
+	width: 100%;
31
+	/*height: 90px;*/
32
+	background-size: cover;
33
+	padding: 10px 10px;
34
+	overflow: hidden;
35
+}
36
+.feedback .image-item {
37
+	width: 70px;
38
+	height: 70px;
39
+	background-image: url(../img/iconfont-tianjia.png);
40
+	background-size: 100% 100%;
41
+	display: inline-block;
42
+	position: relative;
43
+	border-radius: 5px;
44
+/*	margin-right: 10px;*/
45
+	border: solid 1px #e8e8e8;
46
+}
47
+.feedback .image-item input[type="file"] {
48
+	position: absolute;
49
+	left: 0px;
50
+	top: 0px;
51
+	width: 100%;
52
+	height: 100%;
53
+	opacity: 0;
54
+	cursor: pointer;
55
+	z-index: 0;
56
+}
57
+.feedback .image-item.space {
58
+	border: none;
59
+}
60
+.feedback .image-item .image-close {
61
+	position: absolute;
62
+	display: inline-block;
63
+	right: -6px;
64
+	top: -6px;
65
+	width: 20px;
66
+	height: 20px;
67
+	text-align: center;
68
+	line-height: 20px;
69
+	border-radius: 12px;
70
+	background-color: #FF5053;
71
+	color: #f3f3f3;
72
+	border: solid 1px #FF5053;
73
+	font-size: 9px;
74
+	font-weight: 200;
75
+	z-index: 1;
76
+}
77
+.feedback .image-item.space .image-close {
78
+	display: none;
79
+}

+ 16 - 0
WebChat/html/myTouSu.html

@@ -11,6 +11,7 @@
11 11
     <link rel="stylesheet" href="../css/app.css" />
12 12
     <link href="../css/mui.picker.css" rel="stylesheet" />
13 13
     <link href="../css/mui.poppicker.css" rel="stylesheet" />
14
+    <link href="../css/feedback-page.css" rel="stylesheet" />
14 15
     <link rel="stylesheet" href="../css/iconfont.css" />
15 16
     <link rel="stylesheet" href="../css/inits.css" />
16 17
     <style>
@@ -196,6 +197,10 @@
196 197
                </div>
197 198
             </li>-->
198 199
         </ul>
200
+        <div class="feedback">
201
+			<p>添加图片(选填,提供问题截图,单张20M以下,最多上传5张)</p>
202
+			<div id='image-list' class="row image-list"></div>
203
+		</div>
199 204
 
200 205
         <p class="action">
201 206
             <i class="iconfont icon-gantanhao" style="margin-right: 5px;font-size: 20px;vertical-align: middle;"></i>
@@ -212,10 +217,12 @@
212 217
     <script src="../js/zepto.js"></script>
213 218
     <script src="../Script/Common/huayi.config.js"></script>
214 219
     <script src="../Script/Common/huayi.http.js"></script>
220
+    <script src="../js/feedback-page.js"></script>
215 221
     <script type="text/javascript">
216 222
         var menuCode = helper.request.queryString("menuCode");
217 223
         var regTel = /^(([0\+]\d{2,3}-)?((0\d{2,3}))?(-)?)?(\d{7,8})(-(\d{3,}))?$/;
218 224
         var regMobile = /^([+-]?)\d*\.?\d+$/;
225
+        var str_ary;
219 226
         console.log(menuCode);
220 227
         //			mui.init()
221 228
         if (menuCode == 'WYBY') {
@@ -234,6 +241,14 @@
234 241
         }
235 242
         //提交按钮
236 243
         $('.submit').on('tap', function () {
244
+        	$(".image-box").each(function(i, n) {
245
+				var a = $(n).attr("indexs");
246
+				if(a) {
247
+					Str += a + ',';
248
+
249
+				}
250
+			})
251
+			str_ary = Str.substring(0, Str.length - 1);
237 252
             if (!$('#zhuTiResult').val()) {
238 253
                 mui.alert('请选择主题词!');
239 254
                 return;
@@ -345,6 +360,7 @@
345 360
                     sourceaddress: $('#detail_address').val(),//详细地址
346 361
                     keys: $('#zhuTiResult').attr('data-index'),//关键词
347 362
                     type: $('#userResult').attr('data-index'),//诉求类型
363
+                    files: str_ary,
348 364
                     isprotect: $('input[name="secret"]:checked').val()//(0普通1保密)
349 365
                 },
350 366
                 success: function (data) {

BIN
WebChat/img/iconfont-tianjia.png


+ 119 - 0
WebChat/js/feedback-page.js

@@ -0,0 +1,119 @@
1
+(function(mui, window, document, undefined) {
2
+	mui.init();
3
+	var get = function(id) {
4
+		return document.getElementById(id);
5
+	};
6
+	var qsa = function(sel) {
7
+		return [].slice.call(document.querySelectorAll(sel));
8
+	};
9
+	var ui = {
10
+		question: get('question'),
11
+		contact: get('contact'),
12
+		imageList: get('image-list'),
13
+		submit: get('submit')
14
+	};
15
+	ui.clearForm = function() {
16
+		ui.question.value = '';
17
+		ui.contact.value = '';
18
+		ui.imageList.innerHTML = '';
19
+		ui.newPlaceholder();
20
+	};
21
+	ui.getFileInputArray = function() {
22
+		return [].slice.call(ui.imageList.querySelectorAll('input[type="file"]'));
23
+	};
24
+	ui.getFileInputIdArray = function() {
25
+		var fileInputArray = ui.getFileInputArray();
26
+		var idArray = [];
27
+		fileInputArray.forEach(function(fileInput) {
28
+			if(fileInput.value != '') {
29
+				idArray.push(fileInput.getAttribute('id'));
30
+			}
31
+		});
32
+		return idArray;
33
+	};
34
+	var imageIndexIdNum = 0;
35
+	ui.newPlaceholder = function() {
36
+		var fileInputArray = ui.getFileInputArray();
37
+		if(fileInputArray &&
38
+			fileInputArray.length > 0 &&
39
+			fileInputArray[fileInputArray.length - 1].parentNode.classList.contains('space')) {
40
+			return;
41
+		}
42
+		imageIndexIdNum++;
43
+		var placeholder = document.createElement('div');
44
+		placeholder.setAttribute('class', 'image-item space');
45
+		var closeButton = document.createElement('div');
46
+		closeButton.setAttribute('class', 'image-close');
47
+		closeButton.innerHTML = 'X';
48
+		closeButton.addEventListener('click', function(event) {
49
+			event.stopPropagation();
50
+			event.cancelBubble = true;
51
+			setTimeout(function() {
52
+				ui.imageList.removeChild(placeholder);
53
+			}, 0);
54
+			return false;
55
+		}, false);
56
+		var fileInput = document.createElement('input');
57
+		fileInput.setAttribute('type', 'file');
58
+		fileInput.setAttribute('class', 'image-box ');
59
+		fileInput.setAttribute('accept', 'image/*');
60
+		fileInput.setAttribute('id', 'image-' + imageIndexIdNum);
61
+
62
+		fileInput.addEventListener('change', function(event) {
63
+			var file = fileInput.files[0];
64
+			var lengh = document.getElementsByClassName("image-item").length;
65
+			if(lengh <6) {
66
+				if(file) {
67
+					var filename = $("#image-" + imageIndexIdNum).val();
68
+					fileName = filename.split("\\")[2];
69
+//					alert(fileName);
70
+					var reader = new FileReader();
71
+					reader.onload = function() {
72
+						//处理 android 4.1 兼容问题
73
+						var base64 = reader.result.split(',')[1];
74
+						var dataUrl = 'data:image/png;base64,' + base64;
75
+						var usercode = localStorage.getItem("user"); //获取本地存储
76
+						//image-box 
77
+						//
78
+						placeholder.style.backgroundImage = 'url(' + dataUrl + ')';
79
+						$.ajax({
80
+							type: "post",
81
+//							http://192.168.4.18:4010/   测试
82
+//							http://12345.shangqiu.gov.cn:8819/  正式服务器
83
+//							http://121.196.219.217:8002/   阿里云服务器
84
+							url: 'http://117.158.196.116:4010/Web/Upload64',
85
+							async: true,
86
+							dataType: 'json',
87
+							data: {
88
+								dataurl: dataUrl,
89
+								usercode: usercode,
90
+								filename:fileName,
91
+							},
92
+
93
+							success: function(data) {
94
+								if(data.state == "success") {
95
+									fileInput.setAttribute('indexs', data.data.F_FileId);
96
+									mui.toast('上传成功'); 
97
+									
98
+								} else {
99
+									mui.alert(data.message);
100
+								}
101
+							}
102
+						});
103
+					}
104
+
105
+					reader.readAsDataURL(file);
106
+					placeholder.classList.remove('space');
107
+					ui.newPlaceholder();
108
+				}
109
+			}else{
110
+				mui.toast('最多上传五张');
111
+			}
112
+
113
+		}, false);
114
+		placeholder.appendChild(closeButton);
115
+		placeholder.appendChild(fileInput);
116
+		ui.imageList.appendChild(placeholder);
117
+	};
118
+	ui.newPlaceholder();
119
+})(mui, window, document, undefined);