微信小程序 App.js 公共方法 小功能
微信小程序 App.js 公共方法 小功能
微信小程序 App.js 公共方法 小功能 //原生开发微信小程序//
路由跳转
goto:function(url){wx.navigateTo({url:url,fail:()=>{wx.switchTab({url:url,})}})},//调用该方法<view bindtap="goto"data-url="/pages/index/details/details"data-id="1"></view>constapp=getApp();goto:function(e){varurl=e.currentTarget.dataset.url;varid=e.currentTarget.dataset.id;vartype=e.currentTarget.dataset.type;varurlid=url+'?id='+id+'&type='+type;app.goto(urlid);},弹窗提示
errorTip:function(that,text,timer){wx.showToast({title:text,icon:'none',duration:timer})},//调用该方法app.errorTip(that,弹窗内容,2000);判断登录状态
getUserInfo:function(cb){varthat=this;if(wx.getStorageSync('logintag')){typeofcb=="function"&&cb(this.globalData.userInfo)}else{// wx.switchTab({// url: '/pages/log/log',// })wx.redirectTo({url:'/pages/log/log',});console.log('app logintag为空....... 重新获取');}},//调用该方法varthat=this;app.getUserInfo(that.membercenter());//需要调用方法membercenter:function(){}