index.vue 1.4 KB

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