Commit 41e691722e7994ae3d52bd66eabb68fd027ffd00

Authored by xianghenggang
1 parent ae0ffc864c

no message

Showing 6 changed files with 269 additions and 2 deletions

littleApp_child/app.json View file @ 41e6917
1 1 {
2 2 "pages": [
  3 + "pages/childcare_knowledge/childcare_knowledge",
3 4 "pages/login/login",
4 5 "pages/home/home",
5 6 "pages/aboutThePrenatal/aboutThePrenatal",
littleApp_child/pages/childcare_knowledge/childcare_knowledge.js View file @ 41e6917
  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 +
  13 +Page({
  14 + data: {
  15 + list:[],
  16 + images: [
  17 + 'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
  18 + 'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
  19 + 'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
  20 + ],
  21 + titles: ["日常护理", "营养美食", "疾病护理", "亲子互动", "言传qq"],
  22 + id:0,
  23 + category:''
  24 + },
  25 + onLoad: function (e) {
  26 + this.data.id = e.id
  27 + this.data.category = e.category
  28 + // 数据初始化
  29 + page = 1
  30 + hasMore = true
  31 + isRefresh = false
  32 +
  33 + // this.requestData()
  34 +
  35 +
  36 + },
  37 + onUnload: function() {
  38 +
  39 + },
  40 + /*---------事件处理函数--------*/
  41 + bindViewTap: function() {
  42 + wx.navigateTo({
  43 + url: '../home/home'
  44 + })
  45 + },
  46 + // 加载更多
  47 + loadMore:function(e){
  48 + if(!hasMore || isRefresh == true){
  49 + return
  50 + }
  51 + page ++
  52 +
  53 + this.requestData()
  54 +
  55 + },
  56 + // 下拉刷新回调接口
  57 + onPullDownRefresh: function() {
  58 + page = 1;
  59 + hasMore = true
  60 + // 网络请求,重新请求一遍数据
  61 + this.requestData();
  62 + },
  63 + myScroll:function(e){
  64 + if(e.detail.scrollTop >= e.detail.scrollHeight-wx.getSystemInfoSync().windowHeight - 3){
  65 + this.loadMore()
  66 + }
  67 + },
  68 + titleClick:function(e){
  69 + console.log(e)
  70 + var index = e.currentTarget.dataset.index
  71 + },
  72 + /*---------自定义函数--------*/
  73 + requestData(id){
  74 + var self = this
  75 + isRefresh = true
  76 + networkUtil.showLoading()
  77 + var param = {page:page,limit:15,type:getApp().globalData.userInfo.status,categoryId:self.data.id}
  78 + networkUtil._get(api.articleList,param,function(res){
  79 +
  80 + isRefresh = false
  81 + var arr = []
  82 + if(page > 0) {// 加载更多模式
  83 + arr = self.data.list
  84 + }
  85 + if(res.data.data.length < 15){
  86 + hasMore = false
  87 + }
  88 + arr = arr.concat(res.data.data)
  89 + var temp = self.data.category
  90 + self.setData({
  91 + list:arr,
  92 + hasMore : hasMore,
  93 + category : temp
  94 + })
  95 + },function(res){
  96 + isRefresh = false
  97 + })
  98 + },
  99 +
  100 +
  101 +})
littleApp_child/pages/childcare_knowledge/childcare_knowledge.json View file @ 41e6917
  1 +{
  2 + "navigationBarBackgroundColor": "#f4879b",
  3 + "navigationBarTitleText": "育儿知识",
  4 + "navigationBarTextStyle": "white",
  5 + "backgroundColor": "#d8dbd4"
  6 +}
littleApp_child/pages/childcare_knowledge/childcare_knowledge.wxml View file @ 41e6917
  1 +<!--articleLists.wxml 文章列表-->
  2 +
  3 +<view style="background:#ffffff;height:100%">
  4 + <image class="search_img" src="../../source/imageSource/cancle_apport.png"></image>
  5 + <scroll-view class="title_scroll" scroll-x="true" scroll-y="false">
  6 + <label class="scroll_title_label" wx:for="{{titles}}">
  7 + <label style="font-size:12px" bindtap="titleClick" data-index="{{index}}">{{item}}</label>
  8 + </label>
  9 + </scroll-view>
  10 + <swiper indicator-dots="true" indicator-active-color="#ffffff">
  11 + <block wx:for="{{images}}">
  12 + <swiper-item>
  13 + <image src="{{item}}"></image>
  14 + </swiper-item>
  15 + </block>
  16 + </swiper>
  17 + <scroll-view scroll-y="true" style="height: 100%;" bindscroll="myScroll">
  18 + <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}}">
  19 + <view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
  20 + <image class="home__list__img" src="{{item.image.medium}}" mode="aspectFit" />
  21 + </view>
  22 + <view class="weui-media-box__bd weui-media-box__bd_in-appmsg home__list-item-content">
  23 + <view class="home__list-item__right">
  24 + <view class="weui-media-box__title home__list-item__title">{{item.title}}</view>
  25 + <view class="home__list-item__like">
  26 + <image class="home__list-item__title-like-icon" src="../../source/imageSource/page1_icon_dianzhan_n@3x.png" />
  27 + <view class="home__list-item__title-like-count">{{item.likeCount ? item.likeCount : 0}}</view>
  28 + </view>
  29 + </view>
  30 + <view class="weui-media-box__desc" style="borth">{{item.introduction}}</view>
  31 + </view>
  32 + <view class="home__list-item__bottom"></view>
  33 + </navigator>
  34 + <view class="loadMoreView" wx:if="{{hasMore}}">加载更多...</view>
  35 + </scroll-view>
  36 +</view>
