// pages/home/parents/index.js const request = require('../../../api/parrent.js') const app = getApp() Page({ /** * 页面的初始数据 */ data: { page: 0, pageSize: 15, records: [], recordTypes: app.globalData.recordTypes, eatStates: app.globalData.eatStates, testData: { "paging": { "page": 0, "pageSize": 15, "pageCount": 1, "recordCount": 2 }, "records": [ { "teacher": null, "recordDate": "2018-12-25 00:00:00", "pictures": "4028e38165fac6cb0165fac9d151000a,4028e38165fac6cb0165fac9d314000b,", "dietRecord": [ { "id": "4028048267c974b60167c974b6c00000", "createName": null, "createBy": null, "createDate": null, "updateName": null, "updateBy": null, "updateDate": "2018-12-24 14:25:40", "sysOrgCode": null, "sysCompanyCode": null, "recordCategory": "diet", "recordType": "diet_morning", "eatState": "more", "value": null, "signSummaryId": "4028048267e4213c0167e423f84f0002" }, { "id": "4028048267c974b60167c9751bd30001", "createName": null, "createBy": null, "createDate": null, "updateName": "管理员", "updateBy": "admin", "updateDate": "2018-12-20 10:33:20", "sysOrgCode": null, "sysCompanyCode": null, "recordCategory": "diet", "recordType": "diet_afternoon", "eatState": "normal", "value": null, "signSummaryId": "4028048267e4213c0167e423f84f0002" }, { "id": "4028048267c974b60167c97660120002", "createName": "管理员", "createBy": "admin", "createDate": "2018-12-20 10:33:57", "updateName": null, "updateBy": null, "updateDate": null, "sysOrgCode": "A03", "sysCompanyCode": "A03", "recordCategory": "diet", "recordType": "diet_milk", "eatState": "normal", "value": "300", "signSummaryId": "4028048267e4213c0167e423f84f0002" } ], "sleepRecord": [ { "id": "4028048267c974b60167c976bc210003", "createName": "管理员", "createBy": "admin", "createDate": "2018-12-20 10:34:21", "updateName": null, "updateBy": null, "updateDate": null, "sysOrgCode": "A03", "sysCompanyCode": "A03", "recordCategory": "sleep", "recordType": "sleep_time", "eatState": "normal", "value": "60", "signSummaryId": "4028048267e4213c0167e423f84f0002" } ], "wcRecord": [ { "id": "4028048267c974b60167c97706930004", "createName": "管理员", "createBy": "admin", "createDate": "2018-12-20 10:34:40", "updateName": "管理员", "updateBy": "admin", "updateDate": "2018-12-20 10:43:55", "sysOrgCode": "A03", "sysCompanyCode": "A03", "recordCategory": "wc", "recordType": "wc_pee", "eatState": "normal", "value": "3", "signSummaryId": "4028048267e4213c0167e423f84f0002" } ] }, { "teacher": null, "recordDate": "2018-12-21 00:00:00", "pictures": null, "dietRecord": [ ], "sleepRecord": [ ], "wcRecord": [ ] } ] } }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { const that = this let resData = this.data.testData var record = resData['records'] var templist = this.data.records for (var i = 0; i < record.length; i++) { var item = record[i] var dateStr = item.recordDate.substr(0, 10) let show_day = new Array('周日', '周一', '周二', '周三', '周四', '周五', '周六'); let date = new Date(dateStr); var num = date.getDay() item.recordDate = dateStr + " " + show_day[date.getDay()] // 饮食 var dietRecords = item['dietRecord'] for (var j = 0; j < dietRecords.length; j++) { var diet = dietRecords[j] diet.z_recordType = that.data.recordTypes[diet.recordType] diet.z_eatState = that.data.eatStates[diet.eatState] } // 睡觉 var sleepRecord = item["sleepRecord"] for (var j = 0; j < sleepRecord.length; j++) { var r = sleepRecord[j] r.z_recordType = that.data.recordTypes[r.recordType] } // wc var wcRecord = item["wcRecord"] for (var j = 0; j < wcRecord.length; j++) { var r = wcRecord[j] r.z_recordType = that.data.recordTypes[r.recordType] } console.log(item) templist.push(item) } this.setData({ records: templist, page: resData['paging']['page'] }) // request.queryStudentRecord(that.data.page, that.data.pageSize, '4028048267c0236e0167c02b63100004').then(res => { // console.log(res) // let resData = this.data.testData // var record = resData['records'] // var templist = this.data.records // for (var i = 0; i < record.length; i++) { // var item = record[i] // // 饮食 // var dietRecords = item['dietRecord'] // for (var j = 0; j < dietRecords.length; j++) { // var diet = dietRecords[j] // diet.z_recordType = that.data.recordTypes[diet.recordType] // } // // 睡觉 // var sleepRecord = item["sleepRecord"] // for (var j = 0; j < sleepRecord.length; j++) { // var r = sleepRecord[j] // r.z_recordType = that.data.recordTypes[r.recordType] // } // // wc // var wcRecord = item["wcRecord"] // for (var j = 0; j < wcRecord.length; j++) { // var r = wcRecord[j] // r.z_recordType = that.data.recordTypes[r.recordType] // } // console.log(item) // templist.push(item) // } // this.setData({ // records: templist, // page: resData['paging']['page'] // }) // }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { } })