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

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

接口文档

图片描述
第一现在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>

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值