// pages/mine/mine.js var BASEURL = require('../../utils/wxconstant.js') var baseUrl = BASEURL.BaseUrl() var baseutils = require('../../utils/baseUtils.js') var netUtil = require('../../utils/network.js') var dateutil = require('../../utils/DateTime.js') Page({ /** * 页面的初始数据 */ data: { //id isregistered:false, idMyInfo:'idMyInfo', idCompanyInfo: 'idCompanyInfo', idAbout: 'idAbout', idgoBind:'idgoBind', pointdata:{},//本月、上月积分及排名 "curmonth_points": 520, //本月当前积分 "curmonth_rank": 1,//本月当前排名 "lastmonth_points": 520,//上月积分 "lastmonth_rank": 1 //上月排名 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, btnClick: function (event) { var that = this var id = event.currentTarget.id if (id == that.data.idMyInfo){ if (!that.data.isregistered){ wx.showModal({ title: '提示', content: '您当前尚未与企业关联绑定,是否立即去绑定?', success: function (res) { if (res.confirm) { wx.navigateTo({ url: '../bindphone/bindphone', }) } else if (res.cancel) { return } } }) }else{ wx.navigateTo({ url: '../perinfo/perinfo', }) } } else if (id == that.data.idCompanyInfo){ wx.navigateTo({ url: '../corporateInfo/corporateInfo', }) } else if (id == that.data.idAbout){ } else if (id == that.data.idgoBind){ wx.navigateTo({ url: '../bindphone/bindphone', }) } }, /** * 生命周期函数--监听页面显示 */ onShow: function () { var that = this this.setData({ isregistered: wx.getStorageSync('isregistered'), isLogin: wx.getStorageSync('wxnickName') ? true : false, canIUse: wx.canIUse('button.open-type.getUserInfo'), headerImg: wx.getStorageSync('wxavatarUrl'), wxNickname: wx.getStorageSync('wxnickName'), }) that.getMyRank() }, getMyRank:function(){ var that = this var data = { openid: wx.getStorageSync('openid'), } var url = baseUrl + BASEURL.getUrl.getRank netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) { if (res.data.success){ wx.setStorageSync('isregistered', res.data.data.isregistered) if (res.data.data.pointdata){ var pointdata = res.data.data.pointdata that.setData({ pointdata: pointdata, "curmonth_points": pointdata.curmonth_points, //本月当前积分 "curmonth_rank": pointdata.curmonth_rank,//本月当前排名 "lastmonth_points": pointdata.lastmonth_points,//上月积分 "lastmonth_rank": pointdata.lastmonth_rank //上月排名 }) } } }, function (res) { wx.showToast({ title: '加载数据失败', icon: 'none', duration: 2000 }) }) }, bindGetUserInfo: function (e) { var that = this var userInfo = e.detail.userInfo // console.log('bindGetUserInfo', userInfo) var nickName = userInfo.nickName var avatarUrl = userInfo.avatarUrl var gender = userInfo.gender //性别 0:未知、1:男、2:女 var province = userInfo.province var city = userInfo.city var country = userInfo.country if (nickName && avatarUrl) { baseutils.getComOpenid() //获取openid baseutils.getPersonlEmp() baseutils.judgeisReg() that.setData({ wxNickname: nickName, wxHeader: avatarUrl, isLogin: true }) try { wx.setStorageSync('wxavatarUrl', userInfo.avatarUrl) wx.setStorageSync('wxnickName', userInfo.nickName) } catch (e) { } } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })