From 9f951980afe8c6d024e15f6b7d3e58c427dd886b Mon Sep 17 00:00:00 2001 From: luoye <397379429@qq.com> Date: Thu, 3 Aug 2017 16:06:28 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- littleApp_child/app.json | 3 +- littleApp_child/pages/home/home.js | 316 +++----------------------------- littleApp_child/pages/home/home.wxml | 247 +++---------------------- littleApp_child/pages/home/home.wxss | 337 ++++------------------------------- littleApp_child/utils/util_UI.wxss | 4 + 5 files changed, 81 insertions(+), 826 deletions(-) diff --git a/littleApp_child/app.json b/littleApp_child/app.json index 2587721..e482db2 100644 --- a/littleApp_child/app.json +++ b/littleApp_child/app.json @@ -1,7 +1,8 @@ { "pages": [ - "pages/login/login", "pages/home/home", + "pages/login/login", + "pages/aboutThePrenatal/aboutThePrenatal", "pages/reportDuringPregnancy/reportDuringPregnancy", "pages/reportDuringPregnancyDetail/reportDuringPregnancyDetail", diff --git a/littleApp_child/pages/home/home.js b/littleApp_child/pages/home/home.js index f5d0ba4..62be854 100644 --- a/littleApp_child/pages/home/home.js +++ b/littleApp_child/pages/home/home.js @@ -15,44 +15,20 @@ var app = getApp() Page({ /*---------属性变量--------*/ data: { - isDocument: '', - // 孕周 - week: '-', - // 下次产检 - nextCheckTime: '-', - // 距离预产期 - intervalDays: '-', - avatar: '', - username: '-', - hospitalName: '-', - // 文章列表 - articleList: [], - // 主机类型 - HOSTTypeText: ['测试环境', '', '演示环境',''][networkUtil.Builing_Release_AppStore], - HOSTType: networkUtil.Builing_Release_AppStore, - // 医院ID - hospitalId: 0, - // 孕期报告高危等级的图片 - crisisInfo: { image: '../../source/imageSource/page1_yunqi_green_Image@3x.png', color: '#43bf67' }, - // 高危栏目 - crisisCategorie: '', - hw: false, - member: [] + isLogin: '', + item_big_height:0, + item_small: 0, }, /*---------生命周期--------*/ onLoad: function () { // var that = this // wx.showShareMenu( - + // 计算功能模块的尺寸 + this.calculatePageSize() this.networkStatusChange() // this.networkstatus() if (app.globalData.token == null || app.globalData.token == '') { - this.documentPage() - // wx.login({ - // success: function(res){ - // that.getOpenIdCode(res.code) - // } - // }) + this.loginPage() } else { networkUtil.showLoading() this.getUserInfo() @@ -78,13 +54,13 @@ Page({ }, onShow: function () { // 生命周期函数--监听页面显示 - if (app.globalData.token.length > 0 && this.data.isDocument == true) { + if (app.globalData.token.length > 0 && this.data.isLogin == true) { this.getUserInfo() this.homePage() } if (wx.getStorageSync("access_token") != null && !wx.getStorageSync("isHxOpend")){ - this.connectWebIM() + } }, onUnload: function () { @@ -102,27 +78,8 @@ Page({ this.getUserInfo() this.homePage() }, - // 孕期报告页面 - reportDuringPregnancyTap: function () { - wx.navigateTo({ - url: '../reportDuringPregnancy/reportDuringPregnancy?leftCheckDay=' + this.data.leftCheckDay - }) - }, // 点击头像 tapAvatar: function () { - - // var that = this - // //console.log(event) - // var my = wx.getStorageSync('hxName') - // var nameList = { - // myName: my, - // your: "mommybabydoct4676" - // } - // wx.navigateTo({ - // url: '../chatroom/chatroom?username=' + JSON.stringify(nameList) - // }) - - var that = this wx.showActionSheet({ itemList: ['退出当前用户'], @@ -130,7 +87,7 @@ Page({ if (res.tapIndex == 0) { wx.setStorageSync('userToken', '') getApp().globalData.token = '' - that.documentPage() + that.loginPage() WebIM.conn.close(); } }, @@ -139,163 +96,20 @@ Page({ } }) }, - - // 点击产检须知事件处理 - aboutThePrenatalTap: function () { - wx.navigateTo({ - url: '../aboutThePrenatal/aboutThePrenatal?hospitalId=' + this.data.hospitalId + '&week=' + this.data.currentWeek - }) - }, /*---------自定义函数--------*/ homePage() { this.getAccessToken() var that = this that.setData({ - isDocument: false - }) - - - wx.setStorage({ - key: "myUsername", - data: wx.getStorageSync('hxName') + isLogin: false }) }, - getRoster(){ - var that = this - setTimeout(function () { - WebIM.conn.getRoster({ - success: function (roster) { - //获取好友列表,并进行好友列表渲染,roster格式为: - /** [ - { - jid:'asemoemo#chatdemoui_test1@easemob.com', - name:'test1', - subscription: 'both' - } - ] - */ - var member = [] - for (var i = 0; i < roster.length; i++) { - // if (roster[i].subscription == "both") { - // member.push(roster[i]) - // } - member.push(roster[i]) - } - console.log("getRoster member home:", member) - that.setData({ - member: member - }) - wx.setStorage({ - key: 'member', - data: that.data.member - }) - // console.log("getRoster member home success:", roster) - }, - error: function (err) { - console.log("getRoster erro:", err) - } - }); - }, 3000) - }, - moveFriend: function (message) { - // var that = this - // var rosters = { - // success: function (roster) { - // var member = [] - // for (var i = 0; i < roster.length; i++) { - // if (roster[i].subscription == "both") { - // member.push(roster[i]) - // } - // } - // that.setData({ - // member: member - // }) - // } - // } - // if (message.type == 'unsubscribe' || message.type == 'unsubscribed') { - // WebIM.conn.removeRoster({ - // to: message.from, - // success: function () { - // WebIM.conn.unsubscribed({ - // to: message.from - // }); - // WebIM.conn.getRoster(rosters) - // } - // }) - // } - }, - handleFriendMsg: function (message) { - // var that = this - // console.log(message) - // wx.showModal({ - // title: '添加好友请求', - // content: message.from + '请求加为好友', - // success: function (res) { - // if (res.confirm == true) { - // console.log('vvvvvvvvvvvvv') - // WebIM.conn.subscribed({ - // to: message.from, - // message: "[resp:true]" - // }) - // WebIM.conn.subscribe({ - // to: message.from, - // message: "[resp:true]" - // }) - // } else { - // WebIM.conn.unsubscribed({ - // to: message.from, - // message: "rejectAddFriend" - // }) - // //console.log('delete_friend') - // } - // }, - // fail: function (error) { - // //console.log(error) - // } - // }) - - }, - documentPage() { + loginPage() { var that = this that.setData({ - isDocument: true - }) - }, - getOpenIdCode(code) { - var self = this - // 获取openid - networkUtil._get(api.getOpenId, { code: code }, function (res) { - app.globalData.openInfo.openId = res.openId - }, function (res) { - + isLogin: true }) }, - getAccessToken() { - var that = this - var token=''; - var options = { - apiUrl: WebIM.config.apiURL, - user: wx.getStorageSync('hxName'), - pwd: wx.getStorageSync('hxPassWord'), - // accessToken: token, - // grant_type: "password", - - success: function (res) { - console.log("conn success:", res); - wx.setStorageSync("access_token", res.data.access_token) - token = res.data.access_token - that.getRoster() - }, - fail: function (e) { - console.log("fail:" + e); - }, - autoReconnectNumMax: 30, - autoReconnectInterval: 1, - appKey: WebIM.config.appkey - } - - WebIM.conn.open(options) - }, // 监听网络状态 networkStatusChange() { var that = this @@ -306,125 +120,35 @@ Page({ } }) }, - connectWebIM() { - console.log('开始连接') - WebIM.conn.close() - var that = this - var options = { - apiUrl: WebIM.config.apiURL, - user: wx.getStorageSync('hxName'), - pwd: wx.getStorageSync('hxPassWord'), - accessToken: wx.getStorageSync('access_token'), - // grant_type: "password", - - success: function (res) { - console.log("conn success:", res); - - that.getRoster() - }, - fail: function (e) { - console.log("fail:" + e); - }, - autoReconnectNumMax: 30, - autoReconnectInterval: 1, - appKey: WebIM.config.appkey - } - - WebIM.conn.open(options) - }, - // 获取用户信息 getUserInfo() { var self = this var param = { 'token': app.globalData.token } networkUtil._get(api.getUserInfo, param, function (res) { - console.log("getUserInfo:"+res) - if (res.data.id != 1930) { - self.setData({ - hw: true - }) - } else { - self.setData({ - hw: false - }) - } - var days = numberUtil.calculateTimeInterval(res.data.lastMenses * 1000, new Date().getTime()) - self.getArticleInfo(days) - self.setUserInfo(res.data) }, function (res) { networkUtil.showErrorToast(res.errormsg) - if (res.errorcode == 4002 || res.errorcode == 4003) { - wx.setStorageSync('userToken', '') - getApp().globalData.token = '' - self.documentPage() - } }) }, getArticleInfo(days) { var self = this // 文章列表 networkUtil._get(api.homeArtList, { page: 0, limit: 100, days: days }, function (res) { - console.log(res) - wx.stopPullDownRefresh() - self.data.hospitalId = res.data.hospitalId - self.setData({ - articleList: res.data.list, - crisisCategorie: res.data.highRiskArticles, - hospitalId: self.data.hospitalId - }) }, function (res) { - wx.stopPullDownRefresh() }) }, // 设置UI数据 setUserInfo(data) { - var self = this - var today = new Date() - var interval = numberUtil.calculateTimeInterval(today.getTime(), data.dueDate * 1000) - var date = new Date(data.nextCheckTime) - - self.data.currentWeek = numberUtil.calculateGestationalWeeks(data.lastMenses * 1000) - - var checkTimeText = '' - if (data.nextCheckTime == 0 || data.nextCheckTime == null) { - checkTimeText = '-' - self.data.leftCheckDay = '' - } else { - checkTimeText = data.nextCheckTime - // 剩余几天产检 - self.data.leftCheckDay = numberUtil.calculateTimeInterval(today.getTime(), date.getTime()) - } - getApp().globalData.userInfo = data - // 孕周余数天 - var day = numberUtil.calculateGestationalWeekDay(data.lastMenses * 1000) > 0 ? numberUtil.calculateGestationalWeekDay(data.lastMenses * 1000) + '天' : '' - var intervalText = interval + '天' - var week = '孕' + self.data.currentWeek + '周' + '+' + day - if(day == 0){ - week = '孕' + self.data.currentWeek + '周' - } - if (interval < 0) { - intervalText = '已逾期' - } - if (data.status == 2) { - intervalText = '-' - networkUtil.showErrorToast('您已经分娩或终止妊娠,当前孕程服务已终止') - week = '-' - } - - self.setData({ - week: week, - intervalDays: intervalText, - username: data.username, - avatar: data.avatar.medium, - hospitalName: data.hospitalName, - // 关联危急值 - crisisInfo: numberUtil.home_getRiskInfo(data.crisis), - nextCheckTime: checkTimeText - }) + }, + calculatePageSize(){ + var windowWidth = wx.getSystemInfoSync().windowWidth + var smallWidth = ((windowWidth - 10) / 2 - 10) + this.setData({ + item_big_height: 'height:' + (windowWidth - 10) / 2 + 'px', + item_small: 'width:' + smallWidth / 2 + 'px;height:' + smallWidth / 2 + 'px', + }) } - }) diff --git a/littleApp_child/pages/home/home.wxml b/littleApp_child/pages/home/home.wxml index 7581203..be96689 100644 --- a/littleApp_child/pages/home/home.wxml +++ b/littleApp_child/pages/home/home.wxml @@ -1,47 +1,9 @@ + --{{HOSTTypeText}}-- - - - - - - - - 预约建档 - - 未建档孕妇快速建档 - - - - 已有档案 - - 已建档孕妇获取精准服务 - - - - - @@ -72,199 +34,30 @@ {{hospitalName}} - - - - - - - - + + + + - - - - - - - - - - 高危精准指导 - - - + + + + - - - - - - - - {{item.title}} - - - {{item.introduction}} - - - - - - - {{item.title}} - - - {{item.introduction}} - - - - - - - - - - - - - - - {{item.title}} - - - - - - - - - - - - {{art.title}} - - - {{art.introduction}} - - - + - - - - {{art.title}} - - - {{art.introduction}} - - - - - + + + + 日常护理 + + 如何提防新生儿败血症 + 败血症(septicemia)的意思是致病菌或条件致病菌侵入血循环,在人的血液当中生长繁殖,产生毒素造成急性全身性感 + + + \ No newline at end of file diff --git a/littleApp_child/pages/home/home.wxss b/littleApp_child/pages/home/home.wxss index b5d779f..8592268 100644 --- a/littleApp_child/pages/home/home.wxss +++ b/littleApp_child/pages/home/home.wxss @@ -1,3 +1,4 @@ +@import "../../utils/util_UI.wxss"; /*通用*/ text { font-size: 11px; @@ -10,6 +11,14 @@ text { height:202px; } +.promptText { + background: #f4879b; + font: bold; + text-align: center; + font-size: 10px; + color: white; +} + .TopBgImage { width:100%; height:202px; @@ -94,330 +103,54 @@ text { text-align: center; line-height: 30px; } -/*中间功能模块的整个框架*/ -.founctionModelBG { - /*width: 100%;*/ - height: 24%; - margin-top: 4px; - margin-left: 3px; - margin-right: 2px; -} - -.modelBig { - width: 54%; - height: 100%; - background-color: white; - border-radius: 4px; - float: left; - position: relative; -} - -.modelSmallBG { - width: 23%; - background-color: #d8dbd4; - height: 50%; - float: left; - position: relative; -} - -.modelSmall { - background-color: white; - border-radius: 4px; - position: absolute; - /*垂直居中*/ - /*display: flex; - justify-content:center; - align-items:Center;*/ -} - -.modelSmallContent { - width: 80%; - height: 50px; - margin-left: 50%; - margin-top: 50%; - transform: translateX(-50%) translateY(-65%); -} - -/*功能模块小图标*/ -.iconBg { - width:38px; - height:38px; - position: absolute; - border-radius: 50%; - left: 50%; - transform: translateX(-50%); -} - -.icon { - width:38px; - height:38px; - margin-left: 50%; - transform: translateX(-50%); -} - - -/*// 新增模块*/ -.newModelBg { - margin-top: 3px; - margin-left: 3px; - margin-right: 2px; - height: 12%; - display: flex; - flex-direction: row; - justify-content: space-between; +/*---------foundation---------*/ +.foundation_BG { + margin-left: 5px; + margin-right: 5px; + background: green; + /* display: flex; + flex-wrap: wrap; */ } -.newModel_big { - height: 100%; - width: 55.2%; - border-radius: 4px; - background-color: white; - display: flex; - justify-content:center; - align-items:Center; +.foundation_item_big { + width: 50%; + background: white; + /* display: inline-block; */ + float: left } -.modelBigContent { - width: 38px; - height: 52px; +.foundation_item_small { + background: yellow; + /* display: inline-block; */ + margin-top: 5px; + margin-left: 5px; + float: left } -.newModel_small { - margin-left: 2px; - height: 100%; - width: 23%; - border-radius: 4px; - background-color: white; - position: relative; -} -.newIconBg { - width: 38px; - height: 38px; - border-radius: 50%; - margin-left: 50%; - transform: translateX(-50%); -} +/*---------文章列表---------*/ +.article_bg { -.newModelText { - margin-top: -6px; - transform: translateX(-25%); - text-align: center; - color: #979797; - font-size: 10px; - font: medium; - width: 180%; } -.highRisk_Bg { +.article_title { + height: 30px; background: white; - margin-left: 3px; - margin-top: 3px; - margin-right: 3px; } -/*首页列表文章 顶部的item 布局*/ -.home__list{ +.article_content { background: white; - border-radius: 4px; - margin: 3px; -} - -/*首页列表文章 顶部的item 布局*/ -.home__list__topitem{ - border-bottom: 1rpx solid #d8dbd4; -} - -/*首页列表文章 顶部的的item 布局 的图标*/ -.home__list-topitem-icon{ - /*垂直居中*/ - display: flex; - justify-content:center; - align-items:Center; - width: 20px; - height: 20px; - margin-right: 6px -} - -/*首页列表文章 顶部的的item 布局 的文字*/ -.home__list-topitem-text{ - font-size: 16px; - font:medium; - color: #60c7ed -} - -/*首页列表文章 item 最外层布局*/ -.home__list-item{ - /*border-bottom: 1rpx solid #E5E5E5;*/ - /*left: 20px*/ - position: relative -} - -/*item 分割线*/ -.home__list-item__top{ - position: absolute; - /*width: 100%;*/ - height: 1rpx; - background: #d8dbd4; - top: 0px; - left: 15px; - right: 15px -} - -/*首页列表文章 item 外层布局 右侧*/ -.home__list-item__right{ - width: 100%; - height: 32px; - position:relative; -} - -/*首页列表文章 item 的文章图片*/ -.home__list__img{ - width: 80px; - height: 100%; - vertical-align: top; - /*垂直居中*/ - display: flex; - justify-content:center; - align-items:Center; -} - -.home__list-item-content{ - margin-left: 15px -} - -/*首页列表文章 item 内的title 布局*/ -.home__list-item__title{ - position:absolute; - top: 0px; - left: 0px; - right: 60px; - font-size: 14px; - color: #5e5e5e; - font:normal; -} - -/*首页列表文章 item 内的的点赞 布局*/ -.home__list-item__like{ - position: absolute; - top: 0px; - right: 0px; - /*垂直居中 - display: flex; - justify-content:center; - align-items:Center;*/ -} - -/*首页列表文章 item 内的点赞手图标*/ -.home__list-item__title-like-icon { - position: absolute; - width: 10px; - height: 10px; - right: 0px; - left: 0px; - top: 7px -} - -/*首页列表文章 item 内的的点赞 数*/ -.home__list-item__title-like-count { - /*这个宽度设置后可以变化点赞数整个布局的位置前移后移*/ - width: 30px; - margin-left:15px; - font-size: 10px; - margin-top: 4px; - color: #c8c6c6; - overflow: hidden; - text-overflow: ellipsis; -} - -.promptText { - background: #f4879b; - font: bold; - text-align: center; - font-size: 10px; - color: white; } -/*-----------------------------------是否有建档-------------------------------------------*/ -.whetherTheDocument { - /*position: relative;*/ - width: 100%; - height: 100%; -} - -.background { - width: 100%; - height: 100%; -} - -.noDocumentButton{ - position: relative; - margin-top: 66px; - height: 170px; - margin-left: 35px; - width: 80%; - border-radius: 4px; +.article_content_title { background: white; } -.documentButton{ - position: relative; - margin-top: 20px; - height: 170px; - margin-left: 35px; - width: 80%; - border-radius: 4px; +.article_content_text { background: white; } -.prenatalScreen{ - position: relative; - margin-top: 20px; - height: 170px; - margin-left: 35px; - width: 80%; - border-radius: 4px; +.article_content_image { background: white; -} - -.documentBgImage { - position: absolute; - width: 100%; - height: 100%; - top: 0; - z-index: 0; - border-radius: 4px; -} - -.title{ - position: absolute; - font-weight: bold; - font-size: 20px; - color: #ee7289; - line-height: 20px; - top: 20px; - right: 20px; - bottom: 8px; - left: 20px; -} - -.documentIcon { - width: 20px; - height: 20px; - position: absolute; - top: 21px; - right: 20px; - bottom: 8px; - left: 110px; -} - -.content{ - position: absolute; - font:medium; - color: #5e5e5e; - font-size: 12px; - right: 20px; - left: 20px; - top: 44px; } \ No newline at end of file diff --git a/littleApp_child/utils/util_UI.wxss b/littleApp_child/utils/util_UI.wxss index 20260d8..f30e6f5 100644 --- a/littleApp_child/utils/util_UI.wxss +++ b/littleApp_child/utils/util_UI.wxss @@ -49,4 +49,8 @@ /* 不填*/ .prohibit { background-color: #ECECEC; +} + +.util_bottom_line { + border-bottom: 1px solid #f4879b; } \ No newline at end of file -- 1.8.3.1