index.vue 1.6 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, register} 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. formData: {
  18. address: '',
  19. inviteCode: ''
  20. }
  21. }
  22. },
  23. onLoad(query) {
  24. this.getAccount()
  25. },
  26. mounted() {
  27. },
  28. methods: {
  29. async getAccount(){
  30. console.log('---------------------------------')
  31. tokenpocketBnb.getAccounts().then(async (Address) => {
  32. console.log(Address)
  33. if (Address) {
  34. this.formData.address=Address
  35. this.login()
  36. } else {
  37. tools.goToError(2)
  38. }
  39. }).catch((e)=>{
  40. console.log(e)
  41. tools.goToError(2)
  42. })
  43. },
  44. login(Address){
  45. register(this.formData).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 if(res.code===403){
  54. uni.reLaunch({
  55. url: 'pages/login/invite?address='+Address
  56. })
  57. }else {
  58. tools.goToError(1)
  59. }
  60. })
  61. }
  62. },
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. @import url("/static/css/icon-common.css") ;
  67. </style>