From 277deb64bce48a6b7a6f242b312e6133c3d5ef44 Mon Sep 17 00:00:00 2001 From: luoye <397379429@qq.com> Date: Wed, 27 Dec 2017 14:36:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=84=BF=E7=AB=A5=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- littleApp_child/pages/home/home.js | 89 ++++++++++++++++++++++++++++++------ littleApp_child/pages/home/home.wxml | 10 ++-- littleApp_child/pages/home/home.wxss | 18 ++++++++ 3 files changed, 101 insertions(+), 16 deletions(-) diff --git a/littleApp_child/pages/home/home.js b/littleApp_child/pages/home/home.js index b3b61a6..e2214d8 100644 --- a/littleApp_child/pages/home/home.js +++ b/littleApp_child/pages/home/home.js @@ -15,12 +15,12 @@ var app = getApp() var timeCount = 60; var timer; -var phone; +var phone; var name; // 用户信息的缓存 -var babyCache = ['',''] +var babyCache = [''] // 文章的缓存 -var artCache = ['',''] +var artCache = [''] Page({ /*---------属性变量--------*/ @@ -34,9 +34,11 @@ Page({ list:[], userInfo:'', inputFocus: { nameInput: false, phoneInput: false, codeInput: false }, - currentBabyIndex:0, + babyIndex:0, babys:[], tourist:true, + isShowLeft: false, + isShowRight: false, vipList: [{ title: '高危指导', icon: 'gaoweizhidao', content: '医生依据新生儿娩出情况、新生儿患病情况及新生儿先天性疾病筛查结果辨识、诊断高危儿。针对医生的高危诊断,结合高危儿的月龄、生理因素、高危状态、检查结果、需监测指标等提供精准医疗服务。向早产儿、低出生体重儿、发育迟缓等特殊婴幼儿家长提供育儿帮助。' }, { title: '精准医疗服务', icon: 'jingzunyiliao', content: '依据新生儿特有的生理情况,结合其每天都会快速生长发育的特点,对可能遇到的生理病理问题,提供精确到天的健康教育。新生儿期过后,结合婴幼儿体格生长发育特点,针对不同月龄,进行喂养方式、营养补充、辅食添加、动作发育、习惯培养等宣教指导。' }, { title: '检查预约提醒', icon: 'chakanyuyuetixing', content: '每次检查后,医生会结合当前检查实际情况为儿童预约下次检查时间,届时提前通知家长带孩子进行相关检查。' }, @@ -172,22 +174,67 @@ Page({ inputFocus: inputFocus }) }, + // 跳转上一条 + toBefore() { + var index = this.data.babyIndex + index-- + console.log('index', index) + var left = true + var right = true + if (index == 0) { + left = false + } + this.setData({ + isShowLeft: left, + isShowRight: right, + babyIndex: index + }) + this.changeBaby(index) + }, + // 跳转下一条 + toAfter() { + var index = this.data.babyIndex + index++ + console.log('index', index) + var left = true + var right = true + if (index == app.globalData.userId.length - 1) { + right = false + } + this.setData({ + isShowLeft: left, + isShowRight: right, + babyIndex: index + }) + this.changeBaby(index) + }, // 改变baby - changeBaby(e){ + changeBaby(index){ this.setData({ - currentBabyIndex: e.currentTarget.dataset.index + babyIndex: index }) - this.setUserInfo(babyCache[e.currentTarget.dataset.index]) - this.setArtInfo(artCache[e.currentTarget.dataset.index]) + getApp().globalData.currentId = getApp().globalData.userId[index] + if (babyCache.length > index){ + this.setUserInfo(babyCache[index]) + this.setArtInfo(artCache[index]) + } else { + this.getUserInfo() + } + }, /*---------自定义函数--------*/ homePage() { var that = this this.requestHomeInfo() + var that = this + var right = true + if (app.globalData.userId.length == 1) { + right = false + } that.setData({ pageType: 2, - // babys: [1,2] - babys: app.globalData.userId + babys: app.globalData.userId, + isShowRight: right }) }, toLogin() { @@ -240,9 +287,25 @@ Page({ console.log('获取用户信息',res) self.getArticleInfo(res.data.data.days) self.setUserInfo(res.data.data) - babyCache[self.data.currentBabyIndex] = res.data.data + babyCache[self.data.babyIndex] = res.data.data }, function (res) { - networkUtil.showErrorToast(res.errormsg) + + 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) + } }) }, getArticleInfo(days) { @@ -250,7 +313,7 @@ Page({ // 文章列表 networkUtil._get(api.homeArtList, { page: 0, limit: 100, days: days }, function (res) { console.log('获取文章信息', res.data.list) - artCache[self.data.currentBabyIndex] = res.data.list + artCache[self.data.babyIndex] = res.data.list self.setArtInfo(res.data.list) }, function (res) { wx.stopPullDownRefresh() diff --git a/littleApp_child/pages/home/home.wxml b/littleApp_child/pages/home/home.wxml index 4db213d..33d3930 100644 --- a/littleApp_child/pages/home/home.wxml +++ b/littleApp_child/pages/home/home.wxml @@ -11,15 +11,19 @@ - + - + --> {{userData.username}} + + + + 月龄:{{userData.monthage ? userData.monthage : '0'}} diff --git a/littleApp_child/pages/home/home.wxss b/littleApp_child/pages/home/home.wxss index 049ad20..01f3fb5 100644 --- a/littleApp_child/pages/home/home.wxss +++ b/littleApp_child/pages/home/home.wxss @@ -89,6 +89,24 @@ color: white; } +.icon_left { + height: 22px; + width: 22px; + position: absolute; + top: 50px; + left: 50%; + transform: translateX(-80px); +} + +.icon_right { + height: 22px; + width: 22px; + position: absolute; + top: 50px; + left: 50%; + transform: translateX(55px); +} + /*上方信息条部分*/ .lineView { -- 1.8.3.1