Commit 277deb64bce48a6b7a6f242b312e6133c3d5ef44
1 parent
f5fbb62a92
Exists in
master
and in
2 other branches
儿童切换
Showing 3 changed files with 101 additions and 16 deletions
littleApp_child/pages/home/home.js
View file @
277deb6
| ... | ... | @@ -15,12 +15,12 @@ |
| 15 | 15 | |
| 16 | 16 | var timeCount = 60; |
| 17 | 17 | var timer; |
| 18 | -var phone; | |
| 18 | +var phone; | |
| 19 | 19 | var name; |
| 20 | 20 | // 用户信息的缓存 |
| 21 | -var babyCache = ['',''] | |
| 21 | +var babyCache = [''] | |
| 22 | 22 | // 文章的缓存 |
| 23 | -var artCache = ['',''] | |
| 23 | +var artCache = [''] | |
| 24 | 24 | |
| 25 | 25 | Page({ |
| 26 | 26 | /*---------属性变量--------*/ |
| 27 | 27 | |
| ... | ... | @@ -34,9 +34,11 @@ |
| 34 | 34 | list:[], |
| 35 | 35 | userInfo:'', |
| 36 | 36 | inputFocus: { nameInput: false, phoneInput: false, codeInput: false }, |
| 37 | - currentBabyIndex:0, | |
| 37 | + babyIndex:0, | |
| 38 | 38 | babys:[], |
| 39 | 39 | tourist:true, |
| 40 | + isShowLeft: false, | |
| 41 | + isShowRight: false, | |
| 40 | 42 | vipList: [{ title: '高危指导', icon: 'gaoweizhidao', content: '医生依据新生儿娩出情况、新生儿患病情况及新生儿先天性疾病筛查结果辨识、诊断高危儿。针对医生的高危诊断,结合高危儿的月龄、生理因素、高危状态、检查结果、需监测指标等提供精准医疗服务。向早产儿、低出生体重儿、发育迟缓等特殊婴幼儿家长提供育儿帮助。' }, |
| 41 | 43 | { title: '精准医疗服务', icon: 'jingzunyiliao', content: '依据新生儿特有的生理情况,结合其每天都会快速生长发育的特点,对可能遇到的生理病理问题,提供精确到天的健康教育。新生儿期过后,结合婴幼儿体格生长发育特点,针对不同月龄,进行喂养方式、营养补充、辅食添加、动作发育、习惯培养等宣教指导。' }, |
| 42 | 44 | { title: '检查预约提醒', icon: 'chakanyuyuetixing', content: '每次检查后,医生会结合当前检查实际情况为儿童预约下次检查时间,届时提前通知家长带孩子进行相关检查。' }, |
| 43 | 45 | |
| 44 | 46 | |
| 45 | 47 | |
| 46 | 48 | |
| 47 | 49 | |
| ... | ... | @@ -172,22 +174,67 @@ |
| 172 | 174 | inputFocus: inputFocus |
| 173 | 175 | }) |
| 174 | 176 | }, |
| 177 | + // 跳转上一条 | |
| 178 | + toBefore() { | |
| 179 | + var index = this.data.babyIndex | |
| 180 | + index-- | |
| 181 | + console.log('index', index) | |
| 182 | + var left = true | |
| 183 | + var right = true | |
| 184 | + if (index == 0) { | |
| 185 | + left = false | |
| 186 | + } | |
| 187 | + this.setData({ | |
| 188 | + isShowLeft: left, | |
| 189 | + isShowRight: right, | |
| 190 | + babyIndex: index | |
| 191 | + }) | |
| 192 | + this.changeBaby(index) | |
| 193 | + }, | |
| 194 | + // 跳转下一条 | |
| 195 | + toAfter() { | |
| 196 | + var index = this.data.babyIndex | |
| 197 | + index++ | |
| 198 | + console.log('index', index) | |
| 199 | + var left = true | |
| 200 | + var right = true | |
| 201 | + if (index == app.globalData.userId.length - 1) { | |
| 202 | + right = false | |
| 203 | + } | |
| 204 | + this.setData({ | |
| 205 | + isShowLeft: left, | |
| 206 | + isShowRight: right, | |
| 207 | + babyIndex: index | |
| 208 | + }) | |
| 209 | + this.changeBaby(index) | |
| 210 | + }, | |
| 175 | 211 | // 改变baby |
| 176 | - changeBaby(e){ | |
| 212 | + changeBaby(index){ | |
| 177 | 213 | this.setData({ |
| 178 | - currentBabyIndex: e.currentTarget.dataset.index | |
| 214 | + babyIndex: index | |
| 179 | 215 | }) |
| 180 | - this.setUserInfo(babyCache[e.currentTarget.dataset.index]) | |
| 181 | - this.setArtInfo(artCache[e.currentTarget.dataset.index]) | |
| 216 | + getApp().globalData.currentId = getApp().globalData.userId[index] | |
| 217 | + if (babyCache.length > index){ | |
| 218 | + this.setUserInfo(babyCache[index]) | |
| 219 | + this.setArtInfo(artCache[index]) | |
| 220 | + } else { | |
| 221 | + this.getUserInfo() | |
| 222 | + } | |
| 223 | + | |
| 182 | 224 | }, |
| 183 | 225 | /*---------自定义函数--------*/ |
| 184 | 226 | homePage() { |
| 185 | 227 | var that = this |
| 186 | 228 | this.requestHomeInfo() |
| 229 | + var that = this | |
| 230 | + var right = true | |
| 231 | + if (app.globalData.userId.length == 1) { | |
| 232 | + right = false | |
| 233 | + } | |
| 187 | 234 | that.setData({ |
| 188 | 235 | pageType: 2, |
| 189 | - // babys: [1,2] | |
| 190 | - babys: app.globalData.userId | |
| 236 | + babys: app.globalData.userId, | |
| 237 | + isShowRight: right | |
| 191 | 238 | }) |
| 192 | 239 | }, |
| 193 | 240 | toLogin() { |
| 194 | 241 | |
| ... | ... | @@ -240,9 +287,25 @@ |
| 240 | 287 | console.log('获取用户信息',res) |
| 241 | 288 | self.getArticleInfo(res.data.data.days) |
| 242 | 289 | self.setUserInfo(res.data.data) |
| 243 | - babyCache[self.data.currentBabyIndex] = res.data.data | |
| 290 | + babyCache[self.data.babyIndex] = res.data.data | |
| 244 | 291 | }, function (res) { |
| 245 | - networkUtil.showErrorToast(res.errormsg) | |
| 292 | + | |
| 293 | + if (res.errorcode == 4002){ | |
| 294 | + wx.showModal({ | |
| 295 | + title: '提示', | |
| 296 | + content: res.errormsg, | |
| 297 | + showCancel:false, | |
| 298 | + success: function (res) { | |
| 299 | + wx.setStorageSync('userToken', '') | |
| 300 | + wx.setStorageSync('userId', '') | |
| 301 | + getApp().globalData.token = '' | |
| 302 | + getApp().globalData.userId = '' | |
| 303 | + self.toLogin() | |
| 304 | + } | |
| 305 | + }) | |
| 306 | + } else { | |
| 307 | + networkUtil.showErrorToast(res.errormsg) | |
| 308 | + } | |
| 246 | 309 | }) |
| 247 | 310 | }, |
| 248 | 311 | getArticleInfo(days) { |
| ... | ... | @@ -250,7 +313,7 @@ |
| 250 | 313 | // 文章列表 |
| 251 | 314 | networkUtil._get(api.homeArtList, { page: 0, limit: 100, days: days }, function (res) { |
| 252 | 315 | console.log('获取文章信息', res.data.list) |
| 253 | - artCache[self.data.currentBabyIndex] = res.data.list | |
| 316 | + artCache[self.data.babyIndex] = res.data.list | |
| 254 | 317 | self.setArtInfo(res.data.list) |
| 255 | 318 | }, function (res) { |
| 256 | 319 | wx.stopPullDownRefresh() |
littleApp_child/pages/home/home.wxml
View file @
277deb6
| ... | ... | @@ -11,15 +11,19 @@ |
| 11 | 11 | <!--头像--> |
| 12 | 12 | <image class="avatar" bindtap="tapAvatar" src="{{userData.avatar.medium ? userData.avatar.medium : ''}}" background-size="cover"></image> |
| 13 | 13 | <!--用户名--> |
| 14 | - <!-- <view class="top_name" wx:if="{{babys.length > 1}}"> | |
| 14 | + <!-- <view class="top_name" wx:if="{{babys.length > 1}}"> | |
| 15 | 15 | <view class="userName {{currentBabyIndex == 0 ? 'userName_selected' : ''}}" data-index="0" bindtap="changeBaby">{{userData.username}}</view> |
| 16 | 16 | <view class="top_name_line"></view> |
| 17 | - <view class="userName {{currentBabyIndex == 1 ? 'userName_selected' : ''}}" data-index="1" bindtap="changeBaby">-</view> | |
| 18 | - </view> --> | |
| 17 | + <view class="userName {{currentBabyIndex == 1 ? 'userName_selected' : ''}}" data-index="1" bindtap="changeBaby">-</view> | |
| 18 | + </view> --> | |
| 19 | 19 | <!-- wx:if="{{babys.length < 2}}" --> |
| 20 | 20 | <view class="top_name"> |
| 21 | 21 | <view class="userName" data-index="0">{{userData.username}}</view> |
| 22 | 22 | </view> |
| 23 | + <image class="icon_left" wx:if="{{isShowLeft}}" bindtap="toBefore" src="../../source/left.png"></image> | |
| 24 | + <image class="icon_right" wx:if="{{isShowRight}}" bindtap="toAfter" src="../../source/right.png"></image> | |
| 25 | + | |
| 26 | + | |
| 23 | 27 | <view class="tourist_age" wx:if="{{tourist == true}}">月龄:{{userData.monthage ? userData.monthage : '0'}}</view> |
| 24 | 28 | <image class="vip_icon" bindtap='toVipPage' wx:if="{{tourist == true}}" src="../../source/VIP_gray.png"></image> |
| 25 | 29 | <!--下方黑色横条--> |
littleApp_child/pages/home/home.wxss
View file @
277deb6
| ... | ... | @@ -89,6 +89,24 @@ |
| 89 | 89 | color: white; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | +.icon_left { | |
| 93 | + height: 22px; | |
| 94 | + width: 22px; | |
| 95 | + position: absolute; | |
| 96 | + top: 50px; | |
| 97 | + left: 50%; | |
| 98 | + transform: translateX(-80px); | |
| 99 | +} | |
| 100 | + | |
| 101 | +.icon_right { | |
| 102 | + height: 22px; | |
| 103 | + width: 22px; | |
| 104 | + position: absolute; | |
| 105 | + top: 50px; | |
| 106 | + left: 50%; | |
| 107 | + transform: translateX(55px); | |
| 108 | +} | |
| 109 | + | |
| 92 | 110 | /*上方信息条部分*/ |
| 93 | 111 | |
| 94 | 112 | .lineView { |