绑定提交改为ajax
This commit is contained in:
parent
a59f65a455
commit
509d4a3df7
|
@ -1,5 +1,5 @@
|
|||
class WechatsController < ActionController::Base
|
||||
layout 'wechat/layout'
|
||||
layout 'base_wechat'
|
||||
|
||||
wechat_responder
|
||||
|
||||
|
@ -179,9 +179,9 @@ class WechatsController < ActionController::Base
|
|||
uw = UserWechat.find_by_id(params[:state])
|
||||
uw.user_id = user.id
|
||||
uw.save!
|
||||
render :text => {status:0, msg: "绑定成功"}
|
||||
render :text => {status:0, msg: "绑定成功"}.to_json
|
||||
rescue Exception=>e
|
||||
render :text => {status: -1, msg: e.message}
|
||||
render :text => {status: -1, msg: e.message}.to_json
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
<title>绑定用户</title>
|
||||
<link rel="stylesheet" href="/stylesheets/weui/weui.min.css"/>
|
||||
<script src="/javascripts/jquery.min.js"></script>
|
||||
<script src="/javascripts/wechat/alert.js"></script>
|
||||
</head>
|
||||
|
||||
<%= yield %>
|
|
@ -50,9 +50,17 @@
|
|||
type: "POST",
|
||||
url: $("#main_login_form").attr("action"),
|
||||
data:data,
|
||||
dataType: "json"
|
||||
}).done(function(data){
|
||||
|
||||
dataType: 'json',
|
||||
success: function(data){
|
||||
console.log(data);
|
||||
if(data.status == 0){
|
||||
byConfirm(data.msg, function(){
|
||||
window.closeWindow();
|
||||
});
|
||||
} else {
|
||||
byAlert(data.msg, "绑定失败");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
|
|
|
@ -35,4 +35,9 @@ $(function(){
|
|||
$dialog.hide();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
window.closeWindow = function(){
|
||||
WeixinJSBridge.call('closeWindow');
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue