import httpRequestApi from '../../utils/APIClient';
import {
  formatDate
} from '../../utils/util';
export const followInit = (that) => {
  that.setData({
    followData: []
  })
  //请求数据封装
  that.getWorks = (pageNo, pageSize) => {
    httpRequestApi.getFollowWorks(pageNo, pageSize).success(res => {
      console.log(res)
      const followData = res.data.data.list;
      // const followTemp = [];
      followData.forEach(item => {
        const temp = {};
        console.log(item.userRead.id)
        temp.nickName = item.user.wechatName;
        temp.avatar = item.user.avatar;
        temp.plays = item.userRead.playAmount;
        temp.likes = item.userRead.likeAmount;
        temp.img = item.userRead.iconImg;
        temp.id = item.userRead.id;
        temp.title = item.userRead.title;
        temp.summary = item.userRead.summary;
        temp.time = formatDate(item.userRead.gmtCreated, 3);
        // 还差一些字段
        that.data.followData.push(temp);
      });
      // console.log(followTemp);
      that.setData({
        followData: that.data.followData,
        followPageTotalNo: res.data.data.totalNo
      })
      httpRequestApi.userIntoPage('pages/index/index','首页动态').success((res)=>{
        
      })
    });
  }
  that.getWorks(1, 5);
}