// pages/member/index.js var app = getApp(); var netUtil = require("../../utils/requestUtil.js"); //require引入 Page({ /** * 页面的初始数据 */ data: { is_manager: false, userInfo: [], iconList: [{ icon: 'myfill', color: 'cyan', badge: 0, name: '我的资料', url:'/pages/member/personal' }, { icon: 'homefill', color: 'green', badge: 0, name: '我的房源', url:'/pages/house/list/index' }, { icon: 'card', color: 'olive', badge: 0, name: '房间管理', url:'/pages/house/room/index' }, { icon: 'group', color: 'yellow', badge: 0, name: '子账号', url:'/pages/subaccount/index' }, { icon: 'paint', color: 'green', badge: 0, name: '我的保洁', url:'/pages/member/myclean' }, { icon: 'video', color: 'yellow', badge: 0, name: '视频教程', url:'/pages/single/help' }, { icon: 'creativefill', color: 'gray', badge: 0, name: '关于我们', url:'/pages/single/about' }, { icon: 'questionfill', color: 'blue', badge: 0, name: '常见问题', url:'/pages/question/index' }], gridCol:10, skin: false }, onLoad(e) { console.log(wx.getStorageSync('userInfo'), 'aaaa') this.setData({ userInfo: wx.getStorageSync('userInfo') }) console.log(this.data.userInfo) }, getPhoneNumber(e) { // var iv = encodeURIComponent(e.detail.iv) // var encryptedData = encodeURIComponent(e.detail.encryptedData) var iv = e.detail.iv var encryptedData = e.detail.encryptedData var data = { iv: iv, encryptedData: encryptedData } // 登录 wx.login({ success: res => { // 发送 res.code 到后台换取 openId, sessionKey, unionId if (res.code) { //绑定手机号 var self = this; var url = app.globalData.requestUrl + 'index/member/bindPhone'; data.code = res.code return netUtil.sendGet(url, data) .then((res) => { if (res.statusCode == 200 && res.data.code == 200) { wx.showToast({ title: '手机号绑定成功', icon: 'none', duration: 3000 }) } else { wx.showToast({ title: res.data.msg, icon: 'none', duration: 3000 }) } }).then(() => {}) } else { console.log('error获取code失败:' + e.detail.errMsg) } } }) }, CopyLink(e) { wx.setClipboardData({ data: e.currentTarget.dataset.link, success: res => { wx.showToast({ title: '微信号已复制', duration: 1000, }) } }) }, bingLogout: function() { wx.setStorageSync('userInfo', '') wx.reLaunch({ url: '/pages/member/index', }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { // this.data.is_manager = app.globalData.userInfo.is_manager var userInfo = wx.getStorageSync('userInfo'); this.setData({ is_manager: userInfo.is_manager }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { } })