123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- // pages/platform/index.js
- const app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- list: {},
- keys: []
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- const that = this;
- wx.request({
- url: app.baseUrl + '/article-list?platform=' + options.type + '&topic_name=' + options.title,
- success(res) {
- let lists = {};
- let keys = [];
- (res.data || []).map(v => {
- let time = new Date(v.create_time);
- let year = time.getFullYear();
- let month = time.getMonth();
- let day = time.getDate();
- let T = year;
- month + 1 > 9 ? T += '-' + (month + 1) : T += '-' + '0' + (month + 1);
- day + 1 > 9 ? T += '-' + (day + 1) : T += '-' + '0' + day;
- !lists[T] && keys.push(T);
- lists[T] ? lists[T].push(v) : lists[T] = [v]
- })
- that.setData({
- list: lists,
- keys
- })
- },
- fail(err) {
- }
- })
- },
- formatter: function (val) {
- let out = val;
- if (val >= 1000 && val < 10000) {
- out = (val / 1000).toFixed(2) - 0 + "千"
- } else if (val >= 10000 && val < 100000000) {
- out = (val / 10000).toFixed(0) - 0 + "万"
- } else if (val >= 100000000) {
- out = (val / 100000000).toFixed(2) - 0 + "亿"
- }
- return out
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|