Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
blindBox-vue
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
haojie
blindBox-vue
Commits
a30223ad
Commit
a30223ad
authored
Mar 10, 2023
by
haojie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
a5f84f81
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
114 additions
and
67 deletions
+114
-67
src/assets/img/bk_wallet.png
+0
-0
src/assets/svg/dialog/bk.svg
+0
-0
src/components/Foxwallet/index.less
+3
-0
src/components/Foxwallet/index.tsx
+46
-17
src/pages/raffle/components/ActivityDetail/index.tsx
+17
-3
src/store/FoxWallet.ts
+1
-0
src/utils/ethers.ts
+47
-47
No files found.
src/assets/img/bk_wallet.png
0 → 100644
View file @
a30223ad
830 Bytes
src/assets/svg/dialog/bk.svg
0 → 100644
View file @
a30223ad
This diff is collapsed.
Click to expand it.
src/components/Foxwallet/index.less
View file @
a30223ad
...
...
@@ -34,6 +34,9 @@
margin-left: 12px;
}
}
& > :not(:first-child) {
margin-top: 12px;
}
}
}
}
...
...
src/components/Foxwallet/index.tsx
View file @
a30223ad
...
...
@@ -3,10 +3,12 @@ import { useFoxDialog } from '@/store/dialog';
import
'./index.less'
;
import
CloseSvg
from
'@/assets/svg/dialog/close.svg'
;
import
FoxSvg
from
'@/assets/svg/dialog/fox.svg'
;
import
BkSvg
from
'@/assets/img/bk_wallet.png'
;
import
{
MessagePlugin
}
from
'tdesign-vue-next'
;
import
Loading
from
'../Loading'
;
import
{
useFoxWallet
}
from
'@/store/FoxWallet'
;
import
{
useI18n
}
from
'vue-i18n'
;
import
{
Connect_Fox_tp_wallet
,
Connect_BK_wallet
}
from
'@/utils/ethers'
;
export
default
defineComponent
({
setup
(
props
)
{
const
{
$state
:
foxDialog
}
=
useFoxDialog
();
...
...
@@ -20,8 +22,13 @@ export default defineComponent({
{
icon
:
<
FoxSvg
></
FoxSvg
>,
label
:
'MetaMask Wallet'
,
value
:
''
,
value
:
'
fox
'
,
},
// {
// icon: <img src={BkSvg} alt="" />,
// label: 'BitKeep',
// value: 'bk',
// },
],
});
const
dialogHead
=
()
=>
{
...
...
@@ -30,23 +37,19 @@ export default defineComponent({
const
closeIcon
=
()
=>
{
return
<
CloseSvg
></
CloseSvg
>;
};
// 连接小狐狸或tp
const
getConnectFox
=
async
(
tooltip
:
boolean
)
=>
{
// 这里是用户主动连接,临时存储到本地,刷新页面时自动赋值
let
eth
:
any
=
window
;
try
{
const
accounts
=
await
eth
.
ethereum
.
request
({
method
:
'eth_requestAccounts'
,
});
if
(
accounts
[
0
])
{
userAddress
.
address
=
accounts
[
0
];
userAddress
.
MaskAddress
=
`
${
accounts
[
0
].
slice
(
0
,
6
)}
...
${
accounts
[
0
].
slice
(
accounts
[
0
].
length
-
4
,
accounts
[
0
].
length
)}
`
;
window
.
sessionStorage
.
setItem
(
'ConnectFox'
,
'true'
);
// 连接小狐狸或tp
let
address_list
=
await
Connect_Fox_tp_wallet
();
if
(
address_list
.
address
)
{
userAddress
.
address
=
address_list
.
address
;
userAddress
.
MaskAddress
=
address_list
.
MaskAddress
;
userAddress
.
value
=
'fox'
;
// 记录上次连接的钱包
window
.
sessionStorage
.
setItem
(
'ConnectFox'
,
'fox'
);
}
if
(
tooltip
)
{
MessagePlugin
.
closeAll
();
...
...
@@ -65,12 +68,35 @@ export default defineComponent({
console
.
log
(
e
);
}
};
const
CustConnectBk
=
async
(
tooltip
:
boolean
)
=>
{
try
{
let
address_list
:
any
=
await
Connect_BK_wallet
();
if
(
address_list
.
address
)
{
userAddress
.
address
=
address_list
.
address
;
userAddress
.
MaskAddress
=
address_list
.
MaskAddress
;
userAddress
.
value
=
'bk'
;
// 记录上次连接的钱包
window
.
sessionStorage
.
setItem
(
'ConnectFox'
,
'bk'
);
if
(
tooltip
)
{
MessagePlugin
.
closeAll
();
MessagePlugin
.
success
(
t
(
'header.connectSuccess'
));
}
}
}
catch
(
e
)
{
console
.
log
(
e
);
}
};
// 连接钱包
const
ToConnectWallet
=
async
(
item
:
any
)
=>
{
try
{
loading
.
value
=
false
;
// 连接钱包--主动连接--需要提示文字
getConnectFox
(
true
);
if
(
item
.
value
==
'fox'
)
{
// 连接钱包--主动连接--需要提示文字
getConnectFox
(
true
);
}
else
if
(
item
.
value
==
'bk'
)
{
// 连接bk
CustConnectBk
(
true
);
}
}
catch
(
e
)
{
console
.
log
(
e
);
loading
.
value
=
false
;
...
...
@@ -79,9 +105,12 @@ export default defineComponent({
// 自动连接--
const
custConnect
=
()
=>
{
let
ConnectFox
=
window
.
sessionStorage
.
getItem
(
'ConnectFox'
);
if
(
ConnectFox
==
'
true
'
)
{
if
(
ConnectFox
==
'
fox
'
)
{
// 不显示提示文字
getConnectFox
(
false
);
}
else
if
(
ConnectFox
==
'bk'
)
{
// 连接bk
CustConnectBk
(
false
);
}
};
onMounted
(()
=>
{
...
...
src/pages/raffle/components/ActivityDetail/index.tsx
View file @
a30223ad
...
...
@@ -14,7 +14,7 @@ import {
}
from
'@/utils/api/BlindBox'
;
import
{
useRoute
}
from
'vue-router'
;
import
{
useI18n
}
from
'vue-i18n'
;
import
{
fox_EtherPay
}
from
'@/utils/ethers'
;
import
{
fox_EtherPay
,
bk_EtherPay
}
from
'@/utils/ethers'
;
import
Loading
from
'@/components/Loading'
;
export
default
defineComponent
({
props
:
{
...
...
@@ -92,6 +92,7 @@ export default defineComponent({
}
}
};
// 小狐狸-tp支付
const
send_token
=
async
()
=>
{
let
hash
:
any
=
await
fox_EtherPay
(
FoxWallet
.
to
,
props
.
info
.
price
);
if
(
hash
)
{
...
...
@@ -100,14 +101,27 @@ export default defineComponent({
recharge
(
hash
,
parseInt
(
props
.
info
.
price
));
}
};
// bk-支付
const
send_bk_token
=
async
()
=>
{
let
hash
:
any
=
await
bk_EtherPay
(
FoxWallet
.
to
,
props
.
info
.
price
);
if
(
hash
)
{
UserHash
.
value
=
hash
;
// 发送充值信息
recharge
(
hash
,
parseInt
(
props
.
info
.
price
));
}
};
// 支付
const
Payment
=
()
=>
{
if
(
!
FoxWallet
.
to
)
{
MessagePlugin
.
warning
(
t
(
'raffle.Missingpayment'
));
return
;
}
// ethers
send_token
();
if
(
FoxWallet
.
value
==
'fox'
)
{
// ethers
send_token
();
}
else
if
(
FoxWallet
.
value
==
'bk'
)
{
send_bk_token
();
}
};
const
getUserBuyStatus
=
async
()
=>
{
try
{
...
...
src/store/FoxWallet.ts
View file @
a30223ad
...
...
@@ -6,6 +6,7 @@ export const useFoxWallet = defineStore('FoxWallet', {
address
:
''
,
MaskAddress
:
''
,
to
:
''
,
value
:
''
,
};
},
});
src/utils/ethers.ts
View file @
a30223ad
import
{
ethers
}
from
'ethers'
;
import
{
MessagePlugin
}
from
'tdesign-vue-next'
;
import
ERC20ABI
from
'./ERC20ABI.json'
;
// 发起交易
let
eth
:
any
=
window
;
// 发起交易--小狐狸-tp支付
export
const
fox_EtherPay
=
async
(
to
:
string
,
price
:
number
)
=>
{
try
{
let
eth
:
any
=
window
;
// 代币地址
const
USDT
=
'0xc5a25e92e691635BDd6DF2e904633Dc3152360cD'
;
const
provider
=
new
ethers
.
providers
.
Web3Provider
(
eth
.
ethereum
);
...
...
@@ -34,49 +35,48 @@ export const fox_EtherPay = async (to: string, price: number) => {
}
};
export
interface
MyWalletOptions
{
chains
:
any
[];
shimDisconnect
?:
boolean
;
}
// const TokenPocket = ({ chains, shimDisconnect }: MyWalletOptions) => {
// let eth: any = window;
// let tpEtheruem = typeof eth !== 'undefined' ? eth.ethereum : undefined;
// const isTokenPocketInjected =
// typeof tpEtheruem !== 'undefined' && tpEtheruem?.isTokenPocket === true;
// const shouldUseWalletConnect = !isBrowser && !isTokenPocketInjected;
// return {
// id: 'Token Pocket',
// name: 'Token Pocket',
// iconUrl: TokenpocketSVG,
// iconBackground: 'transparent',
// installed: !shouldUseWalletConnect ? isTokenPocketInjected : undefined,
// downloadUrls: {
// android:
// 'https://play.google.com/store/apps/details?id=vip.mytokenpocket',
// ios: 'https://apps.apple.com/cn/app/tokenpocket-trusted-wallet/id1436028697',
// browserExtension:
// 'https://chrome.google.com/webstore/detail/tokenpocket/mfgccjchihfkkindfppnaooecgfneiii',
// qrCode:
// 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARgAAAEYAQMAAAC9QHvPAAAABlBMVEX///8AAABVwtN+AAACj0lEQVRo3uWawbHDIAxEN+ODj5RAKe4s5nfmUlyCjz4w1tcukNSAwkwSC54OCAkkHERti7FdeCNZcXmDP/x5x77cWWMlLnMDWK/NKrK5woHVBO9254NKszLZnvXCy7yxi7/PcmUX8uFW+QHmzW6zE3Zj+6vuBDUEg8XOXc59p+Nl3oEfYJrPF8ayC5scoALoPj8rY2wXl9rn7t3P+hU0FpfpbSvLMIsZ1z1/hjAtw+7dLj6cLqbjDeRiPncKcZlv+LZ4loJ6nfMRYE6GT4plH985/gB9wyLMCI/NIMkkhbHc8yjapttnSsZnOdIH7HX1BxlCCoDmHpbBeoI+j8H07mx1PbdntUmZ7zGb+H3Cg9o/UpBzb8EZ//QSBzIWlYq58CDZtAy0utybsRrHDwA8c6UNxGXslBUeANqSP8kHXFO58aRMa1p3ePhChrioQCEyw662uulE5aZmKvwwomFipq9wLhVy7uO9WFegdliGEq1gLHHY9XI3f0YOqQCYkmEFrunCmSpBhsDOcU8sAjPdPvBxgDnkS8XPuKCxqRmXH4hTbkwhlzESl+Exa3f6bsmj6Bu3UNuczKJriHZ/WOjcqs3F9DwqNvMwasnQPgxsAN3nncOcjH9rdUdKqPCVIQQHZzyrSFzuUz5PjsttdreHMiUDjC3ZzlHQqqgrIz8Mzui1RrtWU8lOoVBBlpuSGXsU575j7QcQk0XzpnUPy/TWwld3p+NsUv3uI3Myi7H1PcpGUtXuJfROKjLT3lvxbBIjn6dg3T7ApEzLliRxumLk096UYUVn8KpQDetwOobPbyz85mb2mrybwviPR237s0VmAOg/A94NZGO3LoipDUzLGBsZMx2z4/LlmyiHZX64/QPNL9thE1XE0AAAAABJRU5ErkJggg==',
// },
// createConnector: () => {
// const connector = shouldUseWalletConnect
// ? getWalletConnectConnector({ chains })
// : new InjectedConnector({ chains, options: { shimDisconnect } });
export
const
bk_EtherPay
=
async
(
to
:
string
,
price
:
number
)
=>
{
try
{
}
catch
(
e
)
{
console
.
log
(
e
);
}
};
// 是否安装小狐狸钱包插件
export
const
CanNotDownLoadFoxWallet
=
()
=>
{};
// 连接小狐狸或tp钱包
export
const
Connect_Fox_tp_wallet
=
async
()
=>
{
const
accounts
=
await
eth
.
ethereum
.
request
({
method
:
'eth_requestAccounts'
,
});
return
address_filter
(
accounts
);
};
// 连接bk钱包
export
const
Connect_BK_wallet
=
async
()
=>
{
const
provider
=
eth
.
bitkeep
&&
eth
.
bitkeep
.
ethereum
;
if
(
!
provider
)
{
MessagePlugin
.
warning
(
'尚未安装BitKeep'
);
return
;
}
// 连接钱包
const
accounts
=
await
provider
.
request
({
method
:
'eth_requestAccounts'
});
return
address_filter
(
accounts
);
};
//
return {
// connector,
// mobile:
{
// getUri: shouldUseWalletConnect
// ? async () => {
// const connectorInfo: any = await connector.getProvider();
// return `tpoutside://wc?uri=${encodeURIComponent(
// connectorInfo?.connector?.uri
// )}`;
// }
// : undefined,
// },
// };
// }
,
//
};
//
};
//
地址过滤
export
const
address_filter
=
(
accounts
:
string
[])
=>
{
if
(
accounts
&&
accounts
[
0
])
{
return
{
address
:
accounts
[
0
],
MaskAddress
:
`
${
accounts
[
0
].
slice
(
0
,
6
)}
...
${
accounts
[
0
].
slice
(
accounts
[
0
].
length
-
4
,
accounts
[
0
].
length
)}
`
,
};
}
return
{
address
:
''
,
MaskAddress
:
''
,
};
};
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