submit_bin: function(){ console.log("helelo,userName:" + this.data.username + "\npassword" + this.data.password) var that = this; wx.request({ url: 'http://localhost:8080/login', method:'POST', header:{'content-type':'application/x-www-form-urlencoded'}, data:{ 'userName':that.data.username, 'userPwd':that.data.password }, success:function(res){ console.log("回调函数:"+ res.data) var ResData = res.data; if(ResData==ture){ wx.showToast({ title: 'success', duration: 2000 }) } } }) }
时间: 2024-04-21 09:25:41 浏览: 244
这段代码是 JavaScript 语言编写的一个函数,函数名为 submit_bin。该函数通过调用 wx.request 方法向指定的 URL 发送 HTTP POST 请求,请求的数据为用户名和密码。请求头中设置了 content-type 为 application/x-www-form-urlencoded。当请求成功后,会打印出回调函数中返回的数据,并且如果 ResData 的值为 true,则会弹出一个成功提示框。
相关问题
input_usr: function(e) { this.setData({ username: e.detail.value }) }, // 获取密码 input_pswd: function(e) { this.setData({ password: e.detail.value }) }, submit_btn: function(){ console.log("helelo,userName:" + this.data.username + "\npassword" + this.data.password) var that = this; wx.request({ url: 'http://localhost:8080/login', method:'POST', header:{'content-type':'application/x-www-form-urlencoded'}, data:{ 'userName':that.data.username, 'userPwd':that.data.password }, success:function(res){ console.log("回调函数:"+ res.data) var ResData = res.data; if(ResData==ture){ wx.showToast({ title: 'success', duration: 2000 }) wx.navigateTo({ url: '/pages/index/index', }) }
Sorry, but that is not a question. It seems to be a code snippet for a login function in a web or mobile application. Can you please provide a question for me to answer?
阅读全文