From 1db52ba8705541537f1060fc2019b2edfdcd8f2d Mon Sep 17 00:00:00 2001 From: luoye <397379429@qq.com> Date: Tue, 8 Aug 2017 18:12:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- littleApp_child/pages/articleLists/articleLists.js | 134 ++++++++++++++++++++- .../pages/articleLists/articleLists.json | 2 +- .../pages/articleLists/articleLists.wxml | 88 ++++++-------- .../pages/articleLists/articleLists.wxss | 39 +----- littleApp_child/pages/home/home.wxml | 4 +- 5 files changed, 168 insertions(+), 99 deletions(-) diff --git a/littleApp_child/pages/articleLists/articleLists.js b/littleApp_child/pages/articleLists/articleLists.js index 2fc7473..e85d1d5 100644 --- a/littleApp_child/pages/articleLists/articleLists.js +++ b/littleApp_child/pages/articleLists/articleLists.js @@ -1,12 +1,138 @@ - +//articleLists.js 文章列表 +// 网络请求工具类 +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 isRisk Page({ data: { list:[], + id:0, + category:'' + }, + onLoad: function (e) { + this.data.id = e.id + this.data.category = e.category + // 数据初始化 + 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() + } + // 监听事件 + event.on('listLikeChanged', this, function(data) { + var artList = this.data.list + artList[parseInt(data.articleIdIndex)].likeCount ++ + this.setData({ + list : artList + }); + }) + }, + onUnload: function() { + // 移除监听 + event.remove('listLikeChanged', this); + }, + /*---------事件处理函数--------*/ + bindViewTap: function() { + wx.navigateTo({ + url: '../home/home' + }) }, - onLoad:function(){ + // 加载更多 + loadMore:function(e){ + if(!hasMore || isRefresh == true){ + return + } + page ++ + if(isRisk == true){ + this.requestRisk() + } else { + this.requestData() + } + }, + // 下拉刷新回调接口 + onPullDownRefresh: function() { + page = 1; + hasMore = true + // 网络请求,重新请求一遍数据 + this.requestData(); + }, + myScroll:function(e){ + if(e.detail.scrollTop >= e.detail.scrollHeight-wx.getSystemInfoSync().windowHeight - 3){ + this.loadMore() + } + }, + /*---------自定义函数--------*/ + 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 + }) + },function(res){ + isRefresh = false + }) + }, + requestRisk(){ + var self = this + isRefresh = true + networkUtil.showLoading() + var param = {page:page,limit:15} + networkUtil._get(api.riskGuideList,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){ + isRefresh = false + }) } - - }) diff --git a/littleApp_child/pages/articleLists/articleLists.json b/littleApp_child/pages/articleLists/articleLists.json index e6a29bd..1037434 100644 --- a/littleApp_child/pages/articleLists/articleLists.json +++ b/littleApp_child/pages/articleLists/articleLists.json @@ -1,5 +1,5 @@ { - "navigationBarBackgroundColor": "#f4879b", + "navigationBarBackgroundColor": "#48C17B", "navigationBarTitleText": "文章列表", "navigationBarTextStyle": "white", "backgroundColor": "#d8dbd4" diff --git a/littleApp_child/pages/articleLists/articleLists.wxml b/littleApp_child/pages/articleLists/articleLists.wxml index 624b431..b3dbb64 100644 --- a/littleApp_child/pages/articleLists/articleLists.wxml +++ b/littleApp_child/pages/articleLists/articleLists.wxml @@ -1,54 +1,34 @@ - - - - - - - - - - - - - - 幼儿保健 - - 妈咪baby之“幼儿保健”,主要针对0-6周岁婴幼儿提供院内保健检查信息、诊断指导意见以及相关医疗服务提醒等业务。 - - - - - 儿保记录 - - 查看婴幼儿在院内检查的各项信息,以及对应的诊断、处理、指导意见。 - - - - - 服务提醒 - - 可提供高危、复查、预约、精确指导等相关及时提醒服务。 - - - - - 育儿知识 - - 根据儿童生长发育情况,每周提供针对性婴幼儿日常护理、营养饮食、疾病护理等相关信息。 - + + + + + + + {{item.title}}111 + {{item.introduction}}111 + + + {{item.likeCount}}11 + + + + + + + 加载更多... + \ No newline at end of file diff --git a/littleApp_child/pages/articleLists/articleLists.wxss b/littleApp_child/pages/articleLists/articleLists.wxss index bb3a863..d5d4c6b 100644 --- a/littleApp_child/pages/articleLists/articleLists.wxss +++ b/littleApp_child/pages/articleLists/articleLists.wxss @@ -1,38 +1 @@ - - -.topImg { - width: 100%; - height: 30%; -} - -.icon { - width: 2px; - height: 14px; - margin-left: 15px; - transform: translateY(2px); - background: #48C17B; -} - -/* 栏目标题文字 */ -.title { - height: 17px; - display: inline-block; - line-height: 17px; - font-size: 14px; - color: #000; - margin-left: 5px; -} - -/* 内容文字 */ -.content { - font-size: 12px; - color: #888888; - margin-left: 15px; - margin-right: 15px; - margin-top: 0px; - display: inline-block; -} - -.title_view { - margin-top: 25px; -} \ No newline at end of file +@import "../childcare_knowledge/childcare_knowledge.wxss"; \ No newline at end of file diff --git a/littleApp_child/pages/home/home.wxml b/littleApp_child/pages/home/home.wxml index f364358..0458561 100644 --- a/littleApp_child/pages/home/home.wxml +++ b/littleApp_child/pages/home/home.wxml @@ -56,7 +56,7 @@ - + {{sectionItem.title}} @@ -72,7 +72,7 @@ --> - + -- 1.8.3.1