Преглед на файлове

回答读取内容html解析
回答添加点赞排序

luyanan преди 7 години
родител
ревизия
43ff3cbe86
променени са 10 файла, в които са добавени 53 реда и са изтрити 59 реда
  1. 1 1
      app/css/app.css
  2. 0 19
      app/html/discoverNew.html
  3. 0 18
      app/html/qa-question-show.html
  4. 1 1
      app/js/discoverNew.js
  5. 14 8
      app/js/moreItem.js
  6. 8 0
      app/js/public/base.js
  7. 6 3
      app/js/qa-answer-q.js
  8. 13 2
      app/js/qa-answer-show.js
  9. 1 1
      app/js/qa-my-wenda.js
  10. 9 6
      app/js/qa-question-show.js

+ 1 - 1
app/css/app.css

@ -1164,7 +1164,7 @@ ul.tagList>li .h2Font{color: #666; -webkit-user-select:text;}
1164 1164
.qa-owner .owner-head.useHead{width:32px;height:32px;margin-top:-16px;background-image: url(../images/default-photo.jpg);border-radius: 50%;}
1165 1165
.qa-owner .owner-info{padding-left:38px;width: 100%;overflow: hidden;height: 26px;}
1166 1166
.owner-name{float: left;}
1167
.owner-tit{padding-left:8px;color:#888888}
1167
.owner-tit{padding-left:8px;color:#888888;line-height:24px;}
1168 1168
.qa-con{font-size:14px;line-height: 22px;color:#666;word-break: break-word;}
1169 1169
.showliSpan{overflow: hidden;margin-top:10px;margin-right:-10px;}
1170 1170
.showliSpan>span{font-size:13px;line-height: 22px;color: #999999;padding-right:10px}

+ 0 - 19
app/html/discoverNew.html

@ -181,25 +181,6 @@
181 181
										</div>
182 182
									</div>
183 183
									<ul class="mui-table-view myAllneeds partLine" id="questionItem">
184
										<!--<li class="mui-table-view-cell">
185
										<div class="madiaInfo">
186
										<p class="h1Font mui-ellipsis-2">需求主题寻求一名斯特林热机技术顾问需求主题寻求一名斯特林热机技术顾问需求主题寻求一名斯特林热机技术顾问</p>
187
										<div class="flexCenter qa-owner">
188
										<div class="owner-head useHead"></div>
189
										<div class="owner-info">
190
										<div class="owner-name"><span class="h1Font">张某某</span><em class="authicon authicon-pro" title="科袖认证专家"></em></div>
191
										<div class="owner-tit mui-ellipsis h2Font">职称/职位,所在机构职称/职位,所在机构职称/职位,所在机构</div>
192
										</div>
193
										</div>
194
										<p class="qa-con mui-ellipsis-5">需求内容:我们是一家医疗器械公司,主要生产健康理疗类的电子产品,目前希望对护膝、护腰类的产品进行改进, 想先找一位有资深设计经验的三维工业设计专家,通过三维建模的方式先设计出产品的三维模型,用于展示以及为后续生产做准备我们是一家医疗器械公司,主要生产健康理疗类的电子产品,目前希望对护膝、护腰类的产品进行改进, 想先找一位有资深设计经验的三维工业设计专家,通过三维建模的方式先设计出
195
										</p>
196
										<div class="showli mui-ellipsis">
197
										<span>5月8日 18:00</span>
198
										<span>N 赞</span>
199
										<span>N 留言</span>
200
										</div>
201
										</div>
202
										</li>-->
203 184
									</ul>
204 185
									<div class="nodatabox displayNone">
205 186
										<div class="nodata">

+ 0 - 18
app/html/qa-question-show.html

@ -55,24 +55,6 @@
55 55
										</div>
56 56
										<div class="list-hold-list">
57 57
											<ul class="mui-table-view myAllneeds partLine" id="curAnswers">
58
												<!--<li class="mui-table-view-cell">
59
													<div class="madiaInfo">
60
														<div class="flexCenter qa-owner">
61
															<div class="owner-head useHead"></div>
62
															<div class="owner-info">
63
																<div class="owner-name"><span class="h1Font">张某某</span><em class="authicon authicon-pro" title="科袖认证专家"></em></div>
64
																<div class="owner-tit mui-ellipsis h2Font">职称/职位,所在机构职称/职位,所在机构职称/职位,所在机构</div>
65
															</div>
66
														</div>
67
														<p class="qa-con mui-ellipsis-5">我们是一家医疗器械公司,主要生产健康理疗类的电子产品,目前希望对护膝、护腰类的产品进行改进, 想先找一位有资深设计经验的三维工业设计专家,通过三维建模的方式先设计出产品的三维模型,用于展示以及为后续生产做准备我们是一家医疗器械公司,主要生产健康理疗类的电子产品,目前希望对护膝、护腰类的产品进行改进, 想先找一位有资深设计经验的三维工业设计专家,通过三维建模的方式先设计出
68
														</p>
69
														<div class="showli mui-ellipsis">
70
															<span>5月8日 18:00</span>
71
															<span>N 赞</span>
72
															<span>N 留言</span>
73
														</div>
74
													</div>
75
												</li>-->
76 58
											</ul>
77 59
										</div>
78 60
									</section>

+ 1 - 1
app/js/discoverNew.js

@ -722,7 +722,7 @@
722 722
							liStr.innerHTML = '<div class="madiaInfo">' +
723 723
								'<p class="h1Font mui-ellipsis-2 qa-question"></p>'+
724 724
								'<div class="flexCenter qa-owner"></div>' +
725
								'<p class="qa-con mui-ellipsis-5">' + ($data[i].cnt).replace(/\n/g,"<br />") + '</p>' +
725
								'<div class="qa-con mui-ellipsis-5">' + listConCut($data[i].cnt) + '</div>' +
726 726
								'<div class="showliSpan mui-ellipsis">' +
727 727
								'<span>' + commenTime($data[i].createTime) + '</span>' + hd + '<span class="leaveMsgCount"></span>' +
728 728
								'</div>' +

+ 14 - 8
app/js/moreItem.js

@ -130,14 +130,20 @@ mui.ready(function(){
130 130
			})
131 131
		})
132 132
		document.getElementById("corrAnswer").addEventListener('tap',function(){
133
			plus.nativeUI.showWaiting(); //显示原生等待框
134
			var webviewShow = plus.webview.create("../html/qa-answer-q.html", 'qa-answer-q.html', {}, {
135
				aflag:1,
136
				anid: self.proid,
137
				quid: self.quid,
138
				qutit:self.data.title,
139
				qucnt:self.data.content
140
			})
133
			console.log(JSON.stringify(checkHtmltag(self.data.content)))
134
			if(!checkHtmltag(self.data.content)){
135
				plus.nativeUI.showWaiting(); //显示原生等待框
136
				var webviewShow = plus.webview.create("../html/qa-answer-q.html", 'qa-answer-q.html', {}, {
137
					aflag:1,
138
					anid: self.proid,
139
					quid: self.quid,
140
					qutit:self.data.title,
141
					qucnt:self.data.content
142
				})
143
			}else{
144
				plus.nativeUI.toast("该回答中包含html不能修改,如需修改,请移步科袖网站", toastStyle);
145
			}
146
			
141 147
		})
142 148
		document.getElementsByClassName("exitbtn")[0].addEventListener("tap",function(){
143 149
			var bts = ["是", "否"];

+ 8 - 0
app/js/public/base.js

@ -166,6 +166,14 @@ function shareAddIntegral(num) {
166 166
	});
167 167
}
168 168

169
function listConCut(str){//**回答内容过滤html标签**//
170
	var regTag =/<\/?[a-zA-Z]+[^><]*?>/g;
171
	var strTo=str.replace(/<img(.*?)>/g, "[图片]").replace(regTag,"")
172
	return strTo
173
}
174
function checkHtmltag(htmlStr) {/*字符串是否含有html标签的检测*/
175
    return htmlStr.substr(0,1)=="<"
176
}
169 177
//时间显示规则
170 178
function commenTime(startTime){
171 179
	var nowTimg =  new Date();

+ 6 - 3
app/js/qa-answer-q.js

@ -16,17 +16,19 @@ mui.ready(function(){
16 16
		if(aflag){
17 17
			var anid=self.anid,
18 18
				qucnt=self.qucnt;
19
			document.getElementById("question").value=qucnt
19
			document.getElementById("question").innerHTML=qucnt
20 20
			var con=document.getElementById("question")
21 21
			document.getElementsByClassName("topsave")[0].addEventListener("tap",function(){
22 22
				if(con.value.length<10) {
23 23
					plus.nativeUI.toast("回答不得少于10个字");
24 24
					return;
25 25
				}
26
				var lgCon=con.value.replace(/\>/g,"&gt;").replace(/\</g,"&lt;")
27
				
26 28
				mui.ajax(baseUrl + '/ajax/question/answer/modify', {
27 29
					data: {
28 30
						"id": anid,
29
						"cnt": con.value,
31
						"cnt": lgCon,
30 32
						"uid": userid,
31 33
						"uname": username
32 34
					},
@ -49,10 +51,11 @@ mui.ready(function(){
49 51
					plus.nativeUI.toast("回答不得少于10个字");
50 52
					return;
51 53
				}
54
				var lgCon=con.value.replace(/\>/g,"&gt;").replace(/\</g,"&lt;")
52 55
				mui.ajax(baseUrl + '/ajax/question/answer', {
53 56
					data: {
54 57
						"qid": quid,
55
						"cnt": con.value,
58
						"cnt": lgCon,
56 59
						"uid": userid,
57 60
						"uname": username
58 61
					},

+ 13 - 2
app/js/qa-answer-show.js

@ -16,6 +16,10 @@ mui.ready(function() {
16 16
		var flag=0;
17 17
		var answerTit=""
18 18
		var oUrl = baseUrl + "/images/logo180.png";
19
		
20
		mui('#answerCnt').on('tap','a',function(){
21
			plus.runtime.openURL( this.href);
22
		});
19 23
		wlog("answer",answerId,"2");
20 24
		
21 25
		var oAjax = function(url, dataS, otype, oFun) {
@ -44,7 +48,14 @@ mui.ready(function() {
44 48
					
45 49
					if($da.cnt) {
46 50
						answerTit=$da.cnt
47
						document.getElementById("answerCnt").innerHTML = ($da.cnt).replace(/\n/g,"<br />");
51
						document.getElementById("answerCnt").innerHTML = $da.cnt;
52
						var oImg = document.getElementById("answerCnt").getElementsByTagName("img");
53
						for(var i = 0; i < oImg.length; i++) {
54
							(function(n) {
55
								var att = oImg[n].src.substr(7);
56
								oImg[n].setAttribute("src", baseUrl + att);
57
							})(i);
58
						}
48 59
					}
49 60
					if(userid != $da.uid) {
50 61
						ownerid = $da.uid
@ -144,7 +155,7 @@ mui.ready(function() {
144 155
						flag:flag,
145 156
						name: "answer",
146 157
						data: {
147
							content: answerTit.substring(0, 70),
158
							content: answerTit,
148 159
							title: document.getElementById("questTit").innerHTML,
149 160
							href: baseUrl + "/e/da.html?id=" + answerId,
150 161
							thumbs: [oUrl]

+ 1 - 1
app/js/qa-my-wenda.js

@ -276,7 +276,7 @@ mui.ready(function () {
276 276
                liStr.innerHTML = '<div class="madiaInfo">' +
277 277
                    '<p class="h1Font mui-ellipsis-2 qa-question"></p>' +
278 278
                    '<div class="flexCenter qa-owner"></div>' +
279
                    '<p class="qa-con mui-ellipsis-5">' + (dataStr.cnt).replace(/\n/g,"<br />") + '</p>' +
279
                    '<div class="qa-con mui-ellipsis-5">' + listConCut(dataStr.cnt) + '</div>' +
280 280
                    '<div class="showliSpan mui-ellipsis">' +
281 281
                    '<span>' + commenTime(dataStr.createTime) + '</span>' + hd +'<span class="leaveMsgCount"></span>'+
282 282
                    '</div>' +

+ 9 - 6
app/js/qa-question-show.js

@ -13,7 +13,8 @@ mui.ready(function() {
13 13
		dataO = {
14 14
			time: "",
15 15
			id: "",
16
			score:""
16
			score:"",
17
			agree:""
17 18
		};
18 19
	var oUrl = baseUrl + "/images/logo180.png";
19 20
	var userid, questionId ,pkey=[],byway;
@ -54,7 +55,7 @@ mui.ready(function() {
54 55
							setTimeout(function() {
55 56
								getConmain();
56 57
								document.getElementById("curAnswers").innerHTML = "";
57
								dataO = {time: "",id: "",score:""}
58
								dataO = {time: "",id: "",score:"",agree:""}
58 59
								answerList();
59 60
								if(userid && userid != null && userid != "null") {
60 61
									anExist();
@ -75,7 +76,7 @@ mui.ready(function() {
75 76
					document.getElementById("questionTime").innerHTML = commenTime($da.createTime);
76 77
					document.getElementById("replyCount").innerHTML = $da.replyCount;
77 78
					if($da.cnt) {
78
						document.getElementById("questionCnt").innerHTML =($da.cnt).replace(/\n/g,"<br />");
79
						document.getElementById("questionCnt").innerHTML =$da.cnt.replace(/\n/g,"<br />");
79 80
					}
80 81
					if($da.keys != undefined && $da.keys.length != 0) {
81 82
						var subs = new Array();
@ -146,6 +147,7 @@ mui.ready(function() {
146 147
					dataStr={
147 148
						"qid": questionId,
148 149
						"score": dataO.score,
150
						"agree":dataO.agree,
149 151
						"id": dataO.id,
150 152
						"rows": rows
151 153
					}
@ -169,6 +171,7 @@ mui.ready(function() {
169 171
					if($info.length > 0) {
170 172
						if(byway == 1) {
171 173
							dataO.score = $info[$info.length - 1].score;
174
							dataO.agree = $info[$info.length - 1].agree;
172 175
							dataO.id = $info[$info.length - 1].id;
173 176
						}else if(byway == 2) {
174 177
							dataO.time = $info[$info.length - 1].createTime;
@ -226,7 +229,7 @@ mui.ready(function() {
226 229
				liStr.className = "mui-table-view-cell";
227 230
				liStr.innerHTML = '<div class="madiaInfo">' +
228 231
					'<div class="flexCenter qa-owner"></div>' +
229
					'<p class="qa-con mui-ellipsis-5">' + (dataStr.cnt).replace(/\n/g,"<br />") + '</p>' +
232
					'<div class="qa-con mui-ellipsis-5">' + listConCut(dataStr.cnt)  + '</div>' +
230 233
					'<div class="showliSpan mui-ellipsis">' +
231 234
					'<span>' + commenTime(dataStr.createTime) + '</span>' + hd + '<span class="leaveMsgCount"></span>' +
232 235
					'</div>' +
@ -356,7 +359,7 @@ mui.ready(function() {
356 359
			this.classList.add('active');
357 360
			byway = this.getAttribute("data-type");
358 361
			document.getElementById("curAnswers").innerHTML = "";
359
			dataO = {time: "",id: "",score:""}
362
			dataO = {time: "",id: "",score:"",agree:""}
360 363
			if(typeof(pkey)==undefined){
361 364
				pkey=[]
362 365
			}else{
@ -403,7 +406,7 @@ mui.ready(function() {
403 406
		window.addEventListener('afterAnswer', function(event) {
404 407
			questionId=event.detail.quid
405 408
			document.getElementById("curAnswers").innerHTML = "";
406
			dataO = {time: "",id: "",score:""}
409
			dataO = {time: "",id: "",score:"",agree:""}
407 410
			anExist();
408 411
			answerList();
409 412
			getConmain();