小程序request请求服务器api方法

35 阅读1分钟

addFriends: function (e) {

console.log(e)

var that = this;

wx.request({

url: 'http://192.168.0.108:8092/user/registerSDKByXcx', //url

method: 'GET', //请求方式

header: {

'Content-Type': 'application/json',

},

data: {

telephone: '',

areaCode: '',

inviteCode: '',

type: 2, //参数

nickname: this.data.userInfo.nickName,

loginInfo: this.data.userOpenId,

fromAddType: 2,

userType:1,

openid: this.data.userOpenId,

toUserId: this.data.toUserId,

 

},

success: function (res) {

if (res.data.resultCode == 1) {

// _this.setData({

// phone: res.data.user.phone,

// password: res.data.user.password

// })

wx.showModal({

title: '提示',

content: '添加成功',

success: function (res) {

if (res.confirm) {

console.log('确定')

} else if (res.cancel) {

console.log('取消')

}

}

})

that.setData({

addFriends: false,

showAppButtom: true,

showAppMsg: false

})

}else{

wx.showModal({

title: '提示',

content: '系统繁忙,请稍后重试',

success: function (res) {

if (res.confirm) {

console.log('确定')

} else if (res.cancel) {

console.log('取消')

}

}

})

}

},

fail: function () {

app.consoleLog("请求数据失败,请稍后重试");

},

complete: function () {

// complete

}

})

},