这篇文章主要介绍了微信小程序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的介绍的详细内容,更多请关注知企PROSAAS其它相关文章!
文章链接:https://www.prosaas.cn/17313.html
更新时间:2018年06月27日
声明: 本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:973664285@qq.com我们将第一时间处理! 资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。 所有资源仅限于参考和学习,版权归原作者所有,更多请阅读知企PROSAAS协议
