wx.request({            url: 'https://api.changching.cn/api/v4/sermanstars/',            method: 'POST',            header: {              'Accept': "*/*",              'Authorization': 'Token ' + userInfo.thirdkey + ',userid=' + userInfo.id,            },            data: {              userid: userInfo.id,              sermanid: that.data.sermenid,              star: score,            },            success: function (res) {              that.setData({                userStars: that.data.userStars,                yourstars: "已评价",                ifhidden1: true,                ifhidden2: false,              })              wx.redirectTo({                url: '/pages/cleanerexample/cleanerexample?id=' + that.data.sermenid,              })              wx.showToast({                title: '您已成功评价',                icon: 'success',                duration: 2000              })            },            fail: function (res) {              console.log('对接失败');            },            complete: function (res) {              console.log('对接完成');            }          })  

url:这个是要请求的接口地址

   

data:一个入参,如果是get方法从服务器取数据data可以为空,如果是其他(post,put),则需要写参数列表。

   

method:请求方式,如果是POST请求必须按上面写,默认是get请求,不用处理。

   

complete:页面请求完成后的方法,通过that.setData将数据传递给WXML页面。

   

success:页面加载成功后的执行方法。

TAG标签: 小程序小程序接口是什么

http://www.xiaochengxub.com/read-101717.html