App.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. },
  46. onHide: function () {
  47. console.log("App Hide");
  48. },
  49. methods:{
  50. login(Address){
  51. // login({'address':Address}).then((res)=>{
  52. // if(res.code===1){
  53. // tools.setLoginInfo(res.data)
  54. // setTimeout(()=>{
  55. // uni.reLaunch({
  56. // url: '/pages/index/index'
  57. // })
  58. // },50)
  59. // }else {
  60. // uni.reLaunch({
  61. // url: 'pages/login/register?address='+Address
  62. // })
  63. // }
  64. // })
  65. uni.reLaunch({
  66. url: '/pages/login/index'
  67. })
  68. }
  69. }
  70. };
  71. </script>
  72. <style>
  73. /*每个页面公共css */
  74. @import "./common/css/common";
  75. /* icon */
  76. @import "./common/font/iconfont";
  77. checkbox .wx-checkbox-input {
  78. border-radius: 50% !important;
  79. }
  80. checkbox .wx-checkbox-input.wx-checkbox-input-checked {
  81. background: linear-gradient(129deg, #f0695b 0%, #ed301d 100%);
  82. border: 1px solid rgb(239, 74, 57);
  83. box-shadow: 0px 2px 3px rgba(239, 74, 57, 0.16);
  84. }
  85. uni-checkbox:not([disabled]) .uni-checkbox-input:hover {
  86. border-color: #d1d1d1;
  87. }
  88. </style>