| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- var util = require('../../utils/util.js');
- var app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- stars: [],
- score: 80,
- headIcon:null,
- nick:'',
- workfordo:0,
- working:0,
- postList:[],
- openId:''
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- try {
- var headIcon = wx.getStorageSync('headIcon');
- var nick = wx.getStorageSync('nick');
- var star = wx.getStorageSync('star');
- var score = wx.getStorageSync('score');
- const openid = wx.getStorageSync('openid');
- this.setData({
- headIcon: app.globalData.imageBase + "/"+headIcon,
- nick: nick,
- stars: util.convertToStarsArray(star),
- score: score,
- openId:openid
- })
- this.getWorkStream();
- } catch (e) {
- }
-
-
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function() {
- },
- refreshList:function(e){
- this.getWorkStream();
- },
- moreinfoEvent:function(e){
- var id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: "/pages/myPage/detail/reportDetail?id="+id
- })
- },
- modifyPersonInfo: function (e) {
- wx.navigateTo({
- url: "/pages/account/account"
- })
- },
- getWorkStream:function(){
- //var openid = this.data.openId;// wx.getStorageSync('openid');
- var that = this;
- var url = app.globalData.cloudBase + "/Wx/Work/List/"+ this.data.openId;
- wx.request({
- url: url,
- method: 'GET',
- header: {
- "Content-Type": "json"
- },
- // data: {
- // openid: openid
- // }
- // ,
- success: function (res) {
- console.debug(res.data);
- if (res.data.code === "0") {
- that.processWorkStream(res.data.data);
- }
- },
- fail: function (error) {
- console.log(error)
- }
- })
- },
- processWorkStream:function(list){
- if (null === list || list.length <= 0) {
- return;
- }
- var postList = [];
- var date = new Date();
- //年
- var NY = '' + date.getFullYear();
- //月
- var NM = this.PrefixInteger(date.getMonth() + 1, 2);// < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
- //日
- var ND = this.PrefixInteger(date.getDate(), 2);// < 10 ? '0' + date.getDate() : date.getDate();
- for (var index = 0; index < list.length; index++) {
- var post = list[index];
- // var cdate = new Date(post.updateTime);
- // var cy = '' + cdate.getFullYear();
- // var cm = this.PrefixInteger(cdate.getMonth() + 1, 2);// (cdate.getMonth() + 1 < 10 ? '0' + (cdate.getMonth() + 1) : cdate.getMonth() + 1);
- // var cd = this.PrefixInteger(cdate.getDate(), 2);// < 10 ? '0' + cdate.getDate() : cdate.getDate();
- //var time = post['time'];
- // if (cy === NY && cm === NM && cd === ND) {
- // var ch = this.PrefixInteger(date.getHours(), 2);
- // var cm = this.PrefixInteger(cdate.getMinutes(), 2);
- // var cs = this.PrefixInteger(cdate.getSeconds(), 2);
- // time = '' + ch + ':' + cm + ':' + cs;
- // } else {
- // time = '' + cy + '-' + cm + '-' + cd;
- // }
- // var replys = [];
- // for (var i = 0; i < post.replys.length && i < 2; i++) {
- // var item = post.replys[i];
- // var reply = {
- // id: item.id,
- // openid: item.openid,
- // showBoxId: item.showBoxId,
- // content: item.content,
- // name: item.nick
- // }
- // replys.push(reply);
- // }
- // var photos = [];
- // for (var j = 0; j < post.photos.length; j++) {
- // var item = post.photos[j];
- // var photo = {
- // id: item.id,
- // showBoxId: item.showBoxId,
- // photo: item.photo,
- // large: app.globalData.imageBase + "/" + item.photo,
- // middle: app.globalData.imageBase + "/mid_" + item.photo,
- // small: app.globalData.imageBase + "/thumb_" + item.photo
- // }
- // photos.push(photo);
- // }
- var temp = {
- id: post.id,
- // nick: post.nick,
- // headIcon: app.globalData.imageBase + "/" + post.headIcon,
- time: post.time,
- info: post.info,
- orgName: post.orgName
- // stars: util.convertToStarsArray("" + post.star),
- // score: post.score,
- //replyList: replys,
- //photoList: photos,
- // replySize: post.replys.length
- }
- postList.push(temp);
- }
- this.setData({
- postList: postList
- })
- }
- ,
- PrefixInteger: function (num, length) {
- return (Array(length).join('0') + num).slice(-length);
- }
- })
|