首頁  >  文章  >  微信小程式  >  微信小程式request請求後台介面php的介紹

微信小程式request請求後台介面php的介紹

不言
不言原創
2018-06-27 10:26:592439瀏覽

這篇文章主要介紹了微信小程式request請求後台介面php的實例詳解的相關資料,希望透過本文能幫助到大家,需要的朋友可以參考下

微信小程序request請求後台介面php的實例詳解

後台php介面:http://www.vueyun.com/good/info

##沒有處理數據,直接回傳了,具體再根據返回格式處理

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

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

小程式index.js檔案中onLoad


 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文件,

 <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>

以上就是本文的全部內容,希望對大家的學習有所幫助,更多相關內容請關注PHP中文網!

相關推薦: 

後台https網域綁定和免費的https憑證申請的介紹

微信小程式觸控事件的介紹

微信小程式的GET請求的介紹

##

以上是微信小程式request請求後台介面php的介紹的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn