index.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. tokenpocketBnb.getAccounts().then(async (Address) => {
  27. // let data = await tokenpocketBnb.getTransactionData('0xFbb82E21F36D67FCb1b8aAade20C2b0a9F5aC6d2', 0.0001)
  28. // tokenpocketBnb.sendTransaction(data)
  29. if (Address) {
  30. this.login(Address)
  31. } else {
  32. tools.goToError(2)
  33. }
  34. }).catch((e)=>{
  35. tools.goToError(2)
  36. })
  37. },
  38. login(Address){
  39. login({'address':Address}).then((res)=>{
  40. if(res.code===1){
  41. tools.setLoginInfo(res.data)
  42. setTimeout(()=>{
  43. uni.reLaunch({
  44. url: '/pages/index/index'
  45. })
  46. },50)
  47. }else {
  48. uni.reLaunch({
  49. url: 'pages/login/register?address='+Address
  50. })
  51. }
  52. })
  53. }
  54. },
  55. }
  56. </script>
  57. <style lang="scss" scoped>
  58. @import url("/static/css/icon-common.css") ;
  59. </style>