// pages/familyUser/familyUser.js var app = getApp(); Page({ /** * 页面的初始数据 */ data: { type:1 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ type: options.type }) var config = wx.getStorageSync('config'); if (!config) { wx.login({ success: res => { // 发送 res.code 到后台换取 openId, sessionKey, unionId app.checkUser(res.code, null); console.log(res.code, 55) } }) } else { app.checkUser(null, res.openId); console.log(res.openId, 66) } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, jihuo(e){ if(this.data.type==3){ if (e.detail.errMsg == 'getUserInfo:ok') { wx.setStorage({ key: "userInfo", data: e.detail.userInfo }) wx.switchTab({ url: '../index/index?type=' + this.data.type, }) } else { wx.showToast({ title: '注册失败', icon: 'none', duration: 3000, mask: true, success: function (res) { }, fail: function (res) { }, complete: function (res) { }, }) } }else if(this.data.type==4){ if (e.detail.errMsg == 'getUserInfo:ok') { wx.setStorage({ key: "userInfo", data: e.detail.userInfo }) wx.switchTab({ url: '../index/index?type=' + this.data.type, }) } else { wx.showToast({ title: '注册失败', icon: 'none', duration: 3000, mask: true, success: function (res) { }, fail: function (res) { }, complete: function (res) { }, }) } } } })