微信小程序 App.js 公共方法 小功能 📅 2026/7/4 10:02:09 微信小程序 App.js 公共方法 小功能微信小程序 App.js 公共方法 小功能 //原生开发微信小程序//路由跳转goto:function(url){wx.navigateTo({url:url,fail:(){wx.switchTab({url:url,})}})},//调用该方法view bindtapgotodata-url/pages/index/details/detailsdata-id1/viewconstappgetApp();goto:function(e){varurle.currentTarget.dataset.url;varide.currentTarget.dataset.id;vartypee.currentTarget.dataset.type;varurlidurl?ididtypetype;app.goto(urlid);},弹窗提示errorTip:function(that,text,timer){wx.showToast({title:text,icon:none,duration:timer})},//调用该方法app.errorTip(that,弹窗内容,2000);判断登录状态getUserInfo:function(cb){varthatthis;if(wx.getStorageSync(logintag)){typeofcbfunctioncb(this.globalData.userInfo)}else{// wx.switchTab({// url: /pages/log/log,// })wx.redirectTo({url:/pages/log/log,});console.log(app logintag为空....... 重新获取);}},//调用该方法varthatthis;app.getUserInfo(that.membercenter());//需要调用方法membercenter:function(){}