App.vue 2.0 KB

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