微信小程序之前后台数据交互

前台wx.request到一个网址


var app = getApp()
Page({
  data:{
    recode : '',
  },
  onLoad:function(options){
    var that = this
    var openId = app.globalData.openId
    wx.request({
      url: 'http://qq.cc/Wechat_applet/Collection/pay_status',
      data: {
        'openId' : '111',
        'status' : '0'
      },
      //method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      //header: {'content-type': 'application/json'},
      success: function(res){
        
        var msga = res.data.msg
        console.log(res)
         console.log(msga)
        that.setData({
              recode : msga
        })
      },
      fail: function() {
        // fail
      },
      complete: function() {
        // complete
      }
    })
  },
})
默认是get请求
后台处理程序
 public function pay_status(){
        $table = M('aa');
        $post = I('REQUEST.');
        $items = $table->where("openId = '".$post['openId']."' and pay_status= '".$post['status']."'")->select();
        $data['msg'] = $items;
        $this->ajaxReturn($data);

    }
用微信wxml的wx:for 循环的数据的格式必须是
Page({
  data: {
    array: [{
      message: 'foo',
    }, {
      message: 'bar'
    }]
  }
})
 


评论 抢沙发

表情