forked from huangjin8888/diamonds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.html
149 lines (137 loc) · 5.71 KB
/
manage.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>管理端</title>
<link rel="shortcut icon" href="favicon.ico"> <link href="css/bootstrap.min.css?v=3.3.7" rel="stylesheet">
<link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<link href="css/style.css?v=4.1.0" rel="stylesheet">
</head>
<body class="gray-bg top-navigation">
<div id="wrapper">
<div id="page-wrapper" class="gray-bg">
<div class="wrapper wrapper-content">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="ibox float-e-margins">
<div class="ibox-title">
<h5>基础设置,合约部署完成后将各个地址放入abi的setting后应用此设置</h5>
</div>
<div class="ibox-content">
<div class="form-horizontal">
<div class="form-group">
<label class="col-sm-2 control-label">DiamondsRole</label>
<div class="col-sm-6">
<div class="input-group">
<input type="text" placeholder="SettingAddress" class="form-control" id="addr1">
<span class="input-group-btn">
<button type="button" class="btn btn-primary" id="btn1">设置</button>
</span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">WorkerRole</label>
<div class="col-sm-6">
<div class="input-group">
<input type="text" placeholder="SettingAddress" class="form-control" id="addr2">
<span class="input-group-btn">
<button type="button" class="btn btn-primary" id="btn2">设置</button>
</span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">HoeRole</label>
<div class="col-sm-6">
<div class="input-group">
<input type="text" placeholder="SettingAddress" class="form-control" id="addr3">
<span class="input-group-btn">
<button type="button" class="btn btn-primary" id="btn3">设置</button>
</span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">setApprovalForAll_worker</label>
<div class="col-sm-6">
<div class="input-group">
<input type="text" placeholder="SettingAddress" class="form-control" id="addr4">
<span class="input-group-btn">
<button type="button" class="btn btn-primary" id="btn4">设置</button>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/bootstrap.min.js?v=3.3.7"></script>
<script type="text/javascript" src="js/web3.min.js"> </script>
<script type="text/javascript" src="abi/abi.js"> </script>
<script>
loadData(function(){
var account="";
var price=0;
if (typeof window.ethereum !== 'undefined') {
var ethereum = window.ethereum
//禁止自动刷新,metamask要求写的
ethereum.autoRefreshOnNetworkChange = false
try {
//第一次链接Metamask
var accounts = ethereum.enable()
provider = new Web3(ethereum);
var contract_diamonds=new provider.eth.Contract(contracts.diamonds.abi,contracts.diamonds.address);
var contract_worker=new provider.eth.Contract(contracts.worker.abi,contracts.worker.address);
var contract_hoe=new provider.eth.Contract(contracts.hoe.abi,contracts.hoe.address);
$("#addr1").val(contracts.box.address);
$("#addr2").val(contracts.box.address);
$("#addr3").val(contracts.box.address);
provider.eth.getAccounts(function (error, result) {
if (!error){
console.log(result)//授权成功后result能正常获取到账号了
provider.eth.getBalance(result[0]).then(console.log);
account=result[0];
$("#btn1").click(function(){
contract_diamonds.methods.setRole($("#addr1").val()).send({from:account},function(error,result){});
});
$("#btn2").click(function(){
contract_worker.methods.setRole($("#addr2").val()).send({from:account},function(error,result){});
});
$("#btn3").click(function(){
contract_hoe.methods.setRole($("#addr3").val()).send({from:account},function(error,result){});
});
$("#btn4").click(function(){
contract_worker.methods.setApprovalForAll($("#addr4").val(),true).send({from:account},function(error,result){});
});
}
});
} catch (e) {
swal({
title: "错误:"+e,
type: "error",
confirmButtonText:"好的"
});
}
} else {
swal({
title: "没有安装metamask",
type: "error",
confirmButtonText:"好的"
});
}
});
</script>
</body>
</html>