优化界面交互

pull/25/merge
Minho 2017-05-10 15:42:37 +08:00
parent 42b08a0b18
commit fa20dad73f
1 changed files with 186 additions and 170 deletions

View File

@ -133,9 +133,9 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{{template "widgets/footer.tpl" .}} {{template "widgets/footer.tpl" .}}
</div> </div>
<!-- Modal --> <!-- Modal -->
<div class="modal fade" id="changePrivatelyOwnedModal" tabindex="-1" role="dialog" aria-labelledby="changePrivatelyOwnedModalLabel"> <div class="modal fade" id="changePrivatelyOwnedModal" tabindex="-1" role="dialog" aria-labelledby="changePrivatelyOwnedModalLabel">
@ -168,7 +168,7 @@
<div class="modal-footer"> <div class="modal-footer">
<span class="error-message" id="form-error-message1"></span> <span class="error-message" id="form-error-message1"></span>
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button> <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="submit" class="btn btn-primary">确定</button> <button type="submit" class="btn btn-primary" data-loading-text="变更中..." id="btnChangePrivatelyOwned">确定</button>
</div> </div>
</div> </div>
</form> </form>
@ -229,7 +229,7 @@
<div class="modal-footer"> <div class="modal-footer">
<span id="form-error-message2" class="error-message"></span> <span id="form-error-message2" class="error-message"></span>
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button> <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="submit" id="btnDeleteBook" class="btn btn-primary">确定删除</button> <button type="submit" id="btnDeleteBook" class="btn btn-primary" data-loading-text="删除中...">确定删除</button>
</div> </div>
</div> </div>
</form> </form>
@ -255,6 +255,7 @@
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<span id="form-error-message3" class="error-message"></span>
<button type="button" class="btn btn-default" data-dismiss="modal">取消</button> <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
<button type="submit" id="btnTransferBook" class="btn btn-primary">确定转让</button> <button type="submit" id="btnTransferBook" class="btn btn-primary">确定转让</button>
</div> </div>
@ -278,16 +279,24 @@
}); });
$("#changePrivatelyOwnedForm").ajaxForm({ $("#changePrivatelyOwnedForm").ajaxForm({
beforeSubmit :function () {
$("#btnChangePrivatelyOwned").button("loading");
},
success :function (res) { success :function (res) {
if(res.errcode === 0){ if(res.errcode === 0){
window.location = window.location.href; window.location = window.location.href;
return;
}else{ }else{
console.log(res.message)
showError(res.message,"#form-error-message1"); showError(res.message,"#form-error-message1");
} }
$("#btnChangePrivatelyOwned").button("reset");
},
error :function () {
showError("服务器异常","#form-error-message1");
$("#btnChangePrivatelyOwned").button("reset");
} }
}); });
$("#createToken,#deleteToken").on("click",function () { $("#createToken,#deleteToken").on("click",function () {
var btn = $(this).button("loading"); var btn = $(this).button("loading");
var action = $(this).attr("data-action"); var action = $(this).attr("data-action");
@ -335,20 +344,27 @@
} }
}); });
$("#deleteBookForm").ajaxForm({ $("#deleteBookForm").ajaxForm({
beforeSubmit : function () {
$("#btnDeleteBook").button("loading");
},
success : function (res) { success : function (res) {
if(res.errcode === 0){ if(res.errcode === 0){
window.location = "{{urlfor "BookController.Index"}}"; window.location = "{{urlfor "BookController.Index"}}";
}else{ }else{
console.log(res.message)
showError(res.message,"#form-error-message2"); showError(res.message,"#form-error-message2");
} }
$("#btnDeleteBook").button("reset");
},
error : function () {
showError("服务器异常","#form-error-message2");
$("#btnDeleteBook").button("reset");
} }
}); });
$("#transferBookForm").ajaxForm({ $("#transferBookForm").ajaxForm({
beforeSubmit : function () { beforeSubmit : function () {
var account = $.trim($("#receiveAccount").val()); var account = $.trim($("#receiveAccount").val());
if (account === ""){ if (account === ""){
return showError("接受者账号不能为空") return showError("接受者账号不能为空","#form-error-message3")
} }
$("#btnTransferBook").button("loading"); $("#btnTransferBook").button("loading");
}, },
@ -356,7 +372,7 @@
if(res.errcode === 0){ if(res.errcode === 0){
window.location = window.location.href; window.location = window.location.href;
}else{ }else{
showError(res.message); showError(res.message,"#form-error-message3");
} }
$("#btnTransferBook").button("reset"); $("#btnTransferBook").button("reset");
}, },