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
c064f79c
Commit
c064f79c
authored
Aug 27, 2021
by
xhx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
交易调整
parent
62efdcad
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
310 additions
and
174 deletions
+310
-174
index.html
public/index.html
+1
-1
App.vue
src/App.vue
+6
-5
chain33.ts
src/service/chain33.ts
+63
-59
pool.ts
src/service/pool.ts
+23
-3
bridge.ts
src/utils/bridge.ts
+3
-2
test.ts
src/utils/test.ts
+2
-1
Details.vue
src/views/Details.vue
+78
-55
Home.vue
src/views/Home.vue
+92
-35
Mine.vue
src/views/Mine.vue
+42
-13
No files found.
public/index.html
View file @
c064f79c
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<head>
<head>
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width,
initial-scale=1.0
"
>
<meta
name=
"viewport"
content=
"width=device-width,
initial-scale=1.0, maximum-scale=1.0, user-scalable=no
"
>
<script
type=
"text/javascript"
src=
"https://fe33cn.gitee.io/fe33cn_libs/jsBridge-cdn.js?v=v20200120"
></script>
<script
type=
"text/javascript"
src=
"https://fe33cn.gitee.io/fe33cn_libs/jsBridge-cdn.js?v=v20200120"
></script>
<link
rel=
"icon"
href=
"<%= BASE_URL %>favicon.ico"
>
<link
rel=
"icon"
href=
"<%= BASE_URL %>favicon.ico"
>
<title><
%=
htmlWebpackPlugin
.
options
.
title
%
></title>
<title><
%=
htmlWebpackPlugin
.
options
.
title
%
></title>
...
...
src/App.vue
View file @
c064f79c
...
@@ -11,11 +11,12 @@ import { test } from '@/utils/test' // 本地测试
...
@@ -11,11 +11,12 @@ import { test } from '@/utils/test' // 本地测试
export
default
Vue
.
extend
({
export
default
Vue
.
extend
({
mounted
()
{
mounted
()
{
console
.
log
(
this
.
$store
)
console
.
log
(
this
.
$store
)
// getCurrentBTYAddress('',(res: any) => {
// getCurrentBTYAddress('',(res: any) => {
// console.log('res', res)
// console.log('res', res)
// this.$store.commit('app/SET_ADDRESS', res)
// this.$store.commit('app/SET_ADDRESS', res)
// })
// console.log(this.$store.state.app.address)
this
.
$store
.
commit
(
'app/SET_ADDRESS'
,
test
.
addr
)
// })
this
.
$store
.
commit
(
'app/SET_ADDRESS'
,
test
.
addr
)
}
}
})
})
</
script
>
</
script
>
...
...
src/service/chain33.ts
View file @
c064f79c
...
@@ -3,9 +3,9 @@ import axios from 'axios'
...
@@ -3,9 +3,9 @@ import axios from 'axios'
import
{
sign
}
from
'@/utils/bridge'
import
{
sign
}
from
'@/utils/bridge'
import
{
rawTransaction
}
from
"@/type/request"
;
import
{
rawTransaction
}
from
"@/type/request"
;
import
{
Toast
}
from
"vant"
;
import
{
Toast
}
from
"vant"
;
import
{
test
}
from
'@/utils/test'
//
import { test } from '@/utils/test'
const
service
=
request
(
'http://172.16.100.
75
:8801'
)
const
service
=
request
(
'http://172.16.100.
59
:8801'
)
async
function
chainRequire
(
method
:
string
,
data
:
any
[],
b
?:
boolean
,
_this
?:
any
,
cb
?:
any
){
async
function
chainRequire
(
method
:
string
,
data
:
any
[],
b
?:
boolean
,
_this
?:
any
,
cb
?:
any
){
const
CancelToken
=
axios
.
CancelToken
;
const
CancelToken
=
axios
.
CancelToken
;
...
@@ -38,20 +38,20 @@ async function chainRequire(method: string, data: any[], b?: boolean, _this?: an
...
@@ -38,20 +38,20 @@ async function chainRequire(method: string, data: any[], b?: boolean, _this?: an
* @param txHex
* @param txHex
* @param fn
* @param fn
*/
*/
// function signTransition (txHex: string, fn?: any){
function
signTransition
(
txHex
:
string
,
fn
?:
any
){
// sign({
sign
({
// createHash: txHex,
createHash
:
txHex
,
// exer: 'user.p.szhtest.rankvote',
exer
:
'ticket'
,
// isWithhold: 1
isWithhold
:
-
1
// }, fn)
},
fn
)
// }
async
function
signTransition
(
txHex
:
string
,
privateKey
?:
string
){
return
await
chainRequire
(
'Chain33.SignRawTx'
,[{
privkey
:
privateKey
,
txHex
:
txHex
,
expire
:
'1h'
,
}])
}
}
// async function signTransition(txHex:string,privateKey?:string){
// return await chainRequire('Chain33.SignRawTx',[{
// privkey: privateKey,
// txHex: txHex,
// expire: '1h',
// }])
// }
/**
/**
* 发送签名
* 发送签名
...
@@ -74,51 +74,55 @@ async function getTransaction(hash: string) {
...
@@ -74,51 +74,55 @@ async function getTransaction(hash: string) {
}
}
async
function
signFun
(
b
:
any
,
fn
:
any
,
fail
?:
any
)
{
async
function
signFun
(
b
:
any
,
fn
:
any
,
fail
?:
any
)
{
// await signTransition(b.data.result, async (sign: any) => {
await
signTransition
(
b
.
data
.
result
,
async
(
sign
:
any
)
=>
{
// let s = {} as any
let
s
=
{}
as
any
// if (typeof sign === 'string') {
if
(
typeof
sign
===
'string'
)
{
// s = JSON.parse(sign)
s
=
JSON
.
parse
(
sign
)
// } else {
}
else
{
// s = sign
s
=
sign
// }
}
// if (s.error) {
if
(
s
.
error
)
{
// fail()
Toast
.
clear
()
// return
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) 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
)
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
{
export
default
{
...
...
src/service/pool.ts
View file @
c064f79c
import
{
request
}
from
"./service"
;
import
{
request
}
from
"./service"
;
import
store
from
'@/store/index'
import
store
from
'@/store/index'
import
{
Toast
}
from
'vant'
const
service
=
request
(
'/api'
)
const
service
=
request
(
'/api'
)
...
@@ -15,6 +16,20 @@ service.interceptors.request.use(function (config) {
...
@@ -15,6 +16,20 @@ service.interceptors.request.use(function (config) {
return
Promise
.
reject
(
error
);
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);
// })
export
const
invitePool
=
function
(
invitation
:
string
)
{
export
const
invitePool
=
function
(
invitation
:
string
)
{
return
service
.
post
(
'/web/pool-invite'
,
{
invitation
})
return
service
.
post
(
'/web/pool-invite'
,
{
invitation
})
}
}
...
@@ -23,6 +38,10 @@ export const bindPool = function(id: string, amount: string|number) {
...
@@ -23,6 +38,10 @@ export const bindPool = function(id: string, amount: string|number) {
return
service
.
post
(
'/web/bind-pool'
,
{
id
:
id
,
amount
})
return
service
.
post
(
'/web/bind-pool'
,
{
id
:
id
,
amount
})
}
}
export
const
checkBind
=
function
(
id
:
string
)
{
return
service
.
get
(
'/web/check-bind'
,
{
params
:
{
id
}})
}
export
const
poolInfo
=
function
(
id
:
string
|
number
)
{
export
const
poolInfo
=
function
(
id
:
string
|
number
)
{
return
service
.
get
(
'/web/pool-info'
,
{
params
:
{
id
}})
return
service
.
get
(
'/web/pool-info'
,
{
params
:
{
id
}})
}
}
...
@@ -40,13 +59,14 @@ export const userMachineList = function(data: {
...
@@ -40,13 +59,14 @@ export const userMachineList = function(data: {
addr
?:
string
,
addr
?:
string
,
page
:
string
|
number
,
page
:
string
|
number
,
pageSize
:
string
|
number
,
pageSize
:
string
|
number
,
limit
?:
string
|
number
limit
?:
string
|
number
,
status
?:
string
|
number
})
{
})
{
return
service
.
get
(
'/web/user-machine-list'
,
{
params
:
data
})
return
service
.
get
(
'/web/user-machine-list'
,
{
params
:
data
})
}
}
export
const
userMinedData
=
function
(
id
:
string
|
number
)
{
export
const
userMinedData
=
function
()
{
return
service
.
get
(
'/web/user-mined-data'
,
{
params
:
{
id
}
})
return
service
.
get
(
'/web/user-mined-data'
,
{})
}
}
export
const
userMinedDetail
=
function
(
id
:
string
|
number
)
{
export
const
userMinedDetail
=
function
(
id
:
string
|
number
)
{
...
...
src/utils/bridge.ts
View file @
c064f79c
...
@@ -2,4 +2,5 @@ const jsBridge = (window as any).jsBridge
...
@@ -2,4 +2,5 @@ const jsBridge = (window as any).jsBridge
const
_jsBridge
=
new
jsBridge
()
const
_jsBridge
=
new
jsBridge
()
export
const
sign
=
(
params
:
any
,
fn
?:
Function
)
=>
_jsBridge
.
sign
(
params
,
fn
)
export
const
sign
=
(
params
:
any
,
fn
?:
Function
)
=>
_jsBridge
.
sign
(
params
,
fn
)
export
const
getCurrentBTYAddress
=
(
params
:
any
,
fn
?:
Function
)
=>
_jsBridge
.
getCurrentBTYAddress
(
params
,
fn
)
export
const
getCurrentBTYAddress
=
(
params
:
any
,
fn
?:
Function
)
=>
_jsBridge
.
getCurrentBTYAddress
(
params
,
fn
)
\ No newline at end of file
export
const
signGroup
=
(
params
:
any
,
fn
?:
Function
)
=>
_jsBridge
.
signTxGroup
(
params
,
fn
)
\ No newline at end of file
src/utils/test.ts
View file @
c064f79c
...
@@ -3,7 +3,8 @@
...
@@ -3,7 +3,8 @@
// privateKey: '0xCC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944'
// privateKey: '0xCC38546E9E659D15E6B4893F0AB32A06D103931A8230B0BDE71459D2B27D6944'
// }
// }
export
const
test
=
{
export
const
test
=
{
addr
:
'1LGQLmGVHSNthZcLbGpVfJTDmcicMQprZs'
,
addr
:
'16GgdskdRFasxuMdtBaxNS4ZagyZgEUuMs'
,
// addr: '1LGQLmGVHSNthZcLbGpVfJTDmcicMQprZs',
privateKey
:
'0xa65b62735022cd47b11c5a88b0caac8d360810257aaf1e14bbc330dee63b35ff'
privateKey
:
'0xa65b62735022cd47b11c5a88b0caac8d360810257aaf1e14bbc330dee63b35ff'
}
}
// export const test = {
// export const test = {
...
...
src/views/Details.vue
View file @
c064f79c
...
@@ -62,12 +62,12 @@
...
@@ -62,12 +62,12 @@
<p
class=
"details-title"
>
挖矿信息
</p>
<p
class=
"details-title"
>
挖矿信息
</p>
<div
class=
"py-2"
>
<div
class=
"py-2"
>
<p
class=
"details-item"
>
<p
class=
"details-item"
>
<span>
矿池地址
</span>
<span
class=
"flex-shrink-0 mr-3"
>
矿池地址
</span>
<span>
{{ info.minerAddr }}
</span>
<span
class=
"flex-grow-0 hide"
>
{{ info.minerAddr }}
</span>
</p>
</p>
<p
class=
"details-item"
>
<p
class=
"details-item"
>
<span>
发起人挖矿地址
</span>
<span
class=
"flex-shrink-0 mr-3"
>
发起人挖矿地址
</span>
<span>
{{ info.selfAddr }}
</span>
<span
class=
"flex-grow-0 hide"
>
{{ info.selfAddr }}
</span>
</p>
</p>
<p
class=
"details-item"
>
<p
class=
"details-item"
>
<span>
发起人委托票数
</span>
<span>
发起人委托票数
</span>
...
@@ -97,7 +97,7 @@
...
@@ -97,7 +97,7 @@
<div
class=
"w-full h-16 px-4 bg-card-color fixed bottom-0 flex items-center justify-between"
>
<div
class=
"w-full h-16 px-4 bg-card-color fixed bottom-0 flex items-center justify-between"
>
<div
class=
"flex items-center"
>
<div
class=
"flex items-center"
>
<div
class=
"text-sm text-white mr-3"
>
票数
</div>
<div
class=
"text-sm text-white mr-3"
>
票数
</div>
<van-stepper
v-model=
"value"
:min=
"
info.minTicket"
:max=
"profit
"
integer
/>
<van-stepper
v-model=
"value"
:min=
"
1"
:max=
"Math.floor(profit/ticketNum)
"
integer
/>
</div>
</div>
<button
class=
"bg-gradient-4 w-24 h-9 text-brown2 text-15px rounded-full"
@
click=
"buy"
>
购买
</button>
<button
class=
"bg-gradient-4 w-24 h-9 text-brown2 text-15px rounded-full"
@
click=
"buy"
>
购买
</button>
</div>
</div>
...
@@ -106,24 +106,24 @@
...
@@ -106,24 +106,24 @@
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
import
Vue
from
'vue'
import
Vue
from
'vue'
import
{
NavBar
,
Stepper
,
Toast
}
from
'vant'
import
{
Loading
,
NavBar
,
Stepper
,
Toast
}
from
'vant'
import
{
poolInfo
,
bindPool
}
from
'@/service/pool'
import
{
poolInfo
,
bindPool
,
checkBind
}
from
'@/service/pool'
import
{
signTxGroup
}
from
'@33cn/wallet-api'
import
{
signTxGroup
}
from
'@33cn/wallet-api'
import
{
signGroup
}
from
'@/utils/bridge'
import
service
from
'@/service/chain33'
import
service
from
'@/service/chain33'
// import mixinsTranscation from '@/mixin/Transcation'
import
{
test
}
from
'@/utils/test'
export
default
Vue
.
extend
({
export
default
Vue
.
extend
({
components
:
{
components
:
{
'nav-bar'
:
NavBar
,
'nav-bar'
:
NavBar
,
'van-stepper'
:
Stepper
'van-stepper'
:
Stepper
},
},
// mixins: [mixinsTranscation],
data
()
{
data
()
{
return
{
return
{
value
:
10
,
value
:
10
,
info
:
{}
as
any
,
info
:
{}
as
any
,
fee
:
0
,
fee
:
0
,
profit
:
0
,
profit
:
0
,
isBind
:
false
,
ticketNum
:
10000
// BTY 转票比例
}
}
},
},
methods
:
{
methods
:
{
...
@@ -135,7 +135,7 @@ export default Vue.extend({
...
@@ -135,7 +135,7 @@ export default Vue.extend({
console
.
log
(
res
)
console
.
log
(
res
)
this
.
fee
=
res
.
data
.
result
.
properFee
this
.
fee
=
res
.
data
.
result
.
properFee
})
})
service
.
getBalance
(
this
.
$store
.
state
.
app
.
address
,
'coin'
).
then
((
res
:
any
)
=>
{
service
.
getBalance
(
this
.
$store
.
state
.
app
.
address
,
'coin
s
'
).
then
((
res
:
any
)
=>
{
console
.
log
(
res
)
console
.
log
(
res
)
this
.
profit
=
Math
.
floor
((
res
.
data
.
result
as
any
)[
0
].
balance
/
1
e8
)
this
.
profit
=
Math
.
floor
((
res
.
data
.
result
as
any
)[
0
].
balance
/
1
e8
)
}).
catch
(()
=>
{
}).
catch
(()
=>
{
...
@@ -151,66 +151,83 @@ export default Vue.extend({
...
@@ -151,66 +151,83 @@ export default Vue.extend({
this
.
info
=
res
.
data
.
data
this
.
info
=
res
.
data
.
data
})
})
},
},
checkBind
()
{
checkBind
(
this
.
info
.
id
).
then
(
res
=>
{
if
(
res
.
data
.
data
.
isSucc
)
{
this
.
isBind
=
true
}
})
},
signGroup
(
txs
:
Array
<
string
>
){
signGroup
(
txs
:
Array
<
string
>
){
return
signTxGroup
(
txs
.
join
(),
'none'
,
-
1
);
return
signTxGroup
(
txs
.
join
(),
'none'
,
-
1
);
},
},
async
buy
()
{
async
buy
()
{
if
(
this
.
isBind
)
{
Toast
(
'你已购买该矿池,不可重复购买当前矿池'
)
return
}
if
(
this
.
profit
<
+
this
.
info
.
minTicket
)
{
if
(
this
.
profit
<
+
this
.
info
.
minTicket
)
{
Toast
(
`您的票数不足
${
this
.
info
.
minTicket
}
票`
)
Toast
(
`您的票数
余额为
${
this
.
profit
}
票,
不足
${
this
.
info
.
minTicket
}
票`
)
return
return
}
}
bindPool
(
this
.
info
.
id
,
this
.
value
).
then
(
async
(
r
:
any
)
=>
{
const
bindRes
=
await
service
.
createBindMiner
({
console
.
log
(
r
)
bindAddr
:
this
.
info
.
minerAddr
,
if
(
r
.
data
.
data
.
isSucc
)
{
originAddr
:
this
.
$store
.
state
.
app
.
address
,
const
bindRes
=
await
service
.
createBindMiner
({
amount
:
this
.
ticketNum
*
+
this
.
value
*
1
e8
,
bindAddr
:
this
.
$store
.
state
.
app
.
address
,
checkBalance
:
false
originAddr
:
this
.
info
.
minerAddr
,
})
amount
:
3000
*
+
this
.
value
*
1
e8
,
console
.
log
(
bindRes
.
data
)
checkBalance
:
false
const
transRes
=
await
service
.
createTransaction
({
})
fee
:
this
.
fee
,
console
.
log
(
bindRes
)
to
:
'16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp'
,
const
transRes
=
await
service
.
createTransaction
({
amount
:
this
.
ticketNum
*
Number
(
this
.
value
)
*
1
e8
,
fee
:
0
,
note
:
'coins->ticket'
,
to
:
'16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp'
,
execName
:
'ticket'
amount
:
3000
*
Number
(
this
.
value
)
*
1
e8
,
})
// amount: 1 * 1e8,// 单位是 (万个币),所以这里不是 10^8,而是 10^12
console
.
log
(
transRes
)
note
:
'coins->ticket'
,
const
sign
=
await
this
.
signGroup
([
bindRes
.
data
.
result
.
txHex
,
transRes
.
data
.
result
]);
execName
:
'ticket'
Toast
.
loading
({
})
duration
:
0
,
console
.
log
(
transRes
)
message
:
'购买中'
,
const
sign
=
await
this
.
signGroup
([
transRes
.
data
.
result
.
txHex
,
bindRes
.
data
.
result
]);
forbidClick
:
true
// const sign = await service.createRawTxGroup({
})
// txs: [transRes.data.result, bindRes.data.result.txHex]
console
.
log
(
'sign'
,
sign
)
// });
const
send
=
await
service
.
sendTransaction
(
sign
)
console
.
log
(
sign
)
console
.
log
(
send
)
const
send
=
await
service
.
sendTransaction
(
sign
.
data
.
result
)
if
(
send
.
data
.
result
.
error
)
{
console
.
log
(
send
)
Toast
(
'购买失败'
)
if
(
send
.
data
.
result
.
error
)
{
return
Toast
(
'购买失败'
)
}
return
let
res
=
{}
as
any
}
const
timer
=
setInterval
(
async
()
=>
{
let
res
=
{}
as
any
res
=
await
service
.
getTransaction
(
send
.
data
.
result
)
const
timer
=
setInterval
(
async
()
=>
{
if
(
!
res
.
data
.
error
)
{
res
=
await
service
.
getTransaction
(
send
.
data
.
result
)
console
.
log
(
'res'
,
res
.
data
)
if
(
!
res
.
data
.
error
)
{
clearInterval
(
timer
)
clearInterval
(
timer
)
const
next
=
res
.
data
.
result
.
tx
.
next
if
(
res
.
data
.
result
.
receipt
.
ty
===
1
)
{
console
.
log
(
'next'
,
next
)
console
.
log
(
'fail'
)
const
transaction
=
await
service
.
getTransaction
(
next
)
}
else
{
if
(
transaction
.
data
.
result
.
receipt
.
ty
===
1
)
{
Toast
(
res
.
data
.
result
.
receipt
.
tyName
)
}
else
{
bindPool
(
this
.
info
.
id
,
this
.
value
).
then
(
async
(
r
:
any
)
=>
{
if
(
r
.
data
.
data
.
isSucc
)
{
this
.
$toast
(
'购买成功'
)
this
.
$toast
(
'购买成功'
)
Toast
.
clear
()
}
}
}
}).
catch
(
e
=>
{
},
1000
)
Toast
(
e
.
response
.
data
.
reason
)
})
}
}
}
}).
catch
(
e
=>
{
},
1000
)
Toast
(
e
.
response
.
data
.
reason
)
})
}
}
},
},
created
()
{
created
()
{
window
.
scrollTo
(
0
,
0
)
window
.
scrollTo
(
0
,
0
)
this
.
getInfo
()
this
.
getInfo
()
this
.
getFee
()
this
.
getFee
()
this
.
checkBind
()
}
}
})
})
</
script
>
</
script
>
...
@@ -232,6 +249,12 @@ export default Vue.extend({
...
@@ -232,6 +249,12 @@ export default Vue.extend({
justify-content
:
space-between
;
justify-content
:
space-between
;
}
}
.hide
{
overflow
:
hidden
;
text-overflow
:
ellipsis
;
white-space
:
nowrap
;
}
.special
{
.special
{
color
:
#FA6400
color
:
#FA6400
}
}
...
...
src/views/Home.vue
View file @
c064f79c
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
</div>
</div>
<div
class=
"px-4 pt-20"
>
<div
class=
"px-4 pt-20"
>
<div
class=
"mine-card flex flex-column bg-card bg-cover rounded-lg"
>
<div
class=
"mine-card flex flex-column bg-card bg-cover rounded-lg"
>
<div
class=
"text-sm text-left pb-3
"
>
当前地址:
{{
addr
}}
</div>
<div
class=
"text-sm text-left pb-3
tracking-normal hide"
>
当前地址:
{{
addr
}}
</div>
<div
class=
"flex items-center justify-between"
>
<div
class=
"flex items-center justify-between"
>
<div>
<div>
<p
class=
"text-xs text-brown"
>
可领收益
</p>
<p
class=
"text-xs text-brown"
>
可领收益
</p>
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
</div>
</div>
<div>
<div>
<p
class=
"text-xs text-brown"
>
参与票数
</p>
<p
class=
"text-xs text-brown"
>
参与票数
</p>
<p
class=
"text-3xl text-red1"
>
{{
100
}}
</p>
<p
class=
"text-3xl text-red1"
>
{{
ticketNum
}}
</p>
</div>
</div>
<button
<button
class=
"bg-gradient-2 w-20 h-8 leading-8 rounded-full text-sm text-white"
class=
"bg-gradient-2 w-20 h-8 leading-8 rounded-full text-sm text-white"
...
@@ -37,12 +37,14 @@
...
@@ -37,12 +37,14 @@
</div>
</div>
<div>
<div>
<template
v-if=
"lists.length > 0"
>
<template
v-if=
"lists.length > 0"
>
<van-pull-refresh
<div
class=
"no-content"
>
v-model=
"isLoading"
<van-pull-refresh
success-text=
"刷新成功"
v-model=
"isLoading"
@
refresh=
"onRefresh"
>
success-text=
"刷新成功"
<MiningCard
v-for=
"(i, index) in lists"
:key=
"index"
:info=
"i"
/>
@
refresh=
"onRefresh"
>
</van-pull-refresh>
<MiningCard
v-for=
"(i, index) in lists"
:key=
"index"
:info=
"i"
/>
</van-pull-refresh>
</div>
</
template
>
</
template
>
<
template
v-else
>
<
template
v-else
>
<div
class=
"no-content text-white flex items-center justify-center"
>
<div
class=
"no-content text-white flex items-center justify-center"
>
...
@@ -67,7 +69,7 @@ import { Icon, PullRefresh, Toast, Popup, List } from 'vant'
...
@@ -67,7 +69,7 @@ import { Icon, PullRefresh, Toast, Popup, List } from 'vant'
import
MiningCard
from
'@/components/MiningCard.vue'
import
MiningCard
from
'@/components/MiningCard.vue'
import
Vue
from
'vue'
import
Vue
from
'vue'
import
service
from
'@/service/chain33'
import
service
from
'@/service/chain33'
import
{
invitePool
,
poolList
}
from
'@/service/pool'
import
{
invitePool
,
poolList
,
userMinedData
}
from
'@/service/pool'
export
default
Vue
.
extend
({
export
default
Vue
.
extend
({
components
:
{
components
:
{
'van-icon'
:
Icon
,
'van-icon'
:
Icon
,
...
@@ -87,10 +89,12 @@ export default Vue.extend({
...
@@ -87,10 +89,12 @@ export default Vue.extend({
waiter
:
18000
,
waiter
:
18000
,
page
:
1
,
page
:
1
,
pageSize
:
10
,
pageSize
:
10
,
ticketNum
:
0
,
profit
:
0
,
profit
:
0
,
fee
:
0
,
fee
:
0
,
show
:
false
,
show
:
false
,
val
:
''
val
:
''
,
refresh
:
false
}
}
},
},
methods
:
{
methods
:
{
...
@@ -102,15 +106,21 @@ export default Vue.extend({
...
@@ -102,15 +106,21 @@ export default Vue.extend({
if
(
res
.
data
.
data
.
isSucc
)
{
if
(
res
.
data
.
data
.
isSucc
)
{
this
.
$toast
(
'添加成功'
)
this
.
$toast
(
'添加成功'
)
this
.
show
=
false
this
.
show
=
false
this
.
getList
()
this
.
getTicket
()
}
}
})
})
},
},
getFee
()
{
getFee
()
{
service
.
getProperFee
(
0
,
0
).
then
(
res
=>
{
service
.
getProperFee
(
0
,
0
).
then
(
res
=>
{
console
.
log
(
res
)
this
.
fee
=
res
.
data
.
result
.
properFee
this
.
fee
=
res
.
data
.
result
.
properFee
})
})
},
},
getTicket
()
{
userMinedData
().
then
(
res
=>
{
this
.
ticketNum
=
res
.
data
.
data
.
tickets
})
},
getList
()
{
getList
()
{
poolList
({
poolList
({
page
:
this
.
page
,
page
:
this
.
page
,
...
@@ -118,22 +128,23 @@ export default Vue.extend({
...
@@ -118,22 +128,23 @@ export default Vue.extend({
limit
:
10000
limit
:
10000
}).
then
((
res
:
any
)
=>
{
}).
then
((
res
:
any
)
=>
{
console
.
log
(
res
)
console
.
log
(
res
)
if
(
this
.
refresh
)
{
this
.
refresh
=
false
this
.
lists
=
[]
}
res
.
data
.
data
?.
list
?
this
.
lists
.
push
(...
res
.
data
.
data
?.
list
)
:
this
.
lists
=
[]
res
.
data
.
data
?.
list
?
this
.
lists
.
push
(...
res
.
data
.
data
?.
list
)
:
this
.
lists
=
[]
this
.
count
=
+
res
.
data
.
data
.
count
this
.
count
=
+
res
.
data
.
data
.
count
document
.
addEventListener
(
'scroll'
,
this
.
scrollEvent
)
document
.
addEventListener
(
'scroll'
,
this
.
scrollEvent
)
}).
catch
(
e
=>
{
}).
catch
(
e
=>
{
console
.
log
(
e
)
const
err
=
e
.
response
const
err
=
e
.
response
if
(
err
.
data
.
code
===
406
&&
err
.
data
.
reason
===
'USER_NOT_BIND'
)
{
if
(
err
.
data
?.
code
===
406
&&
err
.
data
?
.
reason
===
'USER_NOT_BIND'
)
{
this
.
show
=
true
this
.
show
=
true
}
}
})
})
this
.
isLoading
=
false
this
.
isLoading
=
false
},
},
getInfo
()
{
getInfo
()
{
Toast
.
loading
({
duration
:
0
,
forbidClick
:
true
})
service
.
getBalance
(
this
.
$store
.
state
.
app
.
address
,
'ticket'
).
then
((
res
:
any
)
=>
{
service
.
getBalance
(
this
.
$store
.
state
.
app
.
address
,
'ticket'
).
then
((
res
:
any
)
=>
{
console
.
log
(
res
)
console
.
log
(
res
)
this
.
profit
=
Math
.
floor
((
res
.
data
.
result
as
any
)[
0
].
balance
/
1
e8
)
this
.
profit
=
Math
.
floor
((
res
.
data
.
result
as
any
)[
0
].
balance
/
1
e8
)
...
@@ -146,30 +157,70 @@ export default Vue.extend({
...
@@ -146,30 +157,70 @@ export default Vue.extend({
})
})
})
})
},
},
getIncome
()
{
async
getIncome
()
{
//
if (!this.profit) {
if
(
!
this
.
profit
)
{
//
this.$toast('当前无收益可领')
this
.
$toast
(
'当前无收益可领'
)
//
return
return
//
}
}
this
.
btnText
=
'领取中'
this
.
btnText
=
'领取中'
this
.
btnType
=
true
this
.
btnType
=
true
service
.
createRawTransaction
({
Toast
.
loading
({
message
:
'领取中'
,
forbidClick
:
true
,
duration
:
0
})
const
b
=
await
service
.
createTransaction
({
to
:
'16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp'
,
to
:
'16htvcBNSEA7fZhAdLJphDwQRQJaHpyHTp'
,
//
amount: this.profit * 1e8,
amount
:
this
.
profit
*
1
e8
,
amount
:
1
e8
*
0
,
// amount: 1e8 * 1
,
fee
:
this
.
fee
,
fee
:
this
.
fee
,
note
:
'ticket -> coins'
,
note
:
'ticket -> coins'
,
isWithdraw
:
true
,
isWithdraw
:
true
,
execName
:
'ticket'
execName
:
'ticket'
},
()
=>
{
})
console
.
log
(
'success'
)
await
service
.
signTransition
((
b
as
any
).
data
.
result
,
async
(
sign
:
any
)
=>
{
this
.
btnText
=
'领取收益'
let
s
=
{}
as
any
this
.
btnType
=
false
if
(
typeof
sign
===
'string'
)
{
this
.
getInfo
()
s
=
JSON
.
parse
(
sign
)
},
()
=>
{
}
else
{
console
.
log
(
'fail'
)
s
=
sign
this
.
btnText
=
'领取收益'
}
this
.
btnType
=
false
if
(
s
.
error
)
{
Toast
.
clear
()
this
.
btnText
=
'领取收益'
this
.
btnType
=
false
return
}
const
send
=
await
service
.
sendTransaction
(
s
.
signHash
)
if
(
send
.
data
.
error
)
{
Toast
(
send
.
data
.
error
)
this
.
btnText
=
'领取收益'
this
.
btnType
=
false
return
}
let
res
=
{}
as
any
const
timer
=
setInterval
(
async
()
=>
{
res
=
await
service
.
getTransaction
(
send
.
data
.
result
)
if
(
!
res
.
data
.
error
)
{
clearInterval
(
timer
)
if
(
res
.
data
.
result
.
receipt
.
ty
===
1
)
{
Toast
({
message
:
'领取失败'
,
duration
:
3000
})
this
.
btnText
=
'领取收益'
this
.
btnType
=
false
}
else
{
Toast
({
message
:
'领取成功'
,
duration
:
3000
})
this
.
btnText
=
'领取收益'
this
.
btnType
=
false
this
.
getInfo
()
}
}
},
1000
)
})
})
},
},
goMining
()
{
goMining
()
{
...
@@ -177,7 +228,7 @@ export default Vue.extend({
...
@@ -177,7 +228,7 @@ export default Vue.extend({
},
},
onRefresh
()
{
onRefresh
()
{
this
.
page
=
1
this
.
page
=
1
this
.
lists
=
[]
this
.
refresh
=
true
this
.
getList
()
this
.
getList
()
},
},
scrollEvent
()
{
scrollEvent
()
{
...
@@ -199,11 +250,12 @@ export default Vue.extend({
...
@@ -199,11 +250,12 @@ export default Vue.extend({
}
}
},
},
mounted
()
{
mounted
()
{
this
.
addr
=
this
.
$store
.
state
.
app
.
address
const
that
=
this
const
that
=
this
this
.
getList
()
this
.
getList
()
this
.
getInfo
()
this
.
getInfo
()
this
.
getFee
()
this
.
getFee
()
// document.addEventListener('scroll', that.scrollEvent
)
this
.
getTicket
(
)
},
},
beforeDestroy
()
{
beforeDestroy
()
{
const
that
=
this
const
that
=
this
...
@@ -281,6 +333,11 @@ export default Vue.extend({
...
@@ -281,6 +333,11 @@ export default Vue.extend({
.no-content
{
.no-content
{
height
:
calc
(
100vh
-
320px
)
height
:
calc
(
100vh
-
320px
)
}
}
.hide
{
overflow
:
hidden
;
text-overflow
:
ellipsis
;
white-space
:
nowrap
;
}
/
deep
/
.van-pull-refresh
{
/
deep
/
.van-pull-refresh
{
overflow
:
inherit
;
overflow
:
inherit
;
}
}
...
...
src/views/Mine.vue
View file @
c064f79c
...
@@ -41,38 +41,62 @@ export default Vue.extend({
...
@@ -41,38 +41,62 @@ export default Vue.extend({
return
{
return
{
active
:
1
,
active
:
1
,
isLoading
:
false
,
isLoading
:
false
,
all
:
[],
// onLine: [],
// offLine: [],
lists
:
[],
lists
:
[],
page
:
1
,
page
:
1
,
pageSize
:
10
pageSize
:
10
,
count
:
0
,
status
:
2
// 2 在线 1 离线
}
}
},
},
methods
:
{
methods
:
{
getList
()
{
getList
()
{
console
.
log
(
'run'
)
this
.
isLoading
=
false
},
getNowList
()
{
userMachineList
({
userMachineList
({
page
:
this
.
page
,
page
:
this
.
page
,
pageSize
:
this
.
pageSize
,
pageSize
:
this
.
pageSize
,
limit
:
10000
status
:
2
}).
then
(
res
=>
{
}).
then
(
res
=>
{
console
.
log
(
res
)
this
.
count
=
+
res
.
data
.
data
.
count
this
.
all
=
res
.
data
.
data
.
list
||
[]
this
.
lists
=
res
.
data
.
data
.
list
||
[]
this
.
lists
=
this
.
all
.
filter
((
item
:
any
)
=>
item
.
status
!==
1
)
document
.
addEventListener
(
'scroll'
,
this
.
scrollEvent
)
})
})
this
.
isLoading
=
false
this
.
isLoading
=
false
},
},
getNowList
()
{
this
.
lists
=
this
.
all
.
filter
((
item
:
any
)
=>
item
.
status
!==
1
)
this
.
isLoading
=
false
},
getEndList
()
{
getEndList
()
{
this
.
lists
=
this
.
all
.
filter
((
item
:
any
)
=>
item
.
status
===
1
)
userMachineList
({
page
:
this
.
page
,
pageSize
:
this
.
pageSize
,
status
:
1
}).
then
(
res
=>
{
this
.
count
=
+
res
.
data
.
data
.
count
this
.
lists
=
res
.
data
.
data
.
list
||
[]
document
.
addEventListener
(
'scroll'
,
this
.
scrollEvent
)
})
this
.
isLoading
=
false
this
.
isLoading
=
false
},
},
onClickLeft
()
{
onClickLeft
()
{
this
.
$router
.
back
()
this
.
$router
.
back
()
},
},
scrollEvent
()
{
const
e
=
document
.
querySelector
(
'.mining-card'
)
const
g
=
(
e
as
HTMLElement
)?.
offsetHeight
const
h
=
document
.
documentElement
?.
scrollTop
||
document
.
body
.
scrollTop
if
(
this
.
lists
.
length
<
this
.
count
)
{
if
(
h
>
(
g
*
this
.
page
*
(
this
.
pageSize
-
3
)))
{
this
.
page
++
this
.
getList
()
}
}
},
onRefresh
()
{
onRefresh
()
{
this
.
page
=
1
this
.
pageSize
=
10
if
(
this
.
active
===
1
)
{
if
(
this
.
active
===
1
)
{
this
.
getNowList
()
this
.
getNowList
()
}
else
{
}
else
{
...
@@ -81,6 +105,7 @@ export default Vue.extend({
...
@@ -81,6 +105,7 @@ export default Vue.extend({
},
},
setTab
(
n
:
number
)
{
setTab
(
n
:
number
)
{
this
.
active
=
n
this
.
active
=
n
this
.
lists
=
[]
if
(
this
.
active
===
1
)
{
if
(
this
.
active
===
1
)
{
this
.
getNowList
()
this
.
getNowList
()
}
else
{
}
else
{
...
@@ -89,7 +114,11 @@ export default Vue.extend({
...
@@ -89,7 +114,11 @@ export default Vue.extend({
}
}
},
},
mounted
()
{
mounted
()
{
this
.
getList
()
// this.getList()
this
.
getNowList
()
},
beforeDestroy
()
{
document
.
removeEventListener
(
'scroll'
,
this
.
scrollEvent
)
}
}
})
})
</
script
>
</
script
>
...
...
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