// pages/eyeReoort/eyeReoort.js // 网络请求工具类 var networkUtil = require('../../utils/network_util.js'); var api = require('../../utils/apiFile.js'); // 获取应用实例 var app = getApp(); var now =""; Page({ /** * 页面的初始数据 */ data: { hospitalId:'', currentShowFormId:'', eyesReports:[], selectId:'', uerInfo:{}, mouths : [ { id: "0", name: "0月龄", showFormId: "1", isShow: true }, { id: "1", name: "30天", showFormId: 1, isShow: true }, { id: "3", name: "3个月", showFormId: "2", isShow: true }, { id: "6", name: "6个月", showFormId: "3", isShow: true }, { id: "9", name: "9个月", showFormId: 3, isShow: true }, { id: "12", name: "1岁", showFormId: "4", isShow: true }, { id: "18", name: "1岁半", showFormId: "5", isShow: true }, { id: "24", name: "2岁", showFormId: 5, isShow: true }, { id: "36", name: "3岁", showFormId: 5, isShow: true }, { id: "48", name: "4岁", showFormId: "6", isShow: true }, { id: "60", name: "5岁", showFormId: "7", isShow: true }, { id: "72", name: "6岁", showFormId: "8", isShow: true }, { id: "73", name: ">6岁", showFormId: "8", isShow: true } ], mouthsFor216 : [ { id: "0", name: "0月龄", showFormId: "1", isShow: true }, { id: "1", name: "28-30天", showFormId: "1", isShow: true }, { id: "3", name: "3个月", showFormId: "2", isShow: true }, { id: "6", name: "6个月", showFormId: "3", isShow: true }, { id: "12", name: "1岁", showFormId: "4", isShow: true }, { id: "24", name: "2岁", showFormId: "5", isShow: true }, { id: "36", name: "3岁", showFormId: "5", isShow: true }, { id: "48", name: "4岁", showFormId: "6", isShow: true }, { id: "60", name: "5岁", showFormId: "7", isShow: true }, { id: "72", name: "6岁", showFormId: "8", isShow: true }, { id: "73", name: ">7岁", showFormId: "9", isShow: true } ], mouthsFor197 : [ { id: "0", name: "0月龄", showFormId: "1", isShow: true }, { id: "1", name: "30天", showFormId: "1", isShow: true }, { id: "3", name: "3个月", showFormId: "2", isShow: true }, { id: "6", name: "6个月", showFormId: "4", isShow: true }, { id: "9", name: "9个月", showFormId: "4", isShow: true }, { id: "12", name: "1岁", showFormId: "4", isShow: true }, { id: "18", name: "1岁半", showFormId: "4", isShow: true }, { id: "24", name: "2岁", showFormId: "4", isShow: true }, { id: "36", name: "3岁", showFormId: "5", isShow: true }, { id: "48", name: "4岁", showFormId: "6", isShow: true }, { id: "60", name: "5岁", showFormId: "6", isShow: true }, { id: "72", name: "6岁", showFormId: "6", isShow: true }, { id: "73", name: ">6岁", showFormId: "6", isShow: true } ], viewData:{} }, selectEyeItem: function (e){ var item = e.currentTarget.dataset.item; this.calcMouths(item); }, //根据儿童生日计算月龄下拉列表变更内容 calcMouths: function (child) { this.setData({ selectId:child.id }) var that = this; var monthAge = child.checkMonth; var checkMonths = []; if("216" === child.hospitalId){ checkMonths = that.data.mouthsFor216; }else if ("197" === child.hospitalId){ checkMonths = that.data.mouthsFor197; }else{ checkMonths = that.data.mouths; } if(null != monthAge){ var item = checkMonths.filter(function (item) { if (item.name == monthAge) return true; }); if (item.length) { that.setData({ hospitalId:child.hospitalId, currentShowFormId:item[0].showFormId, viewData:child.viewData }) } } else { that.setData({ hospitalId:'', currentShowFormId:'', viewData:{} }) } }, // 获取用户信息 getUserInfo(userId) { networkUtil.showLoading() var self = this var param = { 'token': app.globalData.token } if (getApp().globalData.tourist == true) { param.type = 2 } networkUtil._get(api.userInfo + app.globalData.currentId, param, function(res) { self.setData({ uerInfo : res.data.data }); console.log('获取用户信息', self.uerInfo) }, function(res) { if (res.errorcode == 4002) { wx.showModal({ title: '提示', content: res.errormsg, showCancel: false, success: function(res) { wx.setStorageSync('userToken', '') wx.setStorageSync('userId', '') getApp().globalData.token = '' getApp().globalData.userId = '' self.toLogin() } }) } else { networkUtil.showErrorToast(res.errormsg) } }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var me = this; this.getUserInfo(); networkUtil._get(api.getBabyEyeCheck,{},function(res){ if(0 == res.data.errorcode){ now = res.data.now; if(res.data.data.length>0){ me.setData({ eyesReports : res.data.data, selectId:res.data.data[0].id }) me.calcMouths(res.data.data[0]) } } },function(res){ }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })