Browse Source

发送留言

XMTT 7 years ago
parent
commit
f1ec0ad29a
2 changed files with 113 additions and 33 deletions
  1. 50 12
      js/answerLeaveW.js
  2. 63 21
      js/leaveWord.js

+ 50 - 12
js/answerLeaveW.js

@ -140,18 +140,56 @@
140 140
		if(!self.size.call($($this).siblings(".msgContbox").find("textarea")) ){
141 141
			return;
142 142
		}
143
		ajaxRequist("/ajax/leavemsg", {
144
			cnt: $($this).siblings(".msgContbox").find("textarea").val(),
145
			refId: $($this).data("ouse").sid,
146
			refType: $($this).data("ouse").stype,
147
			sender: $.cookie('userid'),
148
			uname: $.cookie('userName')
149
		}, "POST", function(data) {
150
			$($this).siblings(".msgContbox").find("textarea").val("").siblings(".msgconNum").find("em").text(0);
151
			ajaxRequist("/ajax/leavemsg/qo", {id:data},"GET",function(data) {
152
				self.topHtml($($this).parents(".ifLogin").siblings(".commentsArea").find("ul"),[data])
153
			})
154
		})
143
        $.ajax({
144
            url:"/ajax/leavemsg",
145
            data: {
146
                cnt: $($this).siblings(".msgContbox").find("textarea").val(),
147
                refId: $($this).data("ouse").sid,
148
                refType: $($this).data("ouse").stype,
149
                sender: $.cookie('userid'),
150
                uname: $.cookie('userName')
151
            },
152
            dataType: 'json', //服务器返回json格式数据
153
            type: "POST",
154
            beforeSend: function() {
155
                // $(".table-body").append('<img src="../images/loading.gif" class="loading" />');
156
                $(".list-hold-list").off("click");
157
            },
158
            complete:function () {
159
                $(".list-hold-list").on('click',".ifLogin input",function() {
160
                    if(!lgin()) {
161
                        return;
162
                    }
163
                    self.topLw(this);
164
                    self.LwordTotal($(this),$(this).data("ouse"));
165
                });
166
            },
167
            traditional: true,
168
            success: function (data) {
169
                if (data.success) {
170
                    $($this).siblings(".msgContbox").find("textarea").val("").siblings(".msgconNum").find("em").text(0);
171
                    ajaxRequist("/ajax/leavemsg/qo", {id: data.data}, "GET", function (data) {
172
                        self.topHtml($($this).parents(".ifLogin").siblings(".commentsArea").find("ul"), data)
173
                    })
174
                }
175
            },
176
            error: function(xhr, type, errorThrown) {
177
                $.MsgBox.Alert('提示', '服务器请求失败');
178
            }
179
        });
180

181
		// ajaxRequist("/ajax/leavemsg", {
182
		// 	cnt: $($this).siblings(".msgContbox").find("textarea").val(),
183
		// 	refId: $($this).data("ouse").sid,
184
		// 	refType: $($this).data("ouse").stype,
185
		// 	sender: $.cookie('userid'),
186
		// 	uname: $.cookie('userName')
187
		// }, "POST", function(data) {
188
		// 	$($this).siblings(".msgContbox").find("textarea").val("").siblings(".msgconNum").find("em").text(0);
189
		// 	ajaxRequist("/ajax/leavemsg/qo", {id:data},"GET",function(data) {
190
		// 		self.topHtml($($this).parents(".ifLogin").siblings(".commentsArea").find("ul"),[data])
191
		// 	})
192
		// })
155 193
	}
156 194
	LeaveWord.prototype.autoGrow=function(){
157 195
		document.getElementById("tt").style.width=this.scrollWidth+"px";

+ 63 - 21
js/leaveWord.js

@ -109,24 +109,66 @@
109 109
		if(!self.size.call($(".msgCont")) ){
110 110
			return;
111 111
		}
112
		ajaxRequist("/ajax/leavemsg", {
113
			cnt: $(".msgCont").val(),
114
			refId: self.sid,
115
			refType: self.stype,
116
			sender: $.cookie('userid'),
117
			uname: $.cookie('userName')
118
		}, "POST", function() {
119
			$(".msgCont").val("");
120
			if(self.id) {
121
				delete self.id;
122
				delete self.time;
123
			}
124
			self.init({
125
				sid: self.sid,
126
				stype: self.stype,
127
				rows: 5
128
			});
129
		})
112
        $.ajax({
113
            url:"/ajax/leavemsg",
114
            data: {
115
                cnt: $(".msgCont").val(),
116
                refId: self.sid,
117
                refType: self.stype,
118
                sender: $.cookie('userid'),
119
                uname: $.cookie('userName')
120
			},
121
            dataType: 'json', //服务器返回json格式数据
122
            type: "POST",
123
            beforeSend: function() {
124
                // $(".table-body").append('<img src="../images/loading.gif" class="loading" />');
125
                $("#meSendtt").off("click");
126
            },
127
            complete:function () {
128
                $("#meSendtt").click(function() {
129
                    if(!lgin()) {
130
                        return;
131
                    }
132
                    self.topLw();
133
                });
134
            },
135
            traditional: true,
136
            success: function (data) {
137
                if (data.success) {
138
                    $(".msgCont").val("");
139
                    if (self.id) {
140
                        delete self.id;
141
                        delete self.time;
142
                    }
143
                    self.init({
144
                        sid: self.sid,
145
                        stype: self.stype,
146
                        rows: 5
147
                    });
148
                }
149
            },
150
            error: function(xhr, type, errorThrown) {
151
                $.MsgBox.Alert('提示', '服务器请求失败');
152
            }
153
        });
154
		// ajaxRequist("/ajax/leavemsg", {
155
		// 	cnt: $(".msgCont").val(),
156
		// 	refId: self.sid,
157
		// 	refType: self.stype,
158
		// 	sender: $.cookie('userid'),
159
		// 	uname: $.cookie('userName')
160
		// }, "POST", function() {
161
		// 	$(".msgCont").val("");
162
		// 	if(self.id) {
163
		// 		delete self.id;
164
		// 		delete self.time;
165
		// 	}
166
		// 	self.init({
167
		// 		sid: self.sid,
168
		// 		stype: self.stype,
169
		// 		rows: 5
170
		// 	});
171
		// })
130 172
	}
131 173
	LeaveWord.prototype.autoGrow=function(){
132 174
		document.getElementById("tt").style.width=this.scrollWidth+"px";
@ -147,8 +189,8 @@
147 189
			}
148 190
			var obj=JSON.parse($(this).attr("data-obj")),
149 191
			target=e.target;
150
			switch (target.className){
151
				case "dzthumb":self.thub.call(target, obj.id,obj.agreeCount);
192
			switch (target.className){
193
				case "dzthumb":self.thub.call(target, obj.id,obj.agreeCount);
152 194
					break;
153 195
				case "callBack":$(target).parents(".operateSpan").addClass("displayNone").siblings(".replyLeword").removeClass("displayNone");
154 196
					break;
@ -157,7 +199,7 @@
157 199
				case "hReply btnModel":self.replyLword(target,obj.id)
158 200
					break;
159 201
				case "qCancel": $(target).parent().siblings("textarea").val("").parents(".replyLeword").addClass("displayNone").siblings(".operateSpan").removeClass("displayNone")
160
					break;
202
					break;
161 203
			}
162 204
		});
163 205
		$(".msgCont").on("input",function(){