var util = require('../../../utils/util.js'); var api = require('../../../config/api'); var user = require('../../../utils/user.js'); var app = getApp(); Page({ /** * 页面的初始数据 */ data: { userInfo: { nickName: '期待加入', avatarUrl: '/static/images/new/icon-user.png' }, saveMoney: '0', date: '', saveMoneyYuan: '0', saveMoneyPoint: '0', myqr_show: false, //我的分享二维码 myqr_blur: 100, //背景模糊值 imgList1:[], imgList2:[], }, showRule() { this.setData({ myqr_show: true, myqr_blur: 25 }) }, hidePoster(){ this.setData({ myqr_show:false, myqr_blur:100, }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { // let userInfo = wx.getStorageSync('userInfo'); //console.info(userInfo); }, getMemberInfo: function () { let that = this util.request(api.getMemberInfo, { userId: app.globalData.userInfo.id }, 'GET') .then(res => { console.info(res); if (res.errno === 0) { let date = null; if (res.data.userInfo.memberExpiration) date = res.data.userInfo.memberExpiration.substr(0, 10); let saveMoney = Number(res.data.saveMoney).toFixed(2); that.setData({ userInfo: res.data.userInfo, date: date, saveMoneyYuan: saveMoney.split('.')[0], saveMoneyPoint: saveMoney.split('.')[1] }); app.globalData.memberUserInfo=res.data.userInfo; if(that.data.userInfo.level==1){ that.getMemberAd(); } } else { util.showErrorToast(res.errmsg); console.info(that.data.userInfo) } }); }, goBuyList() { wx.navigateTo({ url: '/pages/member/buyList/buyList', }) }, goBuyMember() { if (!app.globalData.hasLogin){ wx.navigateTo({ url: "/pages/auth/login/login" }); return; } wx.navigateTo({ url: "/pages/member/buyMember/buyMember" }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getMemberInfo(); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, getMemberAd(){ util.request(api.GetMemberAd, { },'GET') .then(res=>{ if (res.errno === 0) { this.setData({ imgList1:res.data.firstPurchase, imgList2:res.data.memberActivity }); } }); }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })