USER-20230908AJ\Administrator 6 сар өмнө
parent
commit
020756e900

+ 1 - 0
App.vue

@@ -7,6 +7,7 @@ export default {
   onLaunch: function () {
     console.log("App Launch");
    let bnbObj= tokenpocketBnb.getProvider()
+    console.log(bnbObj)
     bnbObj.on('accountsChanged',(accounts)=>{
       if(accounts.length<=0){
         uni.reLaunch({

+ 1 - 1
common/router/router.js

@@ -9,7 +9,7 @@ const router = createRouter({
     routes: [...ROUTES]
 });
 //全局路由前置守卫
-const whiteList = ['/','/pages/login/register','/pages/login/index','/pages/login/invite','/pages/index/index']
+const whiteList = ['/pages/login/register','/pages/login/index','/pages/login/invite']
 
 router.beforeEach((to, from, next) => {
     if(to.path!=='/pages/index/error'){

+ 0 - 276
common/wallet/bitkeep-wallet/bitkeep-lucky.js

@@ -1,276 +0,0 @@
-/**
- * bitkeep钱包的tron
- * @type {{}}
- */
-import tools from "@/common/js/tools";
-import {ethers} from "ethers";
-import web3 from "web3";
-
-let bitkeepLucky = {}
-
-let contractArr=[
-    '0x10186d85ac0579cb141ff37261f23cf4f1d254b5'
-];
-const chainId='0x3e6'
-
-
-let provider=null
-/**
- * 钱包初始校验
- * @returns {*}
- */
-bitkeepLucky.getProvider= function (){
-    console.log(window.bitkeep.ethereum)
-    if(!provider){
-        provider = window.bitkeep && window.bitkeep.ethereum;
-        if (!provider) {
-            return window.open('https://bitkeep.com/en/download?type=2');
-        }
-    }
-    if(provider.chainId==='0x73'){
-        // window.bitkeep.ethereum.rpc.rpcUrl='http://luckychain.win/rpc/'
-        provider.rpc.rpcUrl='http://luckychain.win/rpc/'
-    }else {
-        uni.$emit('noLucky',false)
-    }
-    // console.log(provider)
-    return provider;
-}
-
-
-bitkeepLucky.test=function (){
-    provider=bitkeepLucky.getProvider()
-    console.log(provider.isConnected())
-}
-
-/**
- * 获取我登陆的地址
- * @returns {any}
- */
-bitkeepLucky.getMyAddress=function () {
-   return  uni.getStorageSync('luckyAddress')
-}
-
-/**
- * 获取基本账户地址
- * @returns {Promise<unknown>}
- */
-bitkeepLucky.getAccounts=async function (){
-
-    return new Promise( (resolve, reject) => {
-        try {
-            bitkeepLucky.getProvider().request({ method: 'eth_requestAccounts'})
-            .then((address)=>{
-                if(address.length>0){
-                    uni.setStorageSync('luckyAddress',address[0])
-                    resolve(address[0])
-                }else {
-                    resolve(false)
-                }
-            })
-            .catch((e)=>{
-                console.log(e)
-            })
-        }catch (e) {
-            reject(e)
-        }
-    })
-}
-
-
-/**
- * 获取我的余额
- * @param selectedAddress
- * @returns {Promise<unknown>}
- */
-bitkeepLucky.getBalance=async function (selectedAddress) {
-    if(!selectedAddress){
-        selectedAddress=bitkeepLucky.getMyAddress();
-    }
-    console.log('selectedAddress:'+selectedAddress)
-    // alert('钱包地址:'+selectedAddress)
-    return new Promise( (resolve, reject) => {
-        try {
-            if(!selectedAddress){
-                resolve(0)
-            }else {
-                bitkeepLucky.getProvider().request({ method: 'eth_getBalance',params:[selectedAddress, "latest"]})
-                    .then((balance)=>{
-                        balance= ethers.utils.formatEther(balance.toString())
-                        // alert(JSON.stringify(balance))
-                        // console.log(balance)
-                        console.log('getBalance:'+balance)
-                        resolve(balance)
-                    })
-                    .catch((e)=>{
-                        resolve(0)
-                    })
-            }
-
-        }catch (e) {
-            // alert('error:'+JSON.stringify(e))
-            reject(e)
-        }
-    })
-}
-
-
-
-/**
- * 获取合约数量
- * @param selectedAddress
- * @param contractType
- * @returns {Promise<number>}
- */
-bitkeepLucky.getTokenBalance=async function (selectedAddress,contractType) {
-    if(!contractType){
-        contractType=0
-    }
-    if(!selectedAddress){
-        selectedAddress=bitkeepLucky.getMyAddress();
-    }
-    let data='0x70a08231000000000000000000000000'+(selectedAddress.substring(2))
-    console.log(web3.utils.isHex(`0x70a08231`))
-    console.log(data)
-    return new Promise( (resolve, reject) => {
-        try {
-            let data='0x70a08231000000000000000000000000'+(selectedAddress.substring(2))
-            bitkeepLucky.getProvider().request({method: 'eth_call',params:[{'to':contractArr[contractType],'data':data}, "latest"]}).then((balance)=>{
-                console.log('hexToNumber:-----------------'+balance)
-                console.log(web3.utils.hexToNumber(balance))
-                balance= (web3.utils.hexToNumber(balance)/1000000).toString()
-                if(balance<0.000001){
-                    balance=0
-                }
-                resolve(balance)
-            }).catch((e)=>{
-                resolve(0)
-            })
-        }catch (e) {
-            // alert('error:'+JSON.stringify(e))
-            reject(e)
-        }
-    })
-}
-
-
-
-/**
- * 获取合约信息
- * @param contractType
- * @returns {Promise<boolean|*>}
- */
-bitkeepLucky.getContract=async function () {
-
-}
-
-
-/**
- * 合约转账
- * @param to
- * @param money
- * @param contractType
- */
-bitkeepLucky.getContractData=async function (to,money,contractType){
-    // console.log(ethers.utils.getAddress(to))
-    if(!contractType){
-        contractType=0
-    }
-    let data={};
-    console.log('web3----------------------------------------')
-
-    money*=1000000
-    money=web3.utils.numberToHex(money)
-    money=tools.replenishZero(money)
-    console.log(money)
-    console.log(`transfer(${to},${money})`)
-    console.log( web3.utils.sha3(`transfer(${to.substring(2)},${money})`))
-    // console.log(ethers.utils.parseEther(money).toString())
-    data.data='0xa9059cbb'+tools.replenishZero(to)+tools.replenishZero(money);
-    // console.log(data.data)
-    // console.log('0xa9059cbb'+(to.substring(2)))
-    data.to=contractArr[contractType];
-    data.from=bitkeepLucky.getMyAddress();
-    data.gasPrice=await bitkeepLucky.getGasPrice();
-    data.gasLimit=await bitkeepLucky.getEstimateGas();
-    data.chainId=chainId;
-    data.value= '0x0'
-    return data;
-}
-
-
-/**
- * 获取gasPrice
- * @returns {Promise<unknown>}
- */
-bitkeepLucky.getGasPrice= async function (){
-    let gasPrice =await    bitkeepLucky.getProvider().request({ method: 'eth_gasPrice',params:[]})
-    if(!gasPrice){
-        gasPrice='0x0'
-    }
-    return gasPrice;
-}
-
-/**
- * 获取燃料数量
- * @param data
- * @returns {Promise<unknown>}
- */
-bitkeepLucky.getEstimateGas= async function (data){
-    let estimateGas =await   bitkeepLucky.getProvider().request({ method: 'eth_estimateGas',params:[data]})
-    console.log('estimateGas:'+estimateGas)
-    if(!estimateGas){
-        estimateGas=100000
-    }
-    return estimateGas;
-}
-
-/**
- * 转账接口
- * @param to
- * @param money
- * @returns {{}}
- */
-bitkeepLucky.getTransactionData=async function (to,money){
-    let data={};
-    data.data='0x0';
-    data.to=to;
-    data.from=bitkeepLucky.getMyAddress();
-    data.gasPrice=await bitkeepLucky.getGasPrice();
-    data.gasLimit=await bitkeepLucky.getEstimateGas();
-    data.chainId=chainId;
-    if(tools.isDevelopment()){
-        money=0.001;
-    }
-    data.value= web3.utils.numberToHex(ethers.utils.parseEther(money.toString()).toString());
-    console.log('value:'+data.value)
-    return data;
-}
-
-/**
- * 转账
- * @param data
- * @returns {Promise<unknown>}
- */
-bitkeepLucky.sendTransaction=function (data){
-    return new Promise(async (resolve, reject) => {
-        try {
-            let txHash = await  bitkeepLucky.getProvider().request({
-                method: 'eth_sendTransaction',
-                params: [data],
-            });
-            console.log('txHash:'+txHash)
-            if(txHash){
-                resolve(txHash)
-            }else {
-                reject(false)
-            }
-         }catch (e) {
-           reject(false)
-        }
-    })
-}
-
-
-
-export default bitkeepLucky

+ 0 - 631
common/wallet/bitkeep-wallet/bitkeep-tron.js

@@ -1,631 +0,0 @@
-/**
- * bitkeep钱包的tron
- * @type {{}}
- */
-import tools from "@/common/js/tools";
-
-let bitkeepTron = {}
-
-let contractArr=[
-    'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',
-    'TTUzsY3UMVTwT8a7wmJ3P6ar7aj5ddjVsR',
-];
-const tronCrossAddress = "TTUzsY3UMVTwT8a7wmJ3P6ar7aj5ddjVsR";
-const tronCrossAbi = [
-    {
-        "anonymous": false,
-        "inputs": [
-            {
-                "indexed": true,
-                "internalType": "address",
-                "name": "_l1Token",
-                "type": "address"
-            },
-            {
-                "indexed": true,
-                "internalType": "address",
-                "name": "_l2Token",
-                "type": "address"
-            },
-            {
-                "indexed": true,
-                "internalType": "address",
-                "name": "_from",
-                "type": "address"
-            },
-            {
-                "indexed": false,
-                "internalType": "address",
-                "name": "_to",
-                "type": "address"
-            },
-            {
-                "indexed": false,
-                "internalType": "uint256",
-                "name": "_amount",
-                "type": "uint256"
-            },
-            {
-                "indexed": false,
-                "internalType": "bytes",
-                "name": "_data",
-                "type": "bytes"
-            }
-        ],
-        "name": "ERC20DepositInitiated",
-        "type": "event"
-    },
-    {
-        "anonymous": false,
-        "inputs": [
-            {
-                "indexed": true,
-                "internalType": "address",
-                "name": "_l1Token",
-                "type": "address"
-            },
-            {
-                "indexed": true,
-                "internalType": "address",
-                "name": "_l2Token",
-                "type": "address"
-            },
-            {
-                "indexed": true,
-                "internalType": "address",
-                "name": "_from",
-                "type": "address"
-            },
-            {
-                "indexed": false,
-                "internalType": "address",
-                "name": "_to",
-                "type": "address"
-            },
-            {
-                "indexed": false,
-                "internalType": "uint256",
-                "name": "_amount",
-                "type": "uint256"
-            },
-            {
-                "indexed": false,
-                "internalType": "bytes",
-                "name": "_data",
-                "type": "bytes"
-            }
-        ],
-        "name": "ERC20WithdrawalFinalized",
-        "type": "event"
-    },
-    {
-        "anonymous": false,
-        "inputs": [
-            {
-                "indexed": true,
-                "internalType": "address",
-                "name": "_from",
-                "type": "address"
-            },
-            {
-                "indexed": true,
-                "internalType": "address",
-                "name": "_to",
-                "type": "address"
-            },
-            {
-                "indexed": false,
-                "internalType": "uint256",
-                "name": "_amount",
-                "type": "uint256"
-            },
-            {
-                "indexed": false,
-                "internalType": "bytes",
-                "name": "_data",
-                "type": "bytes"
-            }
-        ],
-        "name": "ETHDepositInitiated",
-        "type": "event"
-    },
-    {
-        "anonymous": false,
-        "inputs": [
-            {
-                "indexed": true,
-                "internalType": "address",
-                "name": "_from",
-                "type": "address"
-            },
-            {
-                "indexed": true,
-                "internalType": "address",
-                "name": "_to",
-                "type": "address"
-            },
-            {
-                "indexed": false,
-                "internalType": "uint256",
-                "name": "_amount",
-                "type": "uint256"
-            },
-            {
-                "indexed": false,
-                "internalType": "bytes",
-                "name": "_data",
-                "type": "bytes"
-            }
-        ],
-        "name": "ETHWithdrawalFinalized",
-        "type": "event"
-    },
-    {
-        "anonymous": false,
-        "inputs": [
-            {
-                "indexed": true,
-                "internalType": "address",
-                "name": "previousOwner",
-                "type": "address"
-            },
-            {
-                "indexed": true,
-                "internalType": "address",
-                "name": "newOwner",
-                "type": "address"
-            }
-        ],
-        "name": "OwnershipTransferred",
-        "type": "event"
-    },
-    {
-        "inputs": [
-            {
-                "internalType": "address",
-                "name": "_l1Token",
-                "type": "address"
-            },
-            {
-                "internalType": "address",
-                "name": "_l2Token",
-                "type": "address"
-            },
-            {
-                "internalType": "uint256",
-                "name": "_amount",
-                "type": "uint256"
-            },
-            {
-                "internalType": "uint32",
-                "name": "_l2Gas",
-                "type": "uint32"
-            },
-            {
-                "internalType": "bytes",
-                "name": "_data",
-                "type": "bytes"
-            }
-        ],
-        "name": "depositERC20",
-        "outputs": [],
-        "stateMutability": "nonpayable",
-        "type": "function"
-    },
-    {
-        "inputs": [
-            {
-                "internalType": "address",
-                "name": "_l1Token",
-                "type": "address"
-            },
-            {
-                "internalType": "address",
-                "name": "_l2Token",
-                "type": "address"
-            },
-            {
-                "internalType": "address",
-                "name": "_to",
-                "type": "address"
-            },
-            {
-                "internalType": "uint256",
-                "name": "_amount",
-                "type": "uint256"
-            },
-            {
-                "internalType": "uint32",
-                "name": "_l2Gas",
-                "type": "uint32"
-            },
-            {
-                "internalType": "bytes",
-                "name": "_data",
-                "type": "bytes"
-            }
-        ],
-        "name": "depositERC20To",
-        "outputs": [],
-        "stateMutability": "nonpayable",
-        "type": "function"
-    },
-    {
-        "inputs": [
-            {
-                "internalType": "uint32",
-                "name": "_l2Gas",
-                "type": "uint32"
-            },
-            {
-                "internalType": "bytes",
-                "name": "_data",
-                "type": "bytes"
-            }
-        ],
-        "name": "depositETH",
-        "outputs": [],
-        "stateMutability": "payable",
-        "type": "function"
-    },
-    {
-        "inputs": [
-            {
-                "internalType": "address",
-                "name": "_to",
-                "type": "address"
-            },
-            {
-                "internalType": "uint32",
-                "name": "_l2Gas",
-                "type": "uint32"
-            },
-            {
-                "internalType": "bytes",
-                "name": "_data",
-                "type": "bytes"
-            }
-        ],
-        "name": "depositETHTo",
-        "outputs": [],
-        "stateMutability": "payable",
-        "type": "function"
-    },
-    {
-        "inputs": [
-            {
-                "internalType": "address",
-                "name": "",
-                "type": "address"
-            },
-            {
-                "internalType": "address",
-                "name": "",
-                "type": "address"
-            }
-        ],
-        "name": "deposits",
-        "outputs": [
-            {
-                "internalType": "uint256",
-                "name": "",
-                "type": "uint256"
-            }
-        ],
-        "stateMutability": "view",
-        "type": "function"
-    },
-    {
-        "inputs": [],
-        "name": "donateETH",
-        "outputs": [],
-        "stateMutability": "payable",
-        "type": "function"
-    },
-    {
-        "inputs": [
-            {
-                "internalType": "address",
-                "name": "_l1Token",
-                "type": "address"
-            },
-            {
-                "internalType": "address",
-                "name": "_l2Token",
-                "type": "address"
-            },
-            {
-                "internalType": "address",
-                "name": "_from",
-                "type": "address"
-            },
-            {
-                "internalType": "address",
-                "name": "_to",
-                "type": "address"
-            },
-            {
-                "internalType": "uint256",
-                "name": "_amount",
-                "type": "uint256"
-            },
-            {
-                "internalType": "bytes",
-                "name": "_data",
-                "type": "bytes"
-            }
-        ],
-        "name": "finalizeERC20Withdrawal",
-        "outputs": [],
-        "stateMutability": "nonpayable",
-        "type": "function"
-    },
-    {
-        "inputs": [
-            {
-                "internalType": "address",
-                "name": "_from",
-                "type": "address"
-            },
-            {
-                "internalType": "address",
-                "name": "_to",
-                "type": "address"
-            },
-            {
-                "internalType": "uint256",
-                "name": "_amount",
-                "type": "uint256"
-            },
-            {
-                "internalType": "bytes",
-                "name": "_data",
-                "type": "bytes"
-            }
-        ],
-        "name": "finalizeETHWithdrawal",
-        "outputs": [],
-        "stateMutability": "nonpayable",
-        "type": "function"
-    },
-    {
-        "inputs": [],
-        "name": "owner",
-        "outputs": [
-            {
-                "internalType": "address",
-                "name": "",
-                "type": "address"
-            }
-        ],
-        "stateMutability": "view",
-        "type": "function"
-    },
-    {
-        "inputs": [],
-        "name": "renounceOwnership",
-        "outputs": [],
-        "stateMutability": "nonpayable",
-        "type": "function"
-    },
-    {
-        "inputs": [
-            {
-                "internalType": "address",
-                "name": "newOwner",
-                "type": "address"
-            }
-        ],
-        "name": "transferOwnership",
-        "outputs": [],
-        "stateMutability": "nonpayable",
-        "type": "function"
-    },
-    {
-        "stateMutability": "payable",
-        "type": "receive"
-    }
-];
-/**
- * 钱包初始校验
- * @returns {*}
- */
-bitkeepTron.isInstall=function (){
-    return window.tronLink && window.tronWeb;
-}
-/**
- * 获取我登陆的地址
- * @returns {any}
- */
-bitkeepTron.getMyAddress=function () {
-   return  uni.getStorageSync('myAddress')
-}
-
-/**
- * 获取基本账户地址
- * @returns {Promise<unknown>}
- */
-bitkeepTron.getAccounts=async function (){
-    return new Promise(async (resolve, reject) => {
-        try {
-            await window.tronLink.request({method: "tron_requestAccounts"});
-            let selectedAddress = tronWeb.defaultAddress.base58;
-            uni.setStorageSync('myAddress',selectedAddress)
-            resolve(selectedAddress)
-        }catch (e) {
-            reject(e)
-        }
-    })
-}
-
-/**
- * 获取我的余额
- * @param selectedAddress
- * @returns {Promise<unknown>}
- */
-bitkeepTron.getBalance=async function (selectedAddress) {
-    if(!selectedAddress){
-        selectedAddress=bitkeepTron.getMyAddress();
-    }
-    let balance = await tronWeb.trx.getBalance(selectedAddress);
-    balance=balance/1000000;
-    return  balance
-}
-
-/**
- * 获取合约数量
- * @param selectedAddress
- * @param contractType
- * @returns {Promise<number>}
- */
-bitkeepTron.getTokenBalance=async function (selectedAddress,contractType) {
-    if(!selectedAddress){
-        selectedAddress=bitkeepTron.getMyAddress();
-    }
-    let tokenBalance = await tronWeb.transactionBuilder.triggerConstantContract(
-        contractArr[contractType],
-        "balanceOf(address)",
-        {},
-        [{ type: 'address', value: selectedAddress }],
-        tronWeb.defaultAddress.base58,
-    );
-    let balance = tokenBalance.constant_result[0];
-    balance= parseInt(balance, 16);
-    balance=balance/1000000;
-    return balance;
-}
-
-/**
- * 获取合约信息
- * @param contractType
- * @returns {Promise<boolean|*>}
- */
-bitkeepTron.getContract=async function (contractType) {
-    let contractData = await tronWeb.trx.getContract(contractArr[contractType])
-    console.log(contractData)
-    if(contractData.abi){
-        return contractData
-    }else {
-        return false
-    }
-}
-
-
-/**
- * 合约转账
- * @param to
- * @param money
- * @param contractType
- */
-bitkeepTron.getContractData=function (to,money,contractType){
-    let data={};
-    data.contract=contractArr[contractType];
-    data.to=to;
-    data.from=bitkeepTron.getMyAddress();
-    if(tools.isDevelopment()){
-        money=0.001;
-    }
-    data.value=money;
-    return data;
-}
-
-/**
- * 转账接口
- * @param to
- * @param money
- * @returns {{}}
- */
-bitkeepTron.getTransactionData=function (to,money){
-    let data={};
-    data.to=to;
-    data.from=bitkeepTron.getMyAddress();
-    if(tools.isDevelopment()){
-        money=0.001;
-    }
-    data.value=money;
-    return data;
-}
-
-
-bitkeepTron.depositUsdtTo=async function (address,amount){
-    return new Promise(async (resolve, reject) => {
-        try {
-            let _amount = tronWeb.toSun(amount)
-            let trxUsdtContract = await tronWeb.contract().at(contractArr[0])
-            let res = await trxUsdtContract.methods.approve(tronCrossAddress, _amount).send()
-            if (res) {
-                let timeNum=0;
-               let timeServe= setInterval(async () => {
-                    let hashRes = await tronWeb.trx.getTransaction(res)
-                   if(hashRes.ret.length>0){
-                       if(hashRes.ret[0].contractRet==='SUCCESS'){
-                           const cInstance = tronWeb.contract(tronCrossAbi, tronCrossAddress);
-                           let _l1Token = "0xa614f803b6fd780986a42c78ec9c7f77e6ded13c".toLowerCase()
-                           let _l2Token = "0x10186D85Ac0579Cb141Ff37261f23CF4F1D254b5".toLowerCase()
-                           let sendRes = await cInstance.methods.depositERC20To(_l1Token, _l2Token, address, _amount, 0, []).send()
-                           console.log(sendRes)
-                           resolve(sendRes)
-                           clearInterval(timeServe)
-                       }else if(hashRes.ret[0].contractRet==='REVERT'){
-                           resolve(false)
-                           clearInterval(timeServe)
-                       }else if(timeNum>5){
-                           clearInterval(timeServe)
-                           resolve(false)
-                       }
-                       ++timeNum
-                   }
-                }, 500)
-
-            }else {
-                resolve(false)
-            }
-        }catch (e) {
-            reject(false)
-        }
-    })
-
-}
-
-/**
- * trc转账
- * @param data
- * @returns {Promise<unknown>}
- */
-bitkeepTron.sendTransaction=function (data){
-    return new Promise(async (resolve, reject) => {
-        try {
-            let broastTx={};
-            if (data.contract) {
-                let decimal = 18
-                let Contract = await tronWeb.contract().at(data.contract)
-                const decimalCall = Contract.decimals || Contract.DECIMALS;
-                if (decimalCall) {
-                    decimal = await decimalCall().call()
-                }
-               let txid = await Contract.transfer(
-                    data.to,
-                    tronWeb.toHex(data.value * Math.pow(10, decimal))
-                ).send()
-                if(txid){
-                    broastTx.txid=txid
-                }
-            } else {
-                let tx = await tronWeb.transactionBuilder.sendTrx(data.to, data.value * Math.pow(10, 6), data.from);
-                // sign 签名
-                let signedTx = await tronWeb.trx.sign(tx);
-                //  broadcast  广播
-                 broastTx = await tronWeb.trx.sendRawTransaction(signedTx);
-            }
-            if(broastTx.txid){
-                resolve(broastTx.txid)
-            }else {
-                reject(false)
-            }
-         }catch (e) {
-           reject(false)
-        }
-    })
-}
-
-export default bitkeepTron

+ 1 - 1
manifest.json

@@ -75,7 +75,7 @@
             "disableHostCheck" : true,
             "proxy" : {
                 "/api" : {
-                    "target" : "http://bnb.kxmbuy.net",
+                    "target" : "http://cc-api.localhost.cc/",
                     "changeOrigin" : true,
                     "secure" : false
                 }

+ 25 - 3
pages/index/index.vue

@@ -2,12 +2,13 @@
 import homeIndex from "@/pages/home/home-index.vue";
 import myIndex from "@/pages/my/my-index.vue";
 import convertIndex from "@/pages/convert/convert-index.vue";
-// import tokenpocketBnb from "@/common/wallet/tokenpocket-wallet/tokenpocket-bnb";
+import tokenpocketBnb from "@/common/wallet/tokenpocket-wallet/tokenpocket-bnb";
 export default {
   components: { homeIndex, myIndex, convertIndex },
   data() {
     return {
-      tab_index: 1
+      tab_index: 1,
+      address:''
     };
   },
   mounted() {
@@ -15,6 +16,27 @@ export default {
     // this.handlerDateDurationCurrent()
   },
   methods: {
+    abbreviateString(str ){
+      let startLength=4;
+      let endLength=4;
+      if (str.length <= startLength + endLength + 1) {
+        return str; // 如果字符串长度不足以被截断,则返回原字符串
+      }
+      return str.slice(0, startLength) + '...' + str.slice(-endLength);
+    },
+    async getAccount(){
+      tokenpocketBnb.getAccounts().then(async (Address) => {
+        console.log(Address)
+        if (Address) {
+          this.address=Address
+        } else {
+          this.$message.error("获取信息失败")
+        }
+      }).catch((e)=>{
+        console.log(e)
+        // tools.goToError(2)
+      })
+    },
     getMyData() {
       // let token = uni.getStorageSync('token')
       // if (token) {
@@ -51,7 +73,7 @@ export default {
         src="@/static/img/logo/logo.png"
         ></image>
     <view class="fs-30">
-      sdfsdfsfsd222
+      {{abbreviateString(address)}}
     </view>
   </view>
   <view class="content-b p-20 box-sizing-border">

+ 12 - 6
pages/login/index.vue

@@ -6,7 +6,7 @@
 <script>
   import EnLoading from "../../components/en-utils/en-loading/en-loading";
   import tools from "../../common/js/tools";
-  import {login} from "@/api/member";
+  import {login, register} from "@/api/member";
   import tokenpocketBnb from "@/common/wallet/tokenpocket-wallet/tokenpocket-bnb";
   export default {
     components: {
@@ -14,7 +14,10 @@
     },
     data() {
       return {
-
+        formData: {
+          address: '',
+          inviteCode: ''
+        }
       }
     },
     onLoad(query) {
@@ -29,7 +32,8 @@
         tokenpocketBnb.getAccounts().then(async (Address) => {
           console.log(Address)
           if (Address) {
-            this.login(Address)
+            this.formData.address=Address
+            this.login()
           } else {
             tools.goToError(2)
           }
@@ -39,7 +43,7 @@
         })
       },
       login(Address){
-        login({'address':Address}).then((res)=>{
+        register(this.formData).then((res)=>{
           if(res.code===1){
             tools.setLoginInfo(res.data)
             setTimeout(()=>{
@@ -47,10 +51,12 @@
                 url: '/pages/index/index'
               })
             },50)
-          }else {
+          }else if(res.code===403){
             uni.reLaunch({
-              url: 'pages/login/register?address='+Address
+              url: 'pages/login/invite?address='+Address
             })
+          }else {
+            tools.goToError(1)
           }
         })
       }

+ 44 - 4
pages/login/invite.vue

@@ -1,15 +1,55 @@
 <script>
+import tools from "@/common/js/tools";
+import tokenpocketBnb from "@/common/wallet/tokenpocket-wallet/tokenpocket-bnb";
+import {register} from "@/api/member";
+
 export default {
   name: "invite-page",
   components: {},
   data() {
     return {
-      code: ''
+      formData: {
+        address: '',
+        inviteCode: ''
+      }
     };
   },
   mounted() {
   },
-  methods: {},
+  methods: {
+    async getAccount(){
+      console.log('---------------------------------',tokenpocketBnb)
+      tokenpocketBnb.getAccounts().then(async (Address) => {
+        console.log(Address)
+        if (Address) {
+          this.formData.address=Address
+          this.login()
+        } else {
+          // tools.goToError(2)
+        }
+      }).catch((e)=>{
+        console.log(e)
+        // tools.goToError(2)
+      })
+    },
+    login(){
+      register(this.formData).then((res) => {
+        if(res.code===1){
+          tools.setLoginInfo(res.data)
+          setTimeout(()=>{
+            uni.reLaunch({
+              url: '/pages/index/index'
+            })
+          },50)
+        }else {
+          uni.reLaunch({
+            url: 'pages/login/register?address='+Address
+          })
+        }
+      })
+    }
+
+  },
 }
 </script>
 
@@ -19,9 +59,9 @@ export default {
       请输入邀请码
     </view>
     <view class="w-80 mb-50">
-      <input class="input-b" v-model="code" placeholder="" placeholder-class="text-align-center fs-14"></input>
+      <input class="input-b" v-model="formData.inviteCode" placeholder="" placeholder-class="text-align-center fs-14"></input>
     </view>
-    <view class="but-b b-rad-20 text-align-center fc-f fs-14">
+    <view class="but-b b-rad-20 text-align-center fc-f fs-14" @click="getAccount">
       确认绑定
     </view>
   </view>