TP-Lab / tp-js-sdk

TokenPocket JS API for Dapp of ETH, IOST, TRON, COSMOS, SOLANA, EOS etc. (mobile only)
200 stars 61 forks source link

波场钱包api在移动端前端失效无反馈 #30

Closed Francisundermoon closed 2 years ago

Francisundermoon commented 2 years ago

波场钱包js在pc端可正常调用tronlink活动,但是在tp钱包移动端dapp浏览器一点反应都没有

chendatony31 commented 2 years ago

确认下当前钱包是不是 波场 钱包,以及 其他trx 应用你那里 能不能正常使用

Francisundermoon commented 2 years ago

确认下当前钱包是不是 波场 钱包,以及 其他trx 应用你那里 能不能正常使用

确定是在波场钱包下,在pc端tronlink和移动端bitkeep能正常拉起的页面响应,但是在tp钱包移动端直接失效了

chendatony31 commented 2 years ago

有没有 测试链接 可以给我们测试下? 或者 代码片段之类的贴一下

Francisundermoon commented 2 years ago
 <script>
      new Vue({
           el: "#hello",
           data: function () {
                return {
                     itemshow: false,
                     walletAddress: 2, 
                     currentWalletTip: "",

                }
           },
           mounted() {
                // 判断钱包类型
                if (window.tronWeb) {
                     this.tronWeb = window.tronWeb;
                     console.log(this.tronWeb)
                     tronLink.request({ method: 'tron_requestAccounts' })
                     this.walletAddress = this.tronWeb.defaultAddress.base58;
                     vant.Toast.success('当前为波场钱包');
                     this.walletAddress = 2
                     this.currentWalletTip="Tron"
                }
                console.log(this.walletAddress)
           },

           methods: {
                testicon() {
                     this.itemshow = !this.itemshow
                                         if (window.tronWeb) {
                     this.tronWeb = window.tronWeb;
                     console.log(this.tronWeb)
                     tronLink.request({ method: 'tron_requestAccounts' })
                     this.walletAddress = this.tronWeb.defaultAddress.base58;
                     vant.Toast.success('当前为波场钱包');
                     this.walletAddress = 2
                     this.currentWalletTip="Tron"
                }
                console.log(this.walletAddress)
                }
           }
      })
 </script>

这个,辛苦了

chendatony31 commented 2 years ago

tp 里面 直接读 window.tronWeb.defaultAddress.base58 就可以了, 没有 tronLink.request({ method: 'tron_requestAccounts' }) 这个

Francisundermoon commented 2 years ago

tp 里面 直接读 window.tronWeb.defaultAddress.base58 就可以了, 没有 tronLink.request({ method: 'tron_requestAccounts' }) 这个

解决了,谢谢