|
|
@@ -6,30 +6,34 @@ import tools from "@/common/js/tools";
|
|
|
export default {
|
|
|
onLaunch: function () {
|
|
|
console.log("App Launch");
|
|
|
- let bnbObj= tokenpocketBnb.getProvider()
|
|
|
- console.log(bnbObj)
|
|
|
- bnbObj.on('accountsChanged',(accounts)=>{
|
|
|
- if(accounts.length<=0){
|
|
|
- uni.reLaunch({
|
|
|
- 'url':'pages/index/error?errorType=2'
|
|
|
- })
|
|
|
- }else {
|
|
|
- uni.clearStorageSync()
|
|
|
- this.login(accounts[0])
|
|
|
- }
|
|
|
+ setTimeout(()=>{
|
|
|
+ let bnbObj= tokenpocketBnb.getProvider()
|
|
|
+ console.log(bnbObj)
|
|
|
+ bnbObj.on('accountsChanged',(accounts)=>{
|
|
|
+ console.log('监听成功')
|
|
|
+ if(accounts.length<=0){
|
|
|
+ uni.reLaunch({
|
|
|
+ 'url':'pages/index/error?errorType=2'
|
|
|
+ })
|
|
|
+ }else {
|
|
|
+ uni.clearStorageSync()
|
|
|
+ this.login(accounts[0])
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ bnbObj.on('chainChanged',(chainId)=>{
|
|
|
+ if(chainId!=='0x38'){
|
|
|
+ uni.reLaunch({
|
|
|
+ 'url':'pages/index/error?errorType=5'
|
|
|
+ })
|
|
|
+ }else {
|
|
|
+ uni.reLaunch({
|
|
|
+ 'url':'pages/index/index'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },5000)
|
|
|
|
|
|
- })
|
|
|
- bnbObj.on('chainChanged',(chainId)=>{
|
|
|
- if(chainId!=='0x38'){
|
|
|
- uni.reLaunch({
|
|
|
- 'url':'pages/index/error?errorType=5'
|
|
|
- })
|
|
|
- }else {
|
|
|
- uni.reLaunch({
|
|
|
- 'url':'pages/index/index'
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
uni.$on('noBan',()=>{
|
|
|
console.log(this.$Route)
|
|
|
if(this.$Route.path!=='/pages/index/error'){
|
|
|
@@ -48,19 +52,22 @@ export default {
|
|
|
},
|
|
|
methods:{
|
|
|
login(Address){
|
|
|
- login({'address':Address}).then((res)=>{
|
|
|
- if(res.code===1){
|
|
|
- tools.setLoginInfo(res.data)
|
|
|
- setTimeout(()=>{
|
|
|
- uni.reLaunch({
|
|
|
- url: '/pages/index/index'
|
|
|
- })
|
|
|
- },50)
|
|
|
- }else {
|
|
|
- uni.reLaunch({
|
|
|
- url: 'pages/login/register?address='+Address
|
|
|
- })
|
|
|
- }
|
|
|
+ // login({'address':Address}).then((res)=>{
|
|
|
+ // if(res.code===1){
|
|
|
+ // tools.setLoginInfo(res.data)
|
|
|
+ // setTimeout(()=>{
|
|
|
+ // uni.reLaunch({
|
|
|
+ // url: '/pages/index/index'
|
|
|
+ // })
|
|
|
+ // },50)
|
|
|
+ // }else {
|
|
|
+ // uni.reLaunch({
|
|
|
+ // url: 'pages/login/register?address='+Address
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ uni.reLaunch({
|
|
|
+ url: '/pages/login/index'
|
|
|
})
|
|
|
}
|
|
|
}
|