Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
Community-Mining-Client
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mining
Community-Mining-Client
Commits
5d21644f
Commit
5d21644f
authored
Aug 31, 2021
by
xhx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整
parent
c064f79c
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
83 additions
and
158 deletions
+83
-158
.env.development
.env.development
+3
-2
.env.production
.env.production
+3
-2
MiningInfo.vue
src/components/MiningInfo.vue
+0
-3
Transcation.ts
src/mixin/Transcation.ts
+0
-0
chain33.ts
src/service/chain33.ts
+6
-63
pool.ts
src/service/pool.ts
+36
-21
test.ts
src/utils/test.ts
+4
-0
Details.vue
src/views/Details.vue
+7
-25
Home.vue
src/views/Home.vue
+19
-35
Mine.vue
src/views/Mine.vue
+5
-7
No files found.
.env.development
View file @
5d21644f
NODE_ENV="development"
VUE_APP_URL="http://172.16.100.59:8000"
\ No newline at end of file
VUE_APP_URL="http://172.16.100.59:8000"
VUE_CHAIN_URL="http://172.16.100.59:8801"
\ No newline at end of file
.env.production
View file @
5d21644f
NODE_ENV="production"
// VUE_APP_URL="http://"
\ No newline at end of file
// VUE_APP_URL="http://"
VUE_CHAIN_URL="http://172.16.100.59:8801"
\ No newline at end of file
src/components/MiningInfo.vue
View file @
5d21644f
...
...
@@ -43,9 +43,6 @@ export default Vue.extend({
type
:
Object
}
},
methods
:
{
}
})
</
script
>
...
...
src/mixin/Transcation.ts
deleted
100644 → 0
View file @
c064f79c
src/service/chain33.ts
View file @
5d21644f
...
...
@@ -73,58 +73,6 @@ async function getTransaction(hash: string) {
}])
}
async
function
signFun
(
b
:
any
,
fn
:
any
,
fail
?:
any
)
{
await
signTransition
(
b
.
data
.
result
,
async
(
sign
:
any
)
=>
{
let
s
=
{}
as
any
if
(
typeof
sign
===
'string'
)
{
s
=
JSON
.
parse
(
sign
)
}
else
{
s
=
sign
}
if
(
s
.
error
)
{
Toast
.
clear
()
fail
()
return
}
const
send
=
await
sendTransaction
(
s
.
signHash
)
if
(
send
.
data
.
error
)
{
Toast
(
send
.
data
.
error
)
fail
()
return
}
let
res
=
{}
as
any
const
timer
=
setInterval
(
async
()
=>
{
res
=
await
getTransaction
(
send
.
data
.
result
)
if
(
!
res
.
data
.
error
)
{
clearInterval
(
timer
)
if
(
res
.
data
.
result
.
receipt
.
ty
===
1
)
{
if
(
fail
)
{
Toast
(
res
.
data
.
result
.
receipt
.
tyName
)
fail
()
}
}
else
{
if
(
fn
)
fn
(
res
)
}
}
},
1000
)
})
// web 测试
// const sign = await signTransition(b.data.result, test.privateKey)
// const send = await sendTransaction(sign.data.result)
// let res = {} as any
// const timer = setInterval(async() => {
// res = await getTransaction(send.data.result)
// if (!res.data.error) {
// clearInterval(timer)
// if (res.data.result.receipt.ty === 1) {
// if (fail) fail()
// } else {
// if (fn) fn(res)
// }
// }
// }, 1000)
}
export
default
{
/**
...
...
@@ -132,17 +80,6 @@ export default {
* @param data
* @returns
*/
createRawTransaction
:
async
function
(
data
:
rawTransaction
,
fn
?:
any
,
fail
?:
any
)
{
const
res
=
await
chainRequire
(
'Chain33.CreateRawTransaction'
,
[
data
])
console
.
log
(
res
)
// if 判断
return
signFun
(
res
,
fn
,
fail
)
},
/**
* 构造交易
* @param data
* @returns
*/
createTransaction
:
async
function
(
data
:
rawTransaction
,
fn
?:
any
,
fail
?:
any
)
{
return
await
chainRequire
(
'Chain33.CreateRawTransaction'
,
[
data
])
},
...
...
@@ -198,6 +135,11 @@ export default {
getTransaction
,
/**
* 挖矿绑定
* @param data
* @returns
*/
createBindMiner
:
async
function
(
data
:
{
bindAddr
:
string
,
originAddr
:
string
,
...
...
@@ -208,6 +150,7 @@ export default {
return
res
},
createRawTxGroup
:
function
(
data
:
{
txs
:
any
})
{
...
...
src/service/pool.ts
View file @
5d21644f
import
{
request
}
from
"./service"
;
import
store
from
'@/store/index'
import
{
Toast
}
from
'vant'
const
service
=
request
(
'/api'
)
service
.
interceptors
.
request
.
use
(
function
(
config
)
{
// do something before request is sent
console
.
log
(
store
.
state
)
if
((
store
.
state
as
any
).
app
.
address
)
{
const
str
=
(
store
.
state
as
any
).
app
.
address
...
...
@@ -16,36 +14,49 @@ service.interceptors.request.use(function (config) {
return
Promise
.
reject
(
error
);
});
// service.interceptors.response.use(
// response => {
// // if the custom code is not 200, it is judged as an error.
// // tryHideFullScreenLoading()
// return response
// }, error => {
// console.log('error', error)
// // Do something with response error
// // console.log(error.response)
// const err = error.response
// Toast(err.data.reason || '请求失败')
// return Promise.reject(error);
// })
/**
* 邀请用户
* @param invitation
* @returns
*/
export
const
invitePool
=
function
(
invitation
:
string
)
{
return
service
.
post
(
'/web/pool-invite'
,
{
invitation
})
}
export
const
bindPool
=
function
(
id
:
string
,
amount
:
string
|
number
)
{
return
service
.
post
(
'/web/bind-pool'
,
{
id
:
id
,
amount
})
/**
* 绑定购买
* @param id
* @param amount
* @param isBind
* @returns
*/
export
const
bindPool
=
function
(
id
:
string
,
amount
:
string
|
number
,
isBind
?:
boolean
)
{
return
service
.
post
(
'/web/bind-pool'
,
{
id
,
amount
,
isBind
})
}
/**
* 是否初次绑定购买
* @param id
* @returns
*/
export
const
checkBind
=
function
(
id
:
string
)
{
return
service
.
get
(
'/web/check-bind'
,
{
params
:
{
id
}})
}
/**
* 矿池信息
* @param id
* @returns
*/
export
const
poolInfo
=
function
(
id
:
string
|
number
)
{
return
service
.
get
(
'/web/pool-info'
,
{
params
:
{
id
}})
}
/**
* 矿池市场
* @param data
* @returns
*/
export
const
poolList
=
function
(
data
:
{
page
:
number
,
pageSize
:
number
,
...
...
@@ -54,12 +65,16 @@ export const poolList = function(data: {
return
service
.
get
(
'/web/pool-list'
,
{
params
:
data
})
}
/**
* 矿机列表
* @param data
* @returns
*/
export
const
userMachineList
=
function
(
data
:
{
id
?:
string
|
number
,
addr
?:
string
,
//
id?: string|number,
//
addr?: string,
page
:
string
|
number
,
pageSize
:
string
|
number
,
limit
?:
string
|
number
,
status
?:
string
|
number
})
{
return
service
.
get
(
'/web/user-machine-list'
,
{
params
:
data
})
...
...
src/utils/test.ts
View file @
5d21644f
// export const test = {
// addr: '16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp',
// privateKey: '0xCC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944'
// }
// export const test = {
// addr: '14KEKbYtKKQm4wMthSK9J4La4nAiidGozt',
// privateKey: '0xCC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944'
// }
...
...
src/views/Details.vue
View file @
5d21644f
...
...
@@ -106,10 +106,9 @@
<
script
lang=
"ts"
>
import
Vue
from
'vue'
import
{
Loading
,
NavBar
,
Stepper
,
Toast
}
from
'vant'
import
{
NavBar
,
Stepper
,
Toast
}
from
'vant'
import
{
poolInfo
,
bindPool
,
checkBind
}
from
'@/service/pool'
import
{
signTxGroup
}
from
'@33cn/wallet-api'
import
{
signGroup
}
from
'@/utils/bridge'
import
service
from
'@/service/chain33'
export
default
Vue
.
extend
({
components
:
{
...
...
@@ -122,7 +121,7 @@ export default Vue.extend({
info
:
{}
as
any
,
fee
:
0
,
profit
:
0
,
isBind
:
false
,
isBind
:
false
,
// 初次购买 true: 否 false: 是
ticketNum
:
10000
// BTY 转票比例
}
},
...
...
@@ -152,20 +151,18 @@ export default Vue.extend({
})
},
checkBind
()
{
checkBind
(
this
.
info
.
id
).
then
(
res
=>
{
checkBind
(
this
.
$route
.
query
.
id
as
string
).
then
(
res
=>
{
if
(
res
.
data
.
data
.
isSucc
)
{
this
.
isBind
=
true
}
}).
catch
(()
=>
{
this
.
isBind
=
false
})
},
signGroup
(
txs
:
Array
<
string
>
){
return
signTxGroup
(
txs
.
join
(),
'none'
,
-
1
);
},
async
buy
()
{
if
(
this
.
isBind
)
{
Toast
(
'你已购买该矿池,不可重复购买当前矿池'
)
return
}
if
(
this
.
profit
<
+
this
.
info
.
minTicket
)
{
Toast
(
`您的票数余额为
${
this
.
profit
}
票,不足
${
this
.
info
.
minTicket
}
票`
)
return
...
...
@@ -176,7 +173,6 @@ export default Vue.extend({
amount
:
this
.
ticketNum
*
+
this
.
value
*
1
e8
,
checkBalance
:
false
})
console
.
log
(
bindRes
.
data
)
const
transRes
=
await
service
.
createTransaction
({
fee
:
this
.
fee
,
to
:
'16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp'
,
...
...
@@ -184,7 +180,6 @@ export default Vue.extend({
note
:
'coins->ticket'
,
execName
:
'ticket'
})
console
.
log
(
transRes
)
const
sign
=
await
this
.
signGroup
([
bindRes
.
data
.
result
.
txHex
,
transRes
.
data
.
result
]);
Toast
.
loading
({
duration
:
0
,
...
...
@@ -193,7 +188,6 @@ export default Vue.extend({
})
console
.
log
(
'sign'
,
sign
)
const
send
=
await
service
.
sendTransaction
(
sign
)
console
.
log
(
send
)
if
(
send
.
data
.
result
.
error
)
{
Toast
(
'购买失败'
)
return
...
...
@@ -202,18 +196,16 @@ export default Vue.extend({
const
timer
=
setInterval
(
async
()
=>
{
res
=
await
service
.
getTransaction
(
send
.
data
.
result
)
if
(
!
res
.
data
.
error
)
{
console
.
log
(
'res'
,
res
.
data
)
clearInterval
(
timer
)
const
next
=
res
.
data
.
result
.
tx
.
next
console
.
log
(
'next'
,
next
)
const
transaction
=
await
service
.
getTransaction
(
next
)
if
(
transaction
.
data
.
result
.
receipt
.
ty
===
1
)
{
Toast
(
res
.
data
.
result
.
receipt
.
tyName
)
}
else
{
bindPool
(
this
.
info
.
id
,
this
.
value
).
then
(
async
(
r
:
any
)
=>
{
const
isBind
=
this
.
isBind
?
true
:
false
bindPool
(
this
.
info
.
id
,
this
.
value
,
isBind
).
then
(
async
(
r
:
any
)
=>
{
if
(
r
.
data
.
data
.
isSucc
)
{
this
.
$toast
(
'购买成功'
)
Toast
.
clear
()
}
}).
catch
(
e
=>
{
Toast
(
e
.
response
.
data
.
reason
)
...
...
@@ -239,7 +231,6 @@ export default Vue.extend({
text-align
:
left
;
border-bottom
:
1px
solid
#47474B
;
}
.details-item
{
line-height
:
36px
;
color
:
rgba
(
255
,
255
,
255
,
0
.75
);
...
...
@@ -248,34 +239,27 @@ export default Vue.extend({
align-items
:
center
;
justify-content
:
space-between
;
}
.hide
{
overflow
:
hidden
;
text-overflow
:
ellipsis
;
white-space
:
nowrap
;
}
.special
{
color
:
#FA6400
}
/
deep
/
.van-nav-bar
{
background
:
#323232
;
color
:
#fff
;
}
/
deep
/
.van-nav-bar
.van-icon
{
color
:
#fff
;
}
/
deep
/
.van-nav-bar__content
{
height
:
56px
;
}
/
deep
/ .
van-hairline--bottom
:
:
after
{
border-bottom
:
none
;
}
/
deep
/
.van-stepper__minus
,
/
deep
/
.van-stepper__plus
,
/
deep
/
.van-stepper__input
{
...
...
@@ -283,14 +267,12 @@ export default Vue.extend({
background
:
#3A3A3C
;
border-color
:
#7A7979
;
}
/
deep
/
.van-stepper__minus--disabled
,
/
deep
/
.van-stepper__plus--disabled
{
color
:
#c8c9cc
;
background-color
:
#3A3A3C
;
cursor
:
not
-
allowed
;
}
/
deep
/
.van-stepper__minus--disabled
,
/
deep
/
.van-stepper__plus--disabled
,
/
deep
/
.van-stepper__minus--disabled
:active
,
...
...
src/views/Home.vue
View file @
5d21644f
...
...
@@ -4,13 +4,13 @@
<div
class=
"text-2xl text-white"
>
社区矿池
</div>
<div
class=
"flex-shrink-0 text-sm text-white"
@
click=
"goMining"
>
我的矿机
<span
class=
"i
con
bg-gradient-1"
>
<span
class=
"i
nline-block w-4 h-4 rounded-full
bg-gradient-1"
>
<van-icon
name=
"arrow"
color=
"#323232"
size=
"12"
/>
</span>
</div>
</div>
<div
class=
"px-4 pt-20"
>
<div
class=
"
mine-card flex flex-column
bg-card bg-cover rounded-lg"
>
<div
class=
"
flex flex-col py-4 px-5 mb-11
bg-card bg-cover rounded-lg"
>
<div
class=
"text-sm text-left pb-3 tracking-normal hide"
>
当前地址:
{{
addr
}}
</div>
<div
class=
"flex items-center justify-between"
>
<div>
...
...
@@ -65,7 +65,7 @@
</template>
<
script
lang=
"ts"
>
import
{
Icon
,
PullRefresh
,
Toast
,
Popup
,
List
}
from
'vant'
import
{
Icon
,
PullRefresh
,
Toast
,
Popup
}
from
'vant'
import
MiningCard
from
'@/components/MiningCard.vue'
import
Vue
from
'vue'
import
service
from
'@/service/chain33'
...
...
@@ -79,14 +79,14 @@ export default Vue.extend({
},
data
()
{
return
{
addr
:
this
.
$store
.
state
.
app
.
address
,
addr
:
''
,
btnText
:
'领取收益'
,
btnType
:
false
,
lists
:
[]
as
any
,
isLoading
:
false
,
count
:
0
,
timer
:
0
,
waiter
:
18000
,
waiter
:
18000
0
,
page
:
1
,
pageSize
:
10
,
ticketNum
:
0
,
...
...
@@ -106,9 +106,14 @@ export default Vue.extend({
if
(
res
.
data
.
data
.
isSucc
)
{
this
.
$toast
(
'添加成功'
)
this
.
show
=
false
this
.
getInfo
()
this
.
getList
()
this
.
getTicket
()
}
else
{
this
.
$toast
(
'请输入正确的推荐人地址'
)
}
}).
catch
(()
=>
{
this
.
$toast
(
'请输入正确的推荐人地址'
)
})
},
getFee
()
{
...
...
@@ -124,10 +129,8 @@ export default Vue.extend({
getList
()
{
poolList
({
page
:
this
.
page
,
pageSize
:
this
.
pageSize
,
limit
:
10000
pageSize
:
this
.
pageSize
}).
then
((
res
:
any
)
=>
{
console
.
log
(
res
)
if
(
this
.
refresh
)
{
this
.
refresh
=
false
this
.
lists
=
[]
...
...
@@ -136,25 +139,19 @@ export default Vue.extend({
this
.
count
=
+
res
.
data
.
data
.
count
document
.
addEventListener
(
'scroll'
,
this
.
scrollEvent
)
}).
catch
(
e
=>
{
console
.
log
(
e
)
const
err
=
e
.
response
if
(
err
.
data
?.
code
===
406
&&
err
.
data
?.
reason
===
'USER_NOT_BIND'
)
{
this
.
show
=
true
}
if
(
this
.
timer
)
{
clearInterval
(
this
.
timer
)
}
})
this
.
isLoading
=
false
},
getInfo
()
{
service
.
getBalance
(
this
.
$store
.
state
.
app
.
address
,
'ticket'
).
then
((
res
:
any
)
=>
{
console
.
log
(
res
)
this
.
profit
=
Math
.
floor
((
res
.
data
.
result
as
any
)[
0
].
balance
/
1
e8
)
Toast
.
clear
()
}).
catch
(()
=>
{
Toast
({
duration
:
3000
,
message
:
'请求失败'
,
forbidClick
:
true
})
})
},
async
getIncome
()
{
...
...
@@ -169,16 +166,15 @@ export default Vue.extend({
forbidClick
:
true
,
duration
:
0
})
const
b
=
await
service
.
createTransaction
({
const
transaction
=
await
service
.
createTransaction
({
to
:
'16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp'
,
amount
:
this
.
profit
*
1
e8
,
// amount: 1e8 * 1,
fee
:
this
.
fee
,
note
:
'ticket -> coins'
,
isWithdraw
:
true
,
execName
:
'ticket'
})
await
service
.
signTransition
((
b
as
any
).
data
.
result
,
async
(
sign
:
any
)
=>
{
await
service
.
signTransition
((
transaction
as
any
).
data
.
result
,
async
(
sign
:
any
)
=>
{
let
s
=
{}
as
any
if
(
typeof
sign
===
'string'
)
{
s
=
JSON
.
parse
(
sign
)
...
...
@@ -245,17 +241,17 @@ export default Vue.extend({
setTimer
()
{
if
(
this
.
timer
)
clearInterval
(
this
.
timer
)
this
.
timer
=
setInterval
(()
=>
{
this
.
getList
()
this
.
onRefresh
()
},
this
.
waiter
)
}
},
mounted
()
{
this
.
addr
=
this
.
$store
.
state
.
app
.
address
const
that
=
this
this
.
getList
()
this
.
getInfo
()
this
.
getFee
()
this
.
getTicket
()
this
.
setTimer
()
},
beforeDestroy
()
{
const
that
=
this
...
...
@@ -274,19 +270,7 @@ export default Vue.extend({
z-index
:
50
;
background
:
#323232
;
}
.icon
{
display
:
inline-block
;
width
:
16px
;
height
:
16px
;
border-radius
:
50%
;
}
.mine-card
{
display
:
flex
;
flex-direction
:
column
;
padding
:
16px
20px
;
margin-bottom
:
46px
;
}
.card-list
{
.card-list
{
border
:
1px
solid
#A67855
;
border-top
:
none
;
border-radius
:
5px
;
...
...
src/views/Mine.vue
View file @
5d21644f
...
...
@@ -51,11 +51,6 @@ export default Vue.extend({
}
},
methods
:
{
getList
()
{
this
.
isLoading
=
false
},
getNowList
()
{
userMachineList
({
page
:
this
.
page
,
...
...
@@ -90,7 +85,11 @@ export default Vue.extend({
if
(
this
.
lists
.
length
<
this
.
count
)
{
if
(
h
>
(
g
*
this
.
page
*
(
this
.
pageSize
-
3
)))
{
this
.
page
++
this
.
getList
()
if
(
this
.
active
===
1
)
{
this
.
getNowList
()
}
else
{
this
.
getEndList
()
}
}
}
},
...
...
@@ -114,7 +113,6 @@ export default Vue.extend({
}
},
mounted
()
{
// this.getList()
this
.
getNowList
()
},
beforeDestroy
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment