App.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <script>
  2. import tokenpocketBnb from "@/common/wallet/tokenpocket-wallet/tokenpocket-bnb";
  3. import {login} from "@/api/member";
  4. import tools from "@/common/js/tools";
  5. export default {
  6. onLaunch: function () {
  7. console.log("App Launch");
  8. setTimeout(()=>{
  9. let bnbObj= tokenpocketBnb.getProvider()
  10. console.log(bnbObj)
  11. bnbObj.on('accountsChanged',(accounts)=>{
  12. console.log('监听成功')
  13. if(accounts.length<=0){
  14. uni.reLaunch({
  15. 'url':'pages/index/error?errorType=2'
  16. })
  17. }else {
  18. uni.clearStorageSync()
  19. this.login(accounts[0])
  20. }
  21. })
  22. bnbObj.on('chainChanged',(chainId)=>{
  23. if(chainId!=='0x38'){
  24. uni.reLaunch({
  25. 'url':'pages/index/error?errorType=5'
  26. })
  27. }else {
  28. uni.reLaunch({
  29. 'url':'pages/index/index'
  30. })
  31. }
  32. })
  33. },5000)
  34. uni.$on('noBan',()=>{
  35. console.log(this.$Route)
  36. if(this.$Route.path!=='/pages/index/error'){
  37. uni.reLaunch({
  38. 'url':'pages/index/error?errorType=5'
  39. })
  40. }
  41. })
  42. },
  43. onShow: function () {
  44. console.log("App Show");
  45. uni.reLaunch({
  46. url: '/pages/login/index'
  47. })
  48. },
  49. onHide: function () {
  50. uni.clearStorageSync()
  51. console.log("App Hide");
  52. },
  53. methods:{
  54. login(Address){
  55. // login({'address':Address}).then((res)=>{
  56. // if(res.code===1){
  57. // tools.setLoginInfo(res.data)
  58. // setTimeout(()=>{
  59. // uni.reLaunch({
  60. // url: '/pages/index/index'
  61. // })
  62. // },50)
  63. // }else {
  64. // uni.reLaunch({
  65. // url: 'pages/login/register?address='+Address
  66. // })
  67. // }
  68. // })
  69. uni.reLaunch({
  70. url: '/pages/login/index'
  71. })
  72. }
  73. }
  74. };
  75. </script>
  76. <style>
  77. /*每个页面公共css */
  78. @import "./common/css/common";
  79. /* icon */
  80. @import "./common/font/iconfont";
  81. checkbox .wx-checkbox-input {
  82. border-radius: 50% !important;
  83. }
  84. checkbox .wx-checkbox-input.wx-checkbox-input-checked {
  85. background: linear-gradient(129deg, #f0695b 0%, #ed301d 100%);
  86. border: 1px solid rgb(239, 74, 57);
  87. box-shadow: 0px 2px 3px rgba(239, 74, 57, 0.16);
  88. }
  89. uni-checkbox:not([disabled]) .uni-checkbox-input:hover {
  90. border-color: #d1d1d1;
  91. }
  92. </style>