var loadStatus = function(){ executeCurrentContract("isOwner","",onIsOwner); }; var onIsOwner = function(data){ if (data.result=="true"){ flushAllOwnerData(); $(".ownerDIV").css("display","block"); } else { flushAllUserData(); $(".userDIV").css("display","block"); } }; var flushAllOwnerData = function () { flushOwnerStatus(); flushAskListRO(); flushBidListAll(); flushFinalListOwner(); }; var flushAllUserData = function () { flushUserStatus(); flushAskListRW(); flushBidListPrivate(); flushFinalListPrivate(); }; var flushOwnerStatus = function(){ executeCurrentContract("getStatus","",onOwnerStatus); }; var onOwnerStatus = function(data){ global.ownerStatus = data.result; if (global.ownerStatus == "Bidding") { $("#ownerStatus")[0].value = "竞拍中"; } else { $("#ownerStatus")[0].value = "拍卖完成"; } }; var flushAskListRO = function(){ executeCurrentContract("getAskListRO","",onAskListRO); }; var onAskListRO = function(data){ global.askListRO = JSON.parse(data.result); fillAskListRO(global.askListRO); }; var flushBidListAll = function(){ executeCurrentContract("getBidListAll","",onBidListAll); }; var onBidListAll = function(data){ global.bidListAll = JSON.parse(data.result); fillBidListAll(global.bidListAll); }; var flushFinalListOwner = function(){ executeCurrentContract("getFinalListOwner","",onFinalListOwner); }; var onFinalListOwner = function(data){ global.finalListOwner = JSON.parse(data.result); fillFinalListOwner(global.finalListOwner); }; var endAuction = function(){ executeCurrentContract("match","",function(data){ alert("终止拍卖:"+data.result); flushAllOwnerData(); }); }; var restartAuction = function(){ executeCurrentContract("resetStatus","",function(data){ alert("重新开始拍卖:"+data.result); flushAllOwnerData(); }); }; var flushUserStatus = function(){ executeCurrentContract("getStatus","",onUserStatus); }; var onUserStatus = function(data){ global.userStatus = data.result; if (global.userStatus == "Bidding") { $("#userStatus")[0].value = "竞拍中"; } else { $("#userStatus")[0].value = "拍卖完成"; } }; var flushAskListRW = function(){ executeCurrentContract("getAskListRW","",onAskListRW); }; var onAskListRW = function(data){ global.askListRW = JSON.parse(data.result); fillAskListRW(global.askListRW); }; var flushBidListPrivate = function(){ executeCurrentContract("getBidListPrivate","",onBidListPrivate); }; var onBidListPrivate = function(data){ global.bidListPrivate = JSON.parse(data.result); fillBidListPrivate(global.bidListPrivate); }; var flushFinalListPrivate = function(){ executeCurrentContract("getFinalListPrivate","",onFinalListPrivate); }; var onFinalListPrivate = function(data){ global.finalListPrivate = JSON.parse(data.result); fillFinalListPrivate(global.finalListPrivate); }; var addResource = function(){ var arg = {}; arg.item = $("#resourceDesc")[0].value; arg.price = $("#resourcePrice")[0].value; if (arg.price/1!=arg.price || arg.price/1<=0){ alert("价格必须是大于0的整数"); return; } executeCurrentContract("ask",JSON.stringify(arg),function(data){ alert("添加资源:"+data.result); flushAllUserData(); }); } loadStatus();