加入openid传参

chenlw_dev
guange 9 years ago
parent a6a0681b78
commit 58c1b27600

@ -11,11 +11,12 @@ module Mobile
params do params do
requires :type, type: String requires :type, type: String
requires :content, type: String requires :content, type: String
requires :openid, type: String
end end
post ':id' do post ':id' do
type = params[:type] type = params[:type]
result = 1 result = 1
current_user = User.find 8686 current_user = UserWechat.find_by_openid(params[:openid]).user
if params[:content]!="" && current_user if params[:content]!="" && current_user
case type case type
when "HomeworkCommon" when "HomeworkCommon"

@ -68,23 +68,26 @@ $(document).ready(function(){
replyNum++; replyNum++;
$(".reply-num").text("(" + replyNum + ")"); $(".reply-num").text("(" + replyNum + ")");
//获取并传送回复用户数据 getOpenId(function(openid) {
var userInfo = { //获取并传送回复用户数据
"type" : "HomeworkCommon", var userInfo = {
"content" : postInput "type": "HomeworkCommon",
}; "content": postInput,
openid: openid
$.ajax({ };
type: "POST", //提交方式
dataType: "json", //类型 $.ajax({
url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 type: "POST", //提交方式
data: userInfo, //参数如果没有可以为null dataType: "json", //类型
success: function (data) { //如果执行成功,那么执行此方法 url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名
setReplyTemplate(data.data); data: userInfo, //参数如果没有可以为null
}, success: function (data) { //如果执行成功,那么执行此方法
error: function (err) { //如果执行不成功,那么执行此方法 setReplyTemplate(data.data);
alert("err:" + err); },
} error: function (err) { //如果执行不成功,那么执行此方法
alert("err:" + err);
}
})
}); });
} }

@ -72,23 +72,26 @@ $(document).ready(function(){
replyNum++; replyNum++;
$(".reply-num").text("(" + replyNum + ")"); $(".reply-num").text("(" + replyNum + ")");
//获取并传送回复用户数据 getOpenId(function(openid) {
var userInfo = { //获取并传送回复用户数据
"type" : "Issue", var userInfo = {
"content" : postInput "type": "Issue",
}; "content": postInput,
openid: openid,
$.ajax({ };
type: "POST", //提交方式
dataType: "json", //类型 $.ajax({
url: apiUrl + 'new_comment/' + IssueID, //提交的页面,方法名 type: "POST", //提交方式
data: userInfo, //参数如果没有可以为null dataType: "json", //类型
success: function (data) { //如果执行成功,那么执行此方法 url: apiUrl + 'new_comment/' + IssueID, //提交的页面,方法名
setReplyTemplate(data.data); data: userInfo, //参数如果没有可以为null
}, success: function (data) { //如果执行成功,那么执行此方法
error: function (err) { //如果执行不成功,那么执行此方法 setReplyTemplate(data.data);
alert("err:" + err); },
} error: function (err) { //如果执行不成功,那么执行此方法
alert("err:" + err);
}
})
}); });
} }

Loading…
Cancel
Save