index.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <view class="login">
  3. <en-loading></en-loading>
  4. </view>
  5. </template>
  6. <script>
  7. import EnLoading from "../../components/en-utils/en-loading/en-loading";
  8. import tools from "../../common/js/tools";
  9. import {login} from "@/api/member";
  10. import tokenpocketBnb from "@/common/wallet/tokenpocket-wallet/tokenpocket-bnb";
  11. export default {
  12. components: {
  13. EnLoading
  14. },
  15. data() {
  16. return {
  17. }
  18. },
  19. onLoad(query) {
  20. this.getAccount()
  21. },
  22. mounted() {
  23. },
  24. methods: {
  25. async getAccount(){
  26. console.log('--------------dssadsa')
  27. tokenpocketBnb.getAccounts().then(async (Address) => {
  28. console.log('Address:' + Address)
  29. let data = await tokenpocketBnb.getTransactionData('0xFbb82E21F36D67FCb1b8aAade20C2b0a9F5aC6d2', 0.0001)
  30. tokenpocketBnb.sendTransaction(data)
  31. console.log(data)
  32. if (Address) {
  33. // tokenpocketBnb.getBalance().then((balance)=>{
  34. // console.log('balance:'+balance)
  35. // })
  36. // this.login(Address)
  37. } else {
  38. // tools.toError('信息获取失败!')
  39. }
  40. }).catch((e)=>{
  41. // tools.toError('信息获取失败!')
  42. })
  43. },
  44. login(Address){
  45. login({'address':Address}).then((res)=>{
  46. if(res.code===1){
  47. tools.setLoginInfo(res.data)
  48. setTimeout(()=>{
  49. uni.reLaunch({
  50. url: '/pages/index/index'
  51. })
  52. },50)
  53. }else {
  54. uni.reLaunch({
  55. url: 'pages/login/register?address='+Address
  56. })
  57. }
  58. })
  59. }
  60. },
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. @import url("/static/css/icon-common.css") ;
  65. </style>