Commit f4d1ae33c845363713c8375ebd81a2c6eeda8745
Exists in
master
and in
2 other branches
Merge branch 'master' of https://git.healthbaby.com.cn/luoye/littleapp_child
* 'master' of https://git.healthbaby.com.cn/luoye/littleapp_child: no message
Showing 3 changed files
littleApp_child/pages/childcare_knowledge/childcare_knowledge.js
View file @
f4d1ae3
... | ... | @@ -8,36 +8,41 @@ |
8 | 8 | // 是否有更多 |
9 | 9 | var hasMore |
10 | 10 | var isRefresh |
11 | +// 获取应用实例 | |
12 | +var app = getApp() | |
11 | 13 | |
12 | - | |
13 | 14 | Page({ |
14 | 15 | data: { |
15 | 16 | list: [ |
16 | - { likeCount: 12, title: "title1", introduction: "content1content1content1content1content1content1content1content1content1content1content1ds到场定损", image: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg" } | |
17 | - , { likeCount: 12, title: "title2", introduction: "content2", image: "http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg" } | |
18 | - , { likeCount: 12, title: "title2", introduction: "content2", image: "http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg" } | |
19 | - , { likeCount: 12, title: "title1", introduction: "content1", image: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg" } | |
20 | - , { likeCount: 12, title: "title2", introduction: "content2", image: "http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg" } | |
21 | - , { likeCount: 12, title: "title2", introduction: "content2", image: "http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg" } | |
17 | + // { likeCount: 12, title: "title1", introduction: "content1content1content1content1content1content1content1content1content1content1content1ds到场定损", image: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg" } | |
18 | + // , { likeCount: 12, title: "title2", introduction: "content2", image: "http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg" } | |
19 | + // , { likeCount: 12, title: "title2", introduction: "content2", image: "http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg" } | |
20 | + // , { likeCount: 12, title: "title1", introduction: "content1", image: "http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg" } | |
21 | + // , { likeCount: 12, title: "title2", introduction: "content2", image: "http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg" } | |
22 | + // , { likeCount: 12, title: "title2", introduction: "content2", image: "http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg" } | |
22 | 23 | ], |
23 | - images: [ | |
24 | - // 'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg', | |
25 | - // 'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg', | |
26 | - 'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg' | |
27 | - ], | |
28 | - titles: ["日常护理", "营养美食", "疾病护理", "亲子互动", "言传身教"], | |
29 | - id:0, | |
24 | + images: {}, | |
25 | + // [ | |
26 | + // // 'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg', | |
27 | + // // 'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg', | |
28 | + // 'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg' | |
29 | + // ] | |
30 | + // , | |
31 | + titles: [],//"日常护理", "营养美食", "疾病护理", "亲子互动", "言传身教" | |
30 | 32 | category:'', |
31 | 33 | current_index:0, |
32 | 34 | }, |
33 | 35 | onLoad: function (e) { |
34 | - this.data.id = e.id | |
35 | - this.data.category = e.category | |
36 | 36 | // 数据初始化 |
37 | + var self=this | |
37 | 38 | page = 1 |
38 | 39 | hasMore = true |
39 | 40 | isRefresh = false |
40 | - | |
41 | + this.setData({ | |
42 | + titles: app.globalData.artList, | |
43 | + category: app.globalData.artList[self.data.current_index].id, | |
44 | + images: app.globalData.artList[self.data.current_index].iconimage | |
45 | + }) | |
41 | 46 | this.requestData() |
42 | 47 | |
43 | 48 | |
44 | 49 | |
45 | 50 | |
... | ... | @@ -74,11 +79,16 @@ |
74 | 79 | } |
75 | 80 | }, |
76 | 81 | titleClick:function(e){ |
77 | - console.log(e) | |
78 | - var index = e.currentTarget.dataset.index | |
82 | + // console.log(e) | |
83 | + var self=this | |
84 | + var current_index = e.currentTarget.dataset.index | |
85 | + var categoryid = e.currentTarget.dataset.categoryid | |
79 | 86 | this.setData({ |
80 | - current_index:index | |
87 | + category: categoryid, | |
88 | + current_index: current_index, | |
89 | + images: app.globalData.artList[current_index].iconimage | |
81 | 90 | }) |
91 | + this.requestData() | |
82 | 92 | }, |
83 | 93 | toSearch(){ |
84 | 94 | wx.navigateTo({ |
85 | 95 | |
86 | 96 | |
87 | 97 | |
... | ... | @@ -90,23 +100,22 @@ |
90 | 100 | var self = this |
91 | 101 | isRefresh = true |
92 | 102 | networkUtil.showLoading() |
93 | - var param = {page:page,limit:15} | |
94 | - networkUtil._get(api.articleList,param,function(res){ | |
95 | - | |
103 | + var param = { page: page, limit: 15, type: 2, days: app.globalData.days, categoryId: self.data.category} | |
104 | + // console.log(param) | |
105 | + networkUtil._get(api.articles,param,function(res){ | |
106 | + console.log(res) | |
96 | 107 | isRefresh = false |
97 | 108 | var arr = [] |
98 | 109 | if(page > 0) {// 加载更多模式 |
99 | 110 | arr = self.data.list |
100 | 111 | } |
101 | - if(res.data.data.length < 15){ | |
112 | + if (res.data.list.length < 15){ | |
102 | 113 | hasMore = false |
103 | 114 | } |
104 | - arr = arr.concat(res.data.data) | |
105 | - var temp = self.data.category | |
115 | + arr = arr.concat(res.data.list) | |
106 | 116 | self.setData({ |
107 | 117 | list:arr, |
108 | 118 | hasMore : hasMore, |
109 | - category : temp | |
110 | 119 | }) |
111 | 120 | },function(res){ |
112 | 121 | isRefresh = false |
littleApp_child/pages/childcare_knowledge/childcare_knowledge.wxml
View file @
f4d1ae3
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | <image class="search_img" src="../../source/ic_search.png" bindtap="toSearch"></image> |
4 | 4 | <scroll-view class="title_scroll" scroll-x="true" scroll-y="false"> |
5 | 5 | <label class="scroll_title_label " wx:for="{{titles}}"> |
6 | - <label style="{{current_index == index? 'border-bottom: 2px solid #48C17B;' : 'border-bottom:0px solid #f4879b;'}}" class="title_text" bindtap="titleClick" data-index="{{index}}">{{item}}</label> | |
6 | + <label style="{{current_index == index? 'border-bottom: 2px solid #48C17B;' : 'border-bottom:0px solid #f4879b;'}}" class="title_text" bindtap="titleClick" data-categoryid="{{item.id}}" data-index="{{index}}">{{item.title}}</label> | |
7 | 7 | |
8 | 8 | </label> |
9 | 9 | </scroll-view> |
10 | 10 | |
... | ... | @@ -11,13 +11,14 @@ |
11 | 11 | <view class="main"> |
12 | 12 | |
13 | 13 | <scroll-view bindscrolltolower="loadMore"> |
14 | - <swiper hidden="{{images.length > 0 ? false : true}}" class="swiper" indicator-dots="false" indicator-active-color="#ffffff"> | |
14 | + <!-- <swiper hidden="{{images.length > 0 ? false : true}}" class="swiper" indicator-dots="false" indicator-active-color="#ffffff"> | |
15 | 15 | <block wx:for="{{images}}"> |
16 | 16 | <swiper-item> |
17 | 17 | <image src="{{item}}"></image> |
18 | 18 | </swiper-item> |
19 | 19 | </block> |
20 | - </swiper> | |
20 | + </swiper> --> | |
21 | + <image class="swiper" src="{{images.medium}}"></image> | |
21 | 22 | <view> |
22 | 23 | <navigator url="../childcare_knowledge_detail/childcare_knowledge_detail" wx:for="{{list}}" wx:key="{{index}}"> |
23 | 24 | <view class="content_item"> |
... | ... | @@ -28,7 +29,7 @@ |
28 | 29 | <image class="zar_img" src="../../source/zar.png"></image> |
29 | 30 | <view class="content_zar">{{item.likeCount}}</view> |
30 | 31 | </view> |
31 | - | |
32 | + | |
32 | 33 | </view> |
33 | 34 | <image class="content_image" src="{{item.image.medium}}"></image> |
34 | 35 | </view> |
... | ... | @@ -36,7 +37,7 @@ |
36 | 37 | </navigator> |
37 | 38 | <view class="loadMoreView" wx:if="{{hasMore}}">加载更多...</view> |
38 | 39 | </view> |
39 | - </scroll-view> | |
40 | + </scroll-view> | |
40 | 41 | |
41 | 42 | </view> |