Home  >  Article  >  Web Front-end  >  WeChat applet request request background interface php code example

WeChat applet request request background interface php code example

小云云
小云云Original
2018-02-05 11:08:452560browse

This article mainly introduces to you the relevant information about the detailed example of the WeChat applet request request backend interface PHP. I hope this article can help you. Friends in need can refer to it. I hope it can help you.

WeChat applet request request backend interface php example detailed explanation

Backend php interface: http://www.vueyun.com/good/info

No data is processed, it is returned directly, and the specific processing will be based on the return format


public function getGoodInfo(Request $request)
{
    $goods_datas = $this->Resource->get();

    return response()->json(['status' => 'success','code' => 200,'message' => '获取成功','data'=>$goods_datas]);
}

onLoad
# in the applet index.js file


##

 onLoad: function () {
  console.log('onLoad')
    wx.request({
    //上线接口地址要是https测试可以使用http接口方式
     url: 'http://www.vueyun.com/good/info',
     data: {},
     method: 'GET',
     header: {
      'content-type': 'application/json'
     },
     success: function (res) {
      that.setData({ goodslist: res.data.data });
      console.log(res.data.data, 1111111);
     },

    })
 },

wxml file,


 <view class="goods-container">

     <block wx:for="{{goodslist}}" wx:for-item="item" wx:for-index="idx" >
     <view class="goods-box" bindtap="goodsTap" data-id="{{item.id}}">
      <view class="img-box">
       <image src="{{item.img_url}}" class="image"/>
      </view>
      <view class="goods-title">{{item.img_title}}</view>
      <view class="goods-price">¥ {{item.good_price}}</view>
    </view>
    </block>
  </view>

Related recommendations:

WeChat applet call Introduction to the methods of the backend interface

Writing the backend interface in PHP

Some problems with the PHP backend interface

The above is the detailed content of WeChat applet request request background interface php code example. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn