Parcourir la Source

问题回答状态改变

luyanan 7 ans auparavant
Parent
commit
6d4468fe2d
5 fichiers modifiés avec 87 ajouts et 71 suppressions
  1. 1 1
      app/html/qa-answer-q.html
  2. 4 1
      app/js/moreItem.js
  3. 30 28
      app/js/qa-my-wendaTT.js
  4. 51 40
      app/js/qa-question-show.js
  5. 1 1
      app/js/qa-waiting-a.js

+ 1 - 1
app/html/qa-answer-q.html

@ -21,7 +21,7 @@
21 21
		    <span class="mui-pull-right topsave">发布</span>
22 22
		</header>
23 23
		<div class="mui-content">
24
			<div class="littip-top">使用电脑登录科袖网 www.ekexiu.com<br />可以获得更好的回答体验</div>
24
			<!--<div class="littip-top">使用电脑登录科袖网 www.ekexiu.com<br />可以获得更好的回答体验</div>-->
25 25
			<div class="mui-input-group mainbox" style="height: 80%;">
26 26
				<div class="infocon" style="height:100%;">
27 27
					<textarea class="textareabox simulation" style="height:100%;" id="question" placeholder="请填写回答内容"></textarea>

+ 4 - 1
app/js/moreItem.js

@ -145,7 +145,10 @@ mui.ready(function(){
145 145
				var i = e.index;
146 146
				if(i == 0) {
147 147
					mui.ajax(baseUrl + "/ajax/question/answer/delete", {
148
						data: {id:self.proid},
148
						data: {
149
							id:self.proid,
150
							qid:self.quid
151
						},
149 152
						dataType: 'json',
150 153
						type: 'get',
151 154
						success: function(data) {

+ 30 - 28
app/js/qa-my-wendaTT.js

@ -91,34 +91,36 @@ mui.ready(function () {
91 91
                        currentSelf = mui(pullRefreshEl).pullToRefresh({
92 92
                            up: {
93 93
                                callback: function () {
94
                                    setTimeout(function () {
95
                                        if (index == 2) {
96
                                            var rs = {
97
                                                "professorId": userid,
98
                                                "watchType": 1,
99
                                                "pageSize": pageSize,
100
                                                "pageNo": ++pageNo
101
                                            };
102
                                            oAjaxGet(url, rs, "get", oWatchPro);
103
                                        } else {
104
                                            var rs = {
105
                                                "uid": userid,
106
                                                "rows": rows,
107
                                                "time": dataO.time,
108
                                                "id": dataO.id
109
                                            };
110
                                            if (index == 0) {
111
                                                oAjaxGet(url, rs, "get", oMyQ);
112
                                            } else if (index == 1) {
113
                                                oAjaxGet(url, rs, "get", oMyA);
114
                                            } else if (index == 3) {
115
                                                oAjaxGet(url, rs, "get", oWatchQ);
116
                                            } else if (index == 4) {
117
                                                oAjaxGet(url, rs, "get", oWatchA);
118
                                            }
119
                                        }
120
                                        // currentSelf.endPullUpToRefresh()
121
                                    }, 1000);
94
                                	if(currentSelf.loading){
95
	                                    setTimeout(function () {
96
	                                        if (index == 2) {
97
	                                            var rs = {
98
	                                                "professorId": userid,
99
	                                                "watchType": 1,
100
	                                                "pageSize": pageSize,
101
	                                                "pageNo": ++pageNo
102
	                                            };
103
	                                            oAjaxGet(url, rs, "get", oWatchPro);
104
	                                        } else {
105
	                                            var rs = {
106
	                                                "uid": userid,
107
	                                                "rows": rows,
108
	                                                "time": dataO.time,
109
	                                                "id": dataO.id
110
	                                            };
111
	                                            if (index == 0) {
112
	                                                oAjaxGet(url, rs, "get", oMyQ);
113
	                                            } else if (index == 1) {
114
	                                                oAjaxGet(url, rs, "get", oMyA);
115
	                                            } else if (index == 3) {
116
	                                                oAjaxGet(url, rs, "get", oWatchQ);
117
	                                            } else if (index == 4) {
118
	                                                oAjaxGet(url, rs, "get", oWatchA);
119
	                                            }
120
	                                        }
121
	                                        // currentSelf.endPullUpToRefresh()
122
	                                    }, 1000);
123
                                    }
122 124
                                }
123 125
                            }
124 126
                        });

+ 51 - 40
app/js/qa-question-show.js

@ -54,11 +54,6 @@ mui.ready(function() {
54 54
								getConmain();
55 55
								document.getElementById("curAnswers").innerHTML = "";
56 56
								dataO = {time: "",id: "",score:""}
57
								if(typeof(pkey)==undefined){
58
									pkey=[]
59
								}else{
60
									pkey.refresh(true)
61
								}
62 57
								answerList();
63 58
								if(userid && userid != null && userid != "null") {
64 59
									anExist();
@ -120,15 +115,21 @@ mui.ready(function() {
120 115
				})
121 116
			},
122 117
			anExist = function() {
123
				oAjax("/ajax/question/answer/exists", {
118
				oAjax("/ajax/question/answer", {
124 119
					"qid": questionId,
125 120
					"uid": userid,
126 121
				}, "get", function(res) {
127 122
					console.log(JSON.stringify(res))
128 123
					if(res.data) {
129
						oanswer.setAttribute("data-can", ""); //回答过
130
						oanswer.classList.add("answered");
131
						oanswer.querySelector("span").innerText = "您已回答"
124
						if(res.data.state=="1"){
125
							oanswer.setAttribute("data-can", "0"); //回答过
126
							oanswer.classList.add("answered");
127
							oanswer.querySelector("span").innerText = "您已回答"
128
						}else{
129
							oanswer.setAttribute("data-anid",res.data.id);
130
							oanswer.setAttribute("data-can", "2"); //回答过但已删除
131
							oanswer.querySelector("span").innerText = "撤销删除"
132
						}
132 133
					} else {
133 134
						oanswer.setAttribute("data-can", "1");
134 135
					}
@ -158,19 +159,11 @@ mui.ready(function() {
158 159
					console.log(JSON.stringify(res))
159 160
					var aimId="curAnswers",newStr="暂无回答"
160 161
					var $info = res.data;
161
					if(!ifkong) {
162
						removeAfter(aimId)
163
					}
164
					if($info.length == 0 && ifkong && ifAl) {
165
						insertAfter(newStr, aimId);
166
						ifkong = 0
167
					}
168 162
					if(ifAl) {
169 163
						pullEvent()
170 164
						ifAl = 0;
171 165
					}
172 166
					if($info.length > 0) {
173
						removeAfter(aimId)
174 167
						if(byway == 1) {
175 168
							dataO.score = $info[$info.length - 1].score;
176 169
							dataO.id = $info[$info.length - 1].id;
@ -191,30 +184,35 @@ mui.ready(function() {
191 184
						}
192 185
					} else {
193 186
						pkey.endPullUpToRefresh(true)
194
						return;
195 187
					}
188
					var liLen=document.getElementById(aimId).querySelectorAll("li").length;
189
	                removeAfter(aimId);
190
	                if($info.length == 0 && liLen == 0 ){
191
	                    insertAfter(newStr,aimId);
192
	                }
196 193
				})
197 194
			},
198
			insertAfter=function(newStr, targetE){
199
			    var parent = document.getElementById(targetE).parentNode;
200
			    var kong = document.createElement("div");
201
			   		kong.className="con-kong";
202
			   		kong.innerHTML=newStr;
203
			   	if(parent.lastChild.className == "con-kong"){
204
			        return
205
			   	}else{
206
			        parent.insertBefore( kong, document.getElementById(targetE).nextSibling );
207
			   	}
208
			    
209
			},
210
			removeAfter=function(targetE){
211
				var parent = document.getElementById(targetE).parentNode;
212
				if(parent.lastChild.className == "con-kong"){
213
			   		parent.removeChild(parent.querySelector(".con-kong"));
214
			   	}else{
215
			        return
216
			   	}
217
			},
195
			insertAfter = function (newStr, targetE) {
196
                var parent = document.getElementById(targetE).parentNode;
197
                var kong = document.createElement("div");
198
                kong.className = "con-kong";
199
                kong.innerHTML = newStr;
200
                if (parent.firstChild.className == "con-kong") {
201
                    return
202
                } else {
203
                    parent.insertBefore(kong,parent.firstChild);
204
                }
205
206
            },
207
            removeAfter = function (targetE) {
208
                var parent = document.getElementById(targetE).parentNode;
209
                console.log(parent.firstChild.className);
210
                if (parent.firstChild.className == "con-kong") {
211
                    parent.removeChild(parent.firstChild);
212
                } else {
213
                    return
214
                }
215
            },
218 216
			answerModule = function(dataStr, liStr) {
219 217
				var hd = "",
220 218
					hl = "";
@ -363,14 +361,27 @@ mui.ready(function() {
363 361
		oanswer.addEventListener('tap', function() {
364 362
			var can = this.getAttribute("data-can");
365 363
			if(userid && userid != null && userid != "null") {
366
				if(can) {
364
				if(can=="1") {
367 365
					plus.nativeUI.showWaiting();
368 366
					plus.webview.create("../html/qa-answer-q.html", 'qa-answer-q.html', {}, {
369 367
						"aflag":0,
370 368
						"quid": questionId,
371 369
						"qutit":document.getElementById("questionTit").innerHTML
372 370
					});
373
				} else {
371
				} else if(can=="2") {
372
					var anid= this.getAttribute("data-anid");
373
					oAjax("/ajax/question/answer/unDel", {
374
						"qid": questionId,
375
						"id": anid,
376
					}, "get", function(res) {
377
						console.log(JSON.stringify(res))
378
						if(res.data=="1") {
379
							oanswer.setAttribute("data-can", "0"); //回答过
380
							oanswer.classList.add("answered");
381
							oanswer.querySelector("span").innerText = "您已回答"
382
						}
383
					})
384
				}else{
374 385
					return
375 386
				}
376 387
			} else {

+ 1 - 1
app/js/qa-waiting-a.js

@ -23,7 +23,7 @@ mui.ready(function() {
23 23
				data: dataS,
24 24
				success: function(res) {
25 25
					if(res.success) {
26
						console.log(JSON.stringify(res))
26
						//console.log(JSON.stringify(res))
27 27
						oFun(res)
28 28
					}
29 29
				}