Commit 1db52ba8705541537f1060fc2019b2edfdcd8f2d

Authored by luoye
1 parent d2ac137133

文章列表

Showing 5 changed files with 168 additions and 99 deletions

littleApp_child/pages/articleLists/articleLists.js View file @ 1db52ba
  1 +//articleLists.js 文章列表
  2 +// 网络请求工具类
  3 +var networkUtil = require('../../utils/network_util.js')
  4 +var api = require('../../utils/apiFile.js')
  5 +// 事件监听
  6 +var event = require('../../utils/event.js')
  7 +var page
  8 +// 是否有更多
  9 +var hasMore
  10 +var isRefresh
  11 +// 高危指导页面
  12 +var isRisk
1 13  
2   -
3 14 Page({
4 15 data: {
5 16 list:[],
  17 + id:0,
  18 + category:''
6 19 },
7   - onLoad:function(){
  20 + onLoad: function (e) {
  21 + this.data.id = e.id
  22 + this.data.category = e.category
  23 + // 数据初始化
  24 + page = 1
  25 + hasMore = true
  26 + isRefresh = false
  27 + isRisk = false
  28 +
  29 + wx.setNavigationBarTitle({
  30 + title: e.category,
  31 + success: function(res) {
  32 + }
  33 + })
  34 + if(e.category == '高危精准指导'){
  35 + isRisk = true
  36 + this.requestRisk()
  37 + } else {
  38 + isRisk = false
  39 + this.requestData()
  40 + }
  41 + // 监听事件
  42 + event.on('listLikeChanged', this, function(data) {
  43 + var artList = this.data.list
  44 + artList[parseInt(data.articleIdIndex)].likeCount ++
  45 + this.setData({
  46 + list : artList
  47 + });
  48 + })
  49 + },
  50 + onUnload: function() {
  51 + // 移除监听
  52 + event.remove('listLikeChanged', this);
  53 + },
  54 + /*---------事件处理函数--------*/
  55 + bindViewTap: function() {
  56 + wx.navigateTo({
  57 + url: '../home/home'
  58 + })
  59 + },
  60 + // 加载更多
  61 + loadMore:function(e){
  62 + if(!hasMore || isRefresh == true){
  63 + return
  64 + }
  65 + page ++
  66 + if(isRisk == true){
  67 + this.requestRisk()
  68 + } else {
  69 + this.requestData()
  70 + }
  71 + },
  72 + // 下拉刷新回调接口
  73 + onPullDownRefresh: function() {
  74 + page = 1;
  75 + hasMore = true
  76 + // 网络请求,重新请求一遍数据
  77 + this.requestData();
  78 + },
  79 + myScroll:function(e){
  80 + if(e.detail.scrollTop >= e.detail.scrollHeight-wx.getSystemInfoSync().windowHeight - 3){
  81 + this.loadMore()
  82 + }
  83 + },
  84 + /*---------自定义函数--------*/
  85 + requestData(id){
  86 + var self = this
  87 + isRefresh = true
  88 + networkUtil.showLoading()
  89 + var param = {page:page,limit:15,type:getApp().globalData.userInfo.status,categoryId:self.data.id}
  90 + networkUtil._get(api.articleList,param,function(res){
  91 +
  92 + isRefresh = false
  93 + var arr = []
  94 + if(page > 0) {// 加载更多模式
  95 + arr = self.data.list
  96 + }
  97 + if(res.data.data.length < 15){
  98 + hasMore = false
  99 + }
  100 + arr = arr.concat(res.data.data)
  101 + var temp = self.data.category
  102 + self.setData({
  103 + list:arr,
  104 + hasMore : hasMore,
  105 + category : temp
  106 + })
  107 + },function(res){
  108 + isRefresh = false
  109 + })
  110 + },
  111 + requestRisk(){
  112 + var self = this
  113 + isRefresh = true
  114 + networkUtil.showLoading()
  115 + var param = {page:page,limit:15}
  116 + networkUtil._get(api.riskGuideList,param,function(res){
  117 + console.log(res)
  118 + isRefresh = false
  119 + var arr = []
  120 + if(page > 0) {// 加载更多模式
  121 + arr = self.data.list
  122 + }
  123 + if(res.data.list.length < 15){
  124 + hasMore = false
  125 + }
  126 + arr = arr.concat(res.data.list)
  127 + var temp = self.data.category
  128 + self.setData({
  129 + list:arr,
  130 + hasMore : hasMore,
  131 + category : temp
  132 + })
  133 + },function(res){
  134 + isRefresh = false
  135 + })
8 136  
9 137 }
10   -
11   -
12 138 })
littleApp_child/pages/articleLists/articleLists.json View file @ 1db52ba
1 1 {
2   - "navigationBarBackgroundColor": "#f4879b",
  2 + "navigationBarBackgroundColor": "#48C17B",
3 3 "navigationBarTitleText": "文章列表",
4 4 "navigationBarTextStyle": "white",
5 5 "backgroundColor": "#d8dbd4"
littleApp_child/pages/articleLists/articleLists.wxml View file @ 1db52ba
1   -<!-- <view class="image">
2   - <view> -->
3   -
4   - <!-- </view>
5   -</view> -->
6   -<!-- <view>
7   - <image class="icon"></image>
8   - <view class="title">预约建档</view>
9   - <view class="content">可通过小程序“孕检指导”,在线创建档案信息,前往医院后在档案科室完成信息核对即刻完成建档建立。</view>
10   -</view>
11   -<view>
12   - <image class="icon"></image>
13   - <view class="title">产检记录</view>
14   - <view class="content">通过“孕期报告”、“检验报告”可查看相关检查记录,及时了解产前孕妇的身体健康的相关信息。</view>
15   -</view>
16   -<view>
17   - <image class="icon"></image>
18   - <view class="title">高危指导</view>
19   - <view class="content">根据孕妇的相关健康指数,针对高危孕妇,可根据月龄提供精确指导。</view>
20   -</view> -->
21   -
22   -
23   -
24   -
25   -
26   -<image class="topImg" src="http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg"></image>
27   -<view>
28   - <view class="title_view">
29   - <image class="icon"></image>
30   - <view class="title">幼儿保健</view>
31   - </view>
32   - <view class="content">妈咪baby之“幼儿保健”,主要针对0-6周岁婴幼儿提供院内保健检查信息、诊断指导意见以及相关医疗服务提醒等业务。</view>
33   -</view>
34   -<view>
35   - <view class="title_view">
36   - <image class="icon"></image>
37   - <view class="title">儿保记录</view>
38   - </view>
39   - <view class="content">查看婴幼儿在院内检查的各项信息,以及对应的诊断、处理、指导意见。</view>
40   -</view>
41   -<view>
42   - <view class="title_view">
43   - <image class="icon"></image>
44   - <view class="title">服务提醒</view>
45   - </view>
46   - <view class="content">可提供高危、复查、预约、精确指导等相关及时提醒服务。</view>
47   -</view>
48   -<view>
49   - <view class="title_view">
50   - <image class="icon"></image>
51   - <view class="title">育儿知识</view>
52   - </view>
53   - <view class="content">根据儿童生长发育情况,每周提供针对性婴幼儿日常护理、营养饮食、疾病护理等相关信息。</view>
54   -</view>
  1 +<!--articleLists.wxml 文章列表-->
  2 +<scroll-view scroll-y="true" style="height: 100%;" bindscroll="myScroll">
  3 + <!-- <navigator url="../articleDetail/articleDetail?id={{item.id}}&category={{category}}&artIndex={{index}}" class="weui-media-box weui-media-box_appmsg home__list-item" hover-class="weui-cell_active" wx:for="{{list}}" wx:key="{{index}}">
  4 + <view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
  5 + <image class="home__list__img" src="{{item.image.medium}}" mode="aspectFit"/>
  6 + </view>
  7 + <view class="weui-media-box__bd weui-media-box__bd_in-appmsg home__list-item-content">
  8 + <view class="home__list-item__right">
  9 + <view class="weui-media-box__title home__list-item__title">{{item.title}}</view>
  10 + <view class="home__list-item__like">
  11 + <image class="home__list-item__title-like-icon" src="../../source/imageSource/page1_icon_dianzhan_n@3x.png"/>
  12 + <view class="home__list-item__title-like-count">{{item.likeCount ? item.likeCount : 0}}</view>
  13 + </view>
  14 + </view>
  15 + <view class="weui-media-box__desc" style="borth">{{item.introduction}}</view>
  16 + </view>
  17 + <view class="home__list-item__bottom"></view>
  18 + </navigator> -->
  19 + <navigator url="../childcare_knowledge_detail/childcare_knowledge_detail" wx:for="{{list}}" wx:key="{{index}}">
  20 + <view class="content_item">
  21 + <view style="margin-left:15px;margin-right:75px;">
  22 + <view class="content_title">{{item.title}}111</view>
  23 + <view class="content_content">{{item.introduction}}111</view>
  24 + <view class="zar_box">
  25 + <image class="zar_img" src="../../source/zar.png"></image>
  26 + <view class="content_zar">{{item.likeCount}}11</view>
  27 + </view>
  28 + </view>
  29 + <image class="content_image" src="{{item.image.medium}}"></image>
  30 + </view>
  31 + <view class="home__list-item__bottom"></view>
  32 + </navigator>
  33 + <view class="loadMoreView" wx:if="{{hasMore}}">加载更多...</view>
  34 +</scroll-view>
littleApp_child/pages/articleLists/articleLists.wxss View file @ 1db52ba
1   -
2   -
3   -.topImg {
4   - width: 100%;
5   - height: 30%;
6   -}
7   -
8   -.icon {
9   - width: 2px;
10   - height: 14px;
11   - margin-left: 15px;
12   - transform: translateY(2px);
13   - background: #48C17B;
14   -}
15   -
16   -/* 栏目标题文字 */
17   -.title {
18   - height: 17px;
19   - display: inline-block;
20   - line-height: 17px;
21   - font-size: 14px;
22   - color: #000;
23   - margin-left: 5px;
24   -}
25   -
26   -/* 内容文字 */
27   -.content {
28   - font-size: 12px;
29   - color: #888888;
30   - margin-left: 15px;
31   - margin-right: 15px;
32   - margin-top: 0px;
33   - display: inline-block;
34   -}
35   -
36   -.title_view {
37   - margin-top: 25px;
38   -}
  1 +@import "../childcare_knowledge/childcare_knowledge.wxss";
littleApp_child/pages/home/home.wxml View file @ 1db52ba
... ... @@ -56,7 +56,7 @@
56 56 <view class="article_list">
57 57 <block wx:for="{{list}}" wx:for-index="sectionIndex" wx:for-item="sectionItem">
58 58 <view class="article_bg">
59   - <navigator url="../childcare_knowledge/childcare_knowledge" class="navigator_class">
  59 + <navigator url="../articleLists/articleLists" class="navigator_class">
60 60 <image class="article_title_image"></image>
61 61 <view class="article_title">{{sectionItem.title}}</view>
62 62 <image class="article_title_indicator" mode="aspectFit" src="../../source/gengduo.png"></image>
... ... @@ -72,7 +72,7 @@
72 72 </view> -->
73 73 <view class="article_content_bottomBar_likes">
74 74 <image class="article_content_bottomBar_likes_icon" src="../../source/like.png"></image>
75   - <label class="article_content_bottomBar_likes_text">{{item.likeCount}}</label>
  75 + <label class="article_content_bottomBar_likes_text">{{item.likeCount ? item.likeCount : 0}}</label>
76 76 </view>
77 77 </view>
78 78 </navigator>