var loadStatus = function(){ executeCurrentContract("isOwner","",onIsOwner); }; var onIsOwner = function(data){ if (data.result=="true"){ console.log("isOnwer!"); flushApplylist(); flushAcceptlist(); flushApplyinglist(); $(".ownerDIV").css("display","block"); } else { $("#applyForm").css("display","block"); refreshMyStatus(); } }; var flushAllList = function(){ flushApplylist(); flushAcceptlist(); flushApplyinglist(); } var flushApplylist = function(){ executeCurrentContract("getApplyList","",onApplyList); }; var flushAcceptlist = function(){ executeCurrentContract("getAcceptList","",onAcceptList); }; var flushApplylist = function(){ executeCurrentContract("getApplyingList","",onApplyingList); }; var onApplyList = function(data){ global.applyList = JSON.parse(data.result); fillApplyData(global.applyList); }; var onAcceptList = function(data){ global.acceptList = JSON.parse(data.result); fillAcceptList(global.acceptList); }; var onApplyingList = function(data){ global.applyingList = JSON.parse(data.result); fillApplyingData(global.applyingList); }; var apply = function(){ var arg = $("#remarkInput")[0].value; if (arg!=undefined && arg.length>0) executeCurrentContract("apply",arg,onApplyResult); else alert("备注不能为空"); }; var applying = function(){ var arg = $("#remarkInput")[0].value; if (arg!=undefined && arg.length>0) executeCurrentContract("applying",arg,onApplyingResult); else alert("备注不能为空"); }; var onApplyResult = function(data){ alert("申请结果:"+data.result); }; var onApplyingResult = function(data){ alert("正在申请结果:"+data.result); }; var refreshMyStatus = function(){ var pubkey = global.sm2Key.publicKey; executeCurrentContract("hasPermission","",onHasPermission); }; var onHasPermission = function(data){ if (data.result=="null" || data.result=="false"){ $("#statusSpan")[0].innerHTML="暂无权限"; } else { $("#statusSpan")[0].innerHTML = "有权"; } }; loadStatus();