1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- const util = require("../../utils/util.js")
- const app = getApp();
- Page({
- data: {
- listInfo:{
- list:[],
- oneself:{}
- },
- },
- onLoad(options) {
- this.getList();
- },
- onShow() {
- },
- // 获取排行榜列表
- getList(){
- let that=this,data={};
- util.ajax({
- func:'v2/sharer/usersharer/List',
- load:false
- },function (res) {
- if (res.code==0) {
- let arr={},arr1=[];
- if (res.data&&res.data.length>0) {
- res.data.map(el => {
- el.maxLevel=el.level1>=el.level2?el.level1:el.level2;
- });
- arr=res.data[res.data.length-1];
- res.data.splice(res.data.length-1,1)
- arr1=res.data;
- arr.rankNum=that.getRankForList(arr.uid,arr1)
- that.setData({
- 'listInfo.list':arr1,
- 'listInfo.oneself':arr
- })
- console.log(that.data.listInfo)
- }
- } else {
- util.showTips(res.reason);
- }
- })
- },
- // 获取排行榜榜位
- getRankForList(id,arr){
- let rankNum=-1;
- if (!util.isEmpty(id)&&arr.length>0) {
- arr.forEach((el,i) => {
- if (id==el.uid) {
- rankNum=i+1;
- }
- });
- }
- return rankNum;
- },
- onShareAppMessage() {
- }
- })
|