const util = require("../../../../utils/util.js"); const app = getApp(); Page({ data: { scrollTop:0, index:0, height:[0,0,0,0,0,0], info:{}, config:util.config, userInfo:{ nickname:'', avatar:'' }, score:0, }, onShow: function () { this.info(); }, jumpPage(){ wx.reLaunch({ url: '/pages/home/index' }); }, info(){ let that = this, userInfo = app.globalData.userInfo; util.ajax({ func: "score/info" }, function (res) { if (res.code == 0) { that.setData({score:res.data.score}) res.data.score = Math.round(res.data.score); res.data.role = userInfo['role'] || util.userRole(res.data.score); if (res.data.role.level < 6) { res.data.nextLevel = util.config.userRole[res.data.role.level + 1]; res.data.nextLevel.nextscore = Math.round(parseFloat(res.data.nextLevel.startPoint - res.data.score)); } that.setData({info: res.data,'userInfo.avatar':userInfo.avatar,'userInfo.nickname':userInfo.nickname}); that.linearAnim(res.data.role, res.data.score); }else util.showTips(res.reason); }); }, // 积分动画 linearAnim(data, score){ let that = this, height = this.data.index < data.level ? 62 : (data.level == 6 ? 100 : Math.round(100 * ((score - util.config.userRole[data.level].startPoint) / (util.config.userRole[data.level].endPoint - util.config.userRole[data.level].startPoint)))); this.data.height[this.data.index] = height > 100 ? 100 : height; if (this.data.index <= data.level){ this.setData({ index: this.data.index + 1, height: this.data.height}); setTimeout(function(){ that.linearAnim(data, score); that.scrollLeft(); },1000); } }, scrollLeft(){ this.setData({ scrollTop: parseFloat((this.data.index - 2) * 62) }); }, onShareAppMessage() { return { title: '积分等级--分享自@宝贝走天下微信小程序', path: '/pages/account/vip/index/index' } } })