From eb0f68ad286f30fd1cb015a1a2613001562c1fd8 Mon Sep 17 00:00:00 2001 From: luoye <397379429@qq.com> Date: Wed, 9 Aug 2017 17:20:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- littleApp_child/app.wxss | 7 +- littleApp_child/pages/SearchPage/SearchPage.js | 74 ++++++++--- littleApp_child/pages/SearchPage/SearchPage.wxml | 11 +- littleApp_child/pages/SearchPage/SearchPage.wxss | 11 ++ .../pages/articleDetail/articleDetail.js | 75 +---------- .../pages/articleDetail/articleDetail.wxml | 40 +++--- .../pages/articleDetail/articleDetail.wxss | 140 ++++++++++++--------- littleApp_child/pages/articleLists/articleLists.js | 33 ++--- .../pages/articleLists/articleLists.wxml | 8 +- .../childcare_knowledge_detail.js | 63 ++++------ .../childcare_knowledge_detail.wxml | 6 +- littleApp_child/pages/home/home.js | 6 +- littleApp_child/pages/home/home.wxml | 60 ++++----- littleApp_child/pages/home/home.wxss | 19 +-- littleApp_child/utils/apiFile.js | 4 +- littleApp_child/utils/util_UI.wxss | 4 + 16 files changed, 276 insertions(+), 285 deletions(-) diff --git a/littleApp_child/app.wxss b/littleApp_child/app.wxss index 571c95a..af1d8af 100644 --- a/littleApp_child/app.wxss +++ b/littleApp_child/app.wxss @@ -47,8 +47,11 @@ page{ .loadMoreView { height: 20px; text-align: center; - font-size: 13px; - background-color: white; + font-size: 12px; + width: 100%; + background: rgba(0, 0, 0, 0); + /* background: rebeccapurple; */ + color: rgb(22, 22, 22) } .blankView { diff --git a/littleApp_child/pages/SearchPage/SearchPage.js b/littleApp_child/pages/SearchPage/SearchPage.js index 13313be..fb3b0d4 100644 --- a/littleApp_child/pages/SearchPage/SearchPage.js +++ b/littleApp_child/pages/SearchPage/SearchPage.js @@ -1,21 +1,26 @@ //index.js //获取应用实例 var app = getApp() +var networkUtil = require('../../utils/network_util.js') +var api = require('../../utils/apiFile.js') +var page +// 是否有更多 +var hasMore +var isRefresh + + + Page({ data: { - list: [ - { zar: 12, title: "title1", content: "content1content1content1content1content1content1content1content1content1content1content1ds到场定损", image: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg" } - , { zar: 12, title: "title2", content: "content2", image: "http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg" } - , { zar: 12, title: "title2", content: "content2", image: "http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg" } - , { zar: 12, title: "title1", content: "content1", image: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg" } - , { zar: 12, title: "title2", content: "content2", image: "http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg" } - , { zar: 12, title: "title2", content: "content2", image: "http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg" } - ], + // 搜索结果 + list: [], selectHide: false, inputValue: '', + // 搜索词汇 getSearch: [], modalHidden: true, - searching:true + searching:false, + test:'' }, onLoad: function () { @@ -24,12 +29,11 @@ Page({ onShow: function () { var getSearch = wx.getStorageSync('searchData'); this.setData({ - getSearch: getSearch, + getSearch: getSearch.reverse(), inputValue: '' }) - console.log('search is onshow', getSearch) }, - /*-------------------- 交互----------*/ + /*-------------------- ----------*/ // 设置缓存 setSearchStorage: function () { let data; @@ -40,15 +44,37 @@ Page({ searchData.push(this.data.inputValue) wx.setStorageSync('searchData', searchData) this.setData({ - getSearch: searchData, + getSearch: searchData.reverse(), }) } else { console.log('空白') } }, // 加载数据 - loadData(){ + loadData(text){ + var self = this + isRefresh = true + var param = { k: text, limit: 30, page:1} + networkUtil._get(api.search, param, function (res) { + console.log('数据-----', res) + isRefresh = false + var arr = [] + if (page > 0) {// 加载更多模式 + arr = self.data.list + } + if (res.data.list.length < 15) { + hasMore = false + } + arr = arr.concat(res.data.list) + var temp = self.data.category + self.setData({ + list: arr, + hasMore: hasMore, + category: temp + }) + }, function (res) { + }) }, /*-------------------- 交互----------*/ // 返回 @@ -59,32 +85,41 @@ Page({ // 清除输入框 clearInput: function () { this.setData({ - inputValue: '' + inputValue: '', + list: [], + searching: false }) }, // 输入完成 inputEnd:function(e){ + networkUtil.showLoading() this.setData({ inputValue: e.detail.value, - searching: true + searching: true, + list:[] }) this.setSearchStorage() + this.loadData(e.detail.value) }, // 清除所有历史 clearAll: function () { wx.setStorageSync('searchData', []) this.setData({ getSearch: [], + }) }, // 选择该项历史 selectThis: function (e) { - + this.setData({ + inputValue: e.currentTarget.dataset.text, + searching: true + }) + this.loadData(e.currentTarget.dataset.text) }, // 删除该项历史 deletThis: function (e) { - console.log(e) - + var data = this.data.getSearch data.splice(e.currentTarget.dataset.index,1) this.setData({ @@ -95,6 +130,5 @@ Page({ this.setData({ inputValue: e.detail.value }) - console.log('bindInput' + this.data.inputValue) } }) \ No newline at end of file diff --git a/littleApp_child/pages/SearchPage/SearchPage.wxml b/littleApp_child/pages/SearchPage/SearchPage.wxml index bc164e9..8a02855 100644 --- a/littleApp_child/pages/SearchPage/SearchPage.wxml +++ b/littleApp_child/pages/SearchPage/SearchPage.wxml @@ -11,7 +11,7 @@ - + {{item}} @@ -20,19 +20,20 @@ 清除历史记录 + + - + {{item.title}} {{item.content}} - {{item.zar}} + {{item.likeCount ? item.likeCount : 0}} - - + diff --git a/littleApp_child/pages/SearchPage/SearchPage.wxss b/littleApp_child/pages/SearchPage/SearchPage.wxss index 5b66603..52b2649 100644 --- a/littleApp_child/pages/SearchPage/SearchPage.wxss +++ b/littleApp_child/pages/SearchPage/SearchPage.wxss @@ -98,4 +98,15 @@ /* 结果列表 */ .search_detail { margin-top: 40px; +} + + +.content_title { + + display: inline-block; + overflow: hidden; + text-overflow: ellipsis; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 1; } \ No newline at end of file diff --git a/littleApp_child/pages/articleDetail/articleDetail.js b/littleApp_child/pages/articleDetail/articleDetail.js index 070b3c7..30c38d0 100644 --- a/littleApp_child/pages/articleDetail/articleDetail.js +++ b/littleApp_child/pages/articleDetail/articleDetail.js @@ -18,80 +18,7 @@ Page({ /*---------生命周期--------*/ onLoad: function (options) { - // 记录上层传递的信息 - category = options.category - articleId = options.id - categoryIndex = options.categoryIndex - articleIdIndex = options.artIndex - wx.setNavigationBarTitle({ - title: options.category, - success: function(res) { - } - }) - networkUtil.showLoading() - if(category == '健康评级') { - this.requestRiskData(options.id) - } else { - this.requestData(options.id) - } - }, - /*---------自定义函数--------*/ - requestData(articleId){ - var self = this - var imgH = wx.getSystemInfoSync().windowHeight * 0.33 - networkUtil._get(api.article + '/' + articleId,{},function(res){ - console.log(res) - res.data.content = util.convertHtmlToText(res.data.content) - res.data.imgH = imgH - self.setData({ - articleDetail : res.data, - category : category - }) - },function(res){ - - }) - }, - // 点赞 - articleLike(){ - var self = this - // 已经点赞 - if(self.data.articleDetail.isLike == 1){ - networkUtil.showErrorToast('您已经点过赞啦') - return; - } - networkUtil._post(api.articleLike,{id:articleId},function(res){ - console.log(res) - var art = self.data.articleDetail - art.likeCount ++ - art.isLike = 1 - self.setData({ - articleDetail : art - }) - if(categoryIndex){ - // 更新首页数据 - event.emit('likeChanged', {categoryIndex:categoryIndex,articleIdIndex:articleIdIndex}); - } else { - event.emit('listLikeChanged', {categoryIndex:categoryIndex,articleIdIndex:articleIdIndex}); - } - },function(res){ - console.log(res) - }) - }, - // 高危详情页面 - requestRiskData(articleId){ - var self = this - networkUtil._get(api.riskDetails,{id:articleId},function(res){ - console.log(res) - res.data.content = util.convertHtmlToText(res.data.desc) - res.data.imgH = '0px' - self.setData({ - articleDetail : res.data, - category : category, - pageType : '2' - }) - },function(res){ - - }) }, + /*---------自定义函数--------*/ }) diff --git a/littleApp_child/pages/articleDetail/articleDetail.wxml b/littleApp_child/pages/articleDetail/articleDetail.wxml index bb28816..9400e1c 100644 --- a/littleApp_child/pages/articleDetail/articleDetail.wxml +++ b/littleApp_child/pages/articleDetail/articleDetail.wxml @@ -1,19 +1,25 @@ - - - - - {{articleDetail.title ? articleDetail.title : ''}} - {{category ? category:''}} - {{articleDetail.introduction ? articleDetail.introduction : ''}} - - {{(articleDetail.content && articleDetail.content != 'null') ? articleDetail.content : ''}} - - - - - {{articleDetail.likeCount == null ? 0 : articleDetail.likeCount}} + + + + + + {{userData.username}} + + + + 体检医院 + {{userData.checkhospital}} + + + 月龄 + {{userData.monthage ? userData.monthage : '-'}} + + + + 健康状况 + {{userData.hstatus}} + - - - + + \ No newline at end of file diff --git a/littleApp_child/pages/articleDetail/articleDetail.wxss b/littleApp_child/pages/articleDetail/articleDetail.wxss index 1bed2f1..131c086 100644 --- a/littleApp_child/pages/articleDetail/articleDetail.wxss +++ b/littleApp_child/pages/articleDetail/articleDetail.wxss @@ -1,71 +1,93 @@ -/**articleDetail.wxss 文章详情**/ - -.articleDetail{ - display: flex; - flex-direction: column; - background: white +/*顶部模块*/ +.TopBar { + width:100%; + height:202px; } -.article-image{ - width: 100%; -} -.article-title{ - font: medium bold; - font-size: 24px; - margin: 60rpx 60rpx 30rpx 60rpx; - color: black +.promptText { + background: #f4879b; + font: bold; + text-align: center; + font-size: 10px; + color: white; } -.article-type{ - font: medium; - font-size: 16px; - color: #ee7289; - margin-right: 30px; - margin-left: 30px; + +.TopBgImage { + width:100%; + height:202px; + position: absolute; + background: #48C17B; } -.article-tip{ - margin: 0rpx 90rpx 60rpx 90rpx; - color: #979797; - line-height: 25px; - font-size: 15px; - text-align: center; + +.avatar { + width:70px; + height:70px; + border-radius: 50%; + position: absolute; + top: 15px; + left: 50%; + transform: translateX(-50%); + border: 3px solid white; + box-shadow: 0 2px 4px 0 rgba(186,70,70,0.50); } -.article-line{ - width: 300rpx; - height: 2rpx; - background: #d8dbd4; - margin-left: 50%; + +.userName { + font-size: 14px; + font-weight: bold; + display: block; + top: 100px; + position: absolute; + /*居中*/ + left: 50%; transform: translateX(-50%); } -.article-content{ - margin: 0rpx 40rpx 0rpx 40rpx; - font: lighter; - font-size: 18px; - line-height: 27px; - /*letter-spacing: 3rpx;*/ - text-indent: 2em; - white-space: normal; + +.documentView { + position: absolute; + top: 0px; + left: 0px; + right: 0px; + bottom: 0px; +} + +/*上方信息条部分*/ +.infoBar { + width: 100%; + height: 60px; + top: 142px; + position: absolute; } -.article-like{ - width: 150rpx; - height: 150rpx; - border-radius: 100rpx; - margin-left: 50%; - transform: translateX(-50%); + +.infoView { + text-align: center; + width: 33.3%; + height: 100%; + display:inline-block; + box-sizing: border-box; position: relative; - margin-bottom: 150rpx; - margin-top: 100rpx; + background-color: rgba(255, 255, 255, 0.1); } -.article-likeview{ - width: 150rpx; - height: 150rpx; -} -.article-likenum{ - margin-left: 50%; - transform: translateX(-50%); + +.lineView { + width: 100%; + border-right: solid rgba(255, 255, 255, 0.7) 0.5px; + border-left: solid rgba(255, 255, 255, 0.7) 0.5px; + height: 40px; position: absolute; - bottom: 30rpx; - font: medium; - line-height: 28rpx; - font-size: 28rpx; - color: white + top: 10px; } + +.titleText { + margin-top: 12px; + display:block; + font-size: 11px; +color: #D8FCE7; +} + +.timeText { + font-family: PingFangSC-Medium; + font-size: 12px; + color: #FFFFFF; + display:block; + margin-top: 2px; +} \ No newline at end of file diff --git a/littleApp_child/pages/articleLists/articleLists.js b/littleApp_child/pages/articleLists/articleLists.js index e85d1d5..d496618 100644 --- a/littleApp_child/pages/articleLists/articleLists.js +++ b/littleApp_child/pages/articleLists/articleLists.js @@ -8,8 +8,7 @@ var page // 是否有更多 var hasMore var isRefresh -// 高危指导页面 -var isRisk + Page({ data: { @@ -18,26 +17,22 @@ Page({ category:'' }, onLoad: function (e) { - this.data.id = e.id + this.data.id = e.categoryId this.data.category = e.category + console.log(e.categoryId) // 数据初始化 page = 1 hasMore = true isRefresh = false - isRisk = false wx.setNavigationBarTitle({ title: e.category, success: function(res) { } }) - if(e.category == '高危精准指导'){ - isRisk = true - this.requestRisk() - } else { - isRisk = false - this.requestData() - } + // this.setData({}) + + this.requestData() // 监听事件 event.on('listLikeChanged', this, function(data) { var artList = this.data.list @@ -63,11 +58,7 @@ Page({ return } page ++ - if(isRisk == true){ - this.requestRisk() - } else { - this.requestData() - } + this.requestData() }, // 下拉刷新回调接口 onPullDownRefresh: function() { @@ -86,18 +77,18 @@ Page({ var self = this isRefresh = true networkUtil.showLoading() - var param = {page:page,limit:15,type:getApp().globalData.userInfo.status,categoryId:self.data.id} - networkUtil._get(api.articleList,param,function(res){ - + var param = { page: page, limit: 15, type: 2, days: getApp().globalData.days,categoryId:self.data.id} + networkUtil._get(api.articles,param,function(res){ + console.log(res) isRefresh = false var arr = [] if(page > 0) {// 加载更多模式 arr = self.data.list } - if(res.data.data.length < 15){ + if(res.data.list.length < 15){ hasMore = false } - arr = arr.concat(res.data.data) + arr = arr.concat(res.data.list) var temp = self.data.category self.setData({ list:arr, diff --git a/littleApp_child/pages/articleLists/articleLists.wxml b/littleApp_child/pages/articleLists/articleLists.wxml index b3dbb64..0cf7ee8 100644 --- a/littleApp_child/pages/articleLists/articleLists.wxml +++ b/littleApp_child/pages/articleLists/articleLists.wxml @@ -16,14 +16,14 @@ --> - + - {{item.title}}111 - {{item.introduction}}111 + {{item.title}} + {{item.introduction}} - {{item.likeCount}}11 + {{item.likeCount ? item.likeCount : 0}} diff --git a/littleApp_child/pages/childcare_knowledge_detail/childcare_knowledge_detail.js b/littleApp_child/pages/childcare_knowledge_detail/childcare_knowledge_detail.js index c419c62..fe3480e 100644 --- a/littleApp_child/pages/childcare_knowledge_detail/childcare_knowledge_detail.js +++ b/littleApp_child/pages/childcare_knowledge_detail/childcare_knowledge_detail.js @@ -4,37 +4,36 @@ var networkUtil = require('../../utils/network_util.js') var api = require('../../utils/apiFile.js') // 事件监听 var event = require('../../utils/event.js') -var page -// 是否有更多 -var hasMore -var isRefresh +var util = require('../../utils/util.js') Page({ data: { - knowledge: { time: "2017-8-7", likeCount: 12, title: "title1", content: "content1content1content1content1content1content1content1content1content1content1content1ds到场定损", image: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg" }, + knowledge: { time: "", likeCount: 0, title: "", content: "", image: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg" }, images: [ 'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg', - 'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg', - 'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg' ], titles: ["日常护理", "营养美食", "疾病护理", "亲子互动", "言传qq"], id: 0, category: '', current_index: 0, + title:'' }, - onLoad: function (e) { - this.data.id = e.id - this.data.category = e.category - // 数据初始化 - page = 1 - hasMore = true - isRefresh = false - - // this.requestData() - - + onLoad: function (options) { + // this.data.id = e.id + // this.data.category = e.category + // 记录上层传递的信息 + // category = options.category + // articleId = options.id + // categoryIndex = options.categoryIndex + // articleIdIndex = options.artIndex + wx.setNavigationBarTitle({ + title: options.category, + success: function (res) { + } + }) + this.requestData(options.id) }, onUnload: function () { @@ -77,28 +76,16 @@ Page({ /*---------自定义函数--------*/ requestData(id) { var self = this - isRefresh = true networkUtil.showLoading() - var param = { page: page, limit: 15, type: getApp().globalData.userInfo.status, categoryId: self.data.id } - networkUtil._get(api.articleList, param, function (res) { - - isRefresh = false - var arr = [] - if (page > 0) {// 加载更多模式 - arr = self.data.list - } - if (res.data.data.length < 15) { - hasMore = false - } - arr = arr.concat(res.data.data) - var temp = self.data.category - self.setData({ - list: arr, - hasMore: hasMore, - category: temp - }) + // var param = { page: page, limit: 15, type: 2, categoryId: self.data.id } + networkUtil._get(api.articles + '/' + id, {}, function (res) { + console.log('数据-----',res) + res.data.content = util.convertHtmlToText(res.data.content) + self.setData({ + knowledge: res.data + }) }, function (res) { - isRefresh = false + }) }, diff --git a/littleApp_child/pages/childcare_knowledge_detail/childcare_knowledge_detail.wxml b/littleApp_child/pages/childcare_knowledge_detail/childcare_knowledge_detail.wxml index d5a18ef..58f81a4 100644 --- a/littleApp_child/pages/childcare_knowledge_detail/childcare_knowledge_detail.wxml +++ b/littleApp_child/pages/childcare_knowledge_detail/childcare_knowledge_detail.wxml @@ -4,15 +4,15 @@ - {{knowledge.likeCount}} + {{knowledge.likeCount ? knowledge.likeCount : 0}} {{knowledge.time}} diff --git a/littleApp_child/pages/home/home.js b/littleApp_child/pages/home/home.js index dd4ac8b..43da9e6 100644 --- a/littleApp_child/pages/home/home.js +++ b/littleApp_child/pages/home/home.js @@ -143,7 +143,7 @@ Page({ var self = this var param = { 'token': app.globalData.token } - networkUtil._get(api.userInfo + app.globalData.userId, {}, function (res) { + networkUtil._get(api.userInfo + app.globalData.userId[0], {}, function (res) { console.log('获取用户信息',res) app.globalData.days = res.data.data.days self.getArticleInfo(res.data.data.days) @@ -260,11 +260,11 @@ Page({ }, loginSuccess(data) { wx.setStorageSync('userToken', data.token) - wx.setStorageSync('userId', data.id) + wx.setStorageSync('userId', data.patientIds) wx.setStorageSync('hxName', data.hxName) wx.setStorageSync('hxPassWord', data.hxPassWord) getApp().globalData.token = data.token - getApp().globalData.userId = data.id + getApp().globalData.userId = data.patientIds this.homePage() } diff --git a/littleApp_child/pages/home/home.wxml b/littleApp_child/pages/home/home.wxml index 0458561..0512b7d 100644 --- a/littleApp_child/pages/home/home.wxml +++ b/littleApp_child/pages/home/home.wxml @@ -9,7 +9,7 @@ - + {{userData.username}} @@ -20,7 +20,7 @@ 月龄 - {{userData.monthage}} + {{userData.monthage ? userData.monthage : '-'}} @@ -53,32 +53,34 @@ - - - - - - {{sectionItem.title}} - - - - - - {{item.title}} - - - - - - - - - + + + + + + + {{sectionItem.title}} + - - - + + + + {{item.title}} + + + + + + + + + + + + + + @@ -125,8 +127,8 @@
- - + + diff --git a/littleApp_child/pages/home/home.wxss b/littleApp_child/pages/home/home.wxss index 587d6e1..584ca3c 100644 --- a/littleApp_child/pages/home/home.wxss +++ b/littleApp_child/pages/home/home.wxss @@ -1,10 +1,6 @@ @import "css/AboutPage.wxss"; @import "css/login.wxss"; /*通用*/ -text { - font-size: 11px; - color: #ffffff; -} /*顶部模块*/ .TopBar { @@ -48,6 +44,7 @@ text { /*居中*/ left: 50%; transform: translateX(-50%); + color: white; } .documentView { @@ -150,9 +147,13 @@ color: #D8FCE7; } /*---------文章列表---------*/ +.article_list_bg { + width: 100%; + background: #F4F4F4; +} + .article_list { - - /* background: red; */ + background: #F4F4F4; margin-left: 5px; margin-right: 5px; margin-top: 11px; @@ -183,9 +184,9 @@ color: #D8FCE7; .article_title_indicator { width: 12px; height: 14px; - float: right; - margin-right: 10px; - margin-top: 10px; + position: absolute; + right: 15px; + transform: translateY(8px); } /* 文章ne内容背景 */ .article_content { diff --git a/littleApp_child/utils/apiFile.js b/littleApp_child/utils/apiFile.js index 33ccd6d..dc67862 100644 --- a/littleApp_child/utils/apiFile.js +++ b/littleApp_child/utils/apiFile.js @@ -11,5 +11,7 @@ module.exports = { // 首页文章列表 homeArtList:'baby/categories', //育儿知识分类列表 - articles:'v1/articles' + articles:'v1/articles', + //搜索 + search:'/v1/search' } \ No newline at end of file diff --git a/littleApp_child/utils/util_UI.wxss b/littleApp_child/utils/util_UI.wxss index 078fb62..b3b5ab6 100644 --- a/littleApp_child/utils/util_UI.wxss +++ b/littleApp_child/utils/util_UI.wxss @@ -53,4 +53,8 @@ .util_bottom_line { border-bottom: 1px solid #e2e2e2; +} + +.whiteColor { + background: white; } \ No newline at end of file -- 1.8.3.1