微信小程序——获取所有资讯接口数据

发布时间:2019-08-05 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了微信小程序——获取所有资讯接口数据脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

首先获取数据把数据打印出来

接口文档

图片描述
第一现在app.js 赋值 如:
app.js文件

App({
  globalData: {
    //资讯接口
    zixu_url: "http://192.168.1.107:8080/ls/api/client/info/list",
    //资讯id接口
    info_url:"http://192.168.1.107:8080/ls/api/client/info/id/",
    // 资讯详情id 的评论数据接口
    admin_comment:"http://192.168.1.107:8080/ls/api/client/comment/list/info/"

  }
})

index.js文件

onLoad:function(){
    // 生命周期函数--监听页面加载 
    //'?page=0'+'&size=5' 展示前五条 
    VAR zix_data= app.globalData.zixu_url+'?page=0'+'&size=5';
    
    this.getMovieListData(zix_data)
    // console.LOG(postList)
  }
getMovieListData: function (url) {
    var that = this;
    
    wx.request({
      url: url,
      method: 'post', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      header: {
        'content-tyPE': 'application/json'
      },
      success: function (res) {
         
          that.setData({
            postList:res.data.objects,
          });
         );
        }
          
      },
      fail: function (error) {
        // fail
        console.log(error)
      }
    })

}

index.wXMl文件

<!--pages/index/index.wxML-->
<import src="zix-template/zix-template.wxml" />
<!--<import src="/pages/posts/post-item/post-item-template.wxml" />-->

<scroll-view class='container'  bindscrolltolower="lower" scroll-x='true' scroll-y='true'>
   
    <block wx:for="{{postList}}" wx:for-item="item" >
        <!--//template-->
        <view ">
              <view class='zix_template'>
                <image class='zix_img' src="{{coverImage}}"></image>
                <text class='zix_tilte'>{{title}} </text>
              </view>
        </view>
    </block>
</scroll-view>

本人只是为了个人技回顾
第二节 如何下滑加载指定的数量数据
第三节 跳转详情页面的跳转
第四节 详情页面评论和 评论时间的转换遍历展示

脚本宝典总结

以上是脚本宝典为你收集整理的微信小程序——获取所有资讯接口数据全部内容,希望文章能够帮你解决微信小程序——获取所有资讯接口数据所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。