12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- const util = require("../../../../utils/util.js");
- const app = getApp();
- Page({
- data: {
- scrollLeft:0,
- index:0,
- width:[0,0,0,0,0,0],
- info:{},
- config:util.config
- },
- onShow: function () {
- this.info();
- },
- info(){
- let that = this, userInfo = app.globalData.userInfo;
- util.ajax({
- func: "score/info"
- }, function (res) {
- if (res.code == 0) {
- 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 });
- that.linearAnim(res.data.role, res.data.score);
- }else
- util.showTips(res.reason);
- });
- },
- linearAnim(data, score){
- let that = this, width = this.data.index < data.level ? 170 : (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.width[this.data.index] = width > 100 ? 100 : width;
- if (this.data.index <= data.level){
- this.setData({ index: this.data.index + 1, width: this.data.width});
- setTimeout(function(){
- that.linearAnim(data, score);
- that.scrollLeft();
- },1000);
- }
- },
- scrollLeft(){
- this.setData({ scrollLeft: parseFloat((this.data.index - 2) * 170) });
- },
- onShareAppMessage() {
- return {
- title: '积分等级--分享自@宝贝走天下微信小程序',
- path: '/pages/account/vip/index/index'
- }
- }
- })
|