Here is a simple example to illustrate the WeChat appletInterfaceCall:
First look at the effect:
This is the true appearance of the mini program, and the experience is somewhat similar to the native APP.
{ "navigationBarBackgroundColor": "#ffffff", "navigationBarTextStyle": "black", "navigationBarTitleText": "萌店商品详情", "backgroundColor": "#eeeeee", "backgroundTextStyle": "light"}
wx.request({ url: 'http://m.vd.cn/api/tuan/TuanGuide_api', //仅为示例,并非真实的接口地址 data: { code:"oneyuan" }, method: "POST", header: { "Content-Type": "application/x-www-form-urlencoded" //post }, complete: function( res ) { that.setData( { oneyuandata: res.data.data }); if( res == null || res.data == null ) { reject(new Error('网络请求失败')) } }, success: function(res) { if(res.data.code ==0){ resolve(res) } } })
Here is a brief explanation of JS, WCSS and WXML code Not offered!
url:这个是要请求的接口地址 data:一个入参 method:请求方式,如果是POST请求必须按上面写,默认是get请求,不用处理。 complete:页面请求完成后的方法,通过that.setData将数据传递给WXML页面。 success:页面加载成功后的执行方法。Copy after login[Related recommendations]
1. How to add a custom menu through http request?
2. Red envelope interface development example code for small program
3. Simple example code for small program development
The above is the detailed content of Share example tutorials on mini program development and calling interfaces. For more information, please follow other related articles on the PHP Chinese website!