gree_leran/unpackage/dist/dev/mp-weixin/pages/intergral/ut/dataTo.js

28 lines
567 B
JavaScript
Raw Normal View History

2024-06-20 15:36:19 +00:00
"use strict";
const resToList = (res) => {
if (res == null || res == void 0) {
return null;
}
console.log("淑娟转换", res);
let list = res.map((e) => {
if (e.extField1 == null) {
e.extField1 = 0;
}
return {
username: e.username || "",
profilePicture: e.profilePicture || "",
score: e.extField1
};
});
list.sort((a, b) => b.score - a.score);
while (list.length < 3) {
list.push({
username: "",
profilePicture: "",
score: 0
});
}
return list;
};
exports.resToList = resToList;