littleApp_child/pages/childcare_knowledge/childcare_knowledge.wxss View file @ 41e6917
  1 +.title_scroll {
  2 + width: 95%;
  3 + margin-left: 40px;
  4 + position: relative;
  5 + /*可以滚动 */
  6 + white-space: nowrap;
  7 + display: inline-block;
  8 +}
  9 +
  10 +/*隐藏Scrollview滚动条 */
  11 +
  12 +::-webkit-scrollbar {
  13 + width: 0;
  14 + height: 0;
  15 + color: transparent;
  16 +}
  17 +
  18 +.scroll_title_label {
  19 + height: 40px;
  20 + margin-right: 30px;
  21 + text-align: left;
  22 + line-height: 40px;
  23 +}
  24 +
  25 +.search_img {
  26 + width: 20px;
  27 + height: 20px;
  28 + position: absolute;
  29 + margin-top: 11px;
  30 + margin-left: 10px;
  31 +}
  32 +
  33 +.home__list-item {
  34 + position: relative;
  35 + background: white;
  36 +}
  37 +
  38 +/*首页列表文章 item 的文章图片*/
  39 +
  40 +.home__list__img {
  41 + width: 80px;
  42 + height: 100%;
  43 + vertical-align: top;
  44 + /*垂直居中*/
  45 + display: flex;
  46 + justify-content: center;
  47 + align-items: Center;
  48 +}
  49 +
  50 +.home__list-item-content {
  51 + margin-left: 15px;
  52 +}
  53 +
  54 +/*首页列表文章 item 外层布局 右侧*/
  55 +
  56 +.home__list-item__right {
  57 + width: 100%;
  58 + height: 32px;
  59 + /*background: darkcyan;*/
  60 + position: relative;
  61 +}
  62 +
  63 +/*首页列表文章 item 内的title 布局*/
  64 +
  65 +.home__list-item__title {
  66 + position: absolute;
  67 + top: 0px;
  68 + left: 0px;
  69 + right: 60px;
  70 + font-size: 14px;
  71 + color: #5e5e5e;
  72 + font: normal;
  73 +}
  74 +
  75 +/*首页列表文章 item 内的的点赞 布局*/
  76 +
  77 +.home__list-item__like {
  78 + position: absolute;
  79 + top: 0px;
  80 + right: 0px;
  81 + /*垂直居中
  82 + display: flex;
  83 + justify-content:center;
  84 + align-items:Center;*/
  85 +}
  86 +
  87 +/*首页列表文章 item 内的点赞手图标*/
  88 +
  89 +.home__list-item__title-like-icon {
  90 + position: absolute;
  91 + width: 10px;
  92 + height: 10px;
  93 + right: 0px;
  94 + left: 0px;
  95 + top: 7px;
  96 +}
  97 +
  98 +/*首页列表文章 item 内的的点赞 数*/
  99 +
  100 +.home__list-item__title-like-count {
  101 + /*这个宽度设置后可以变化点赞数整个布局的位置前移后移*/
  102 + width: 30px;
  103 + margin-left: 15px;
  104 + font-size: 10px;
  105 + margin-top: 4px;
  106 + color: #c8c6c6;
  107 + overflow: hidden;
  108 + text-overflow: ellipsis;
  109 +}
  110 +
  111 +/*item 分割线*/
  112 +
  113 +.home__list-item__bottom {
  114 + position: absolute;
  115 + height: 1rpx;
  116 + background: #d8dbd4;
  117 + top: 0px;
  118 + left: 15px;
  119 + right: 15px;
  120 +}
littleApp_child/pages/login/login.js View file @ 41e6917
... ... @@ -8,7 +8,7 @@
8 8 var timer;
9 9 var phone;
10 10 var name;
11   -var isFirst=true
  11 +var isFirst = true
12 12 Page({
13 13 data: {
14 14 inputFocus: { codeInput: false },
... ... @@ -36,7 +36,7 @@
36 36 this.keepTime()
37 37 }
38 38 // if (numberUtil.IsTelPhoneNumber(phone)) {
39   -
  39 +
40 40 // } else {
41 41 // wx.showToast({
42 42 // title: '请输入正确手机号码',
... ... @@ -69,6 +69,9 @@
69 69 // 提交表单
70 70 formSubmit: function (e) {
71 71  
  72 + // wx.navigateTo({
  73 + // url: '../childcare_knowledge/childcare_knowledge'
  74 + // })
72 75 var self = this
73 76 if (e.detail.value.code == "") {
74 77 wx.showModal({