小程序配置request请求

/* 小程序配置文件*/

var host = "http://192.168.102.117:8080/sg/xcx/";

function allrequest(url, data, resp) {
  wx.request({
    url: host + config[url],
    data: data,
    header: {
      'content-type': 'application/x-www-form-urlencoded'
    },
    method: 'POST',
    success: res => {
      if (res.data.success == 0) {
        wx.showToast({
          title: res.data.errorMsg,
          icon: 'none',
          duration: 1000
        })
      } else {
        resp(res)
      }
    }
  })
}

var config = {

  host,

  // 登录
  login: 'member/login.action',

};

module.exports = {
  allrequest
}
var config = require('../../config.js');
var app = getApp();

// 调用请求
config.allrequest('updateCancelAppoint', {
    access_code: app.globalData.access_code
}, (res) => {

})

 

你可能感兴趣的:(微信小程序)