Home > Web Front-end > JS Tutorial > body text

WeChat applet request request background interface php code example

小云云
Release: 2018-02-05 11:08:45
Original
2559 people have browsed it

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]);
}
Copy after login

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);
     },

    })
 },
Copy after login

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>
Copy after login
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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template