我的想法是通过js直接调用C#的接口,然后传值,把接口当一个中转站,把值传过去。
我现在修改了写法,这样提示错误了,是什么原因呢?
wx.request({
url: 'http://localhost:200/WebService.asmx?op=InpUser',
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
data: {
Name: this.data.MyName,
Phone: this.data.MyPhone,
LFY: this.data.MyLFY,
Email: this.data.MyEmail
},
success: function (res) {
if (res.data.err == 0) {
wx.showToast({
title: '保存成功',
success: res => {
setTimeout(function () {
wx.switchTab({
url: '/pages/TextInput/TextInput',
})
}, 2000);
}
})
} else {
that.setData({
msg: res.data.errtxt
})
}
}
错误提示
POST http://localhost:200/WebService.asmx?op=InpUser 500 (Internal Server Error)
v @ VM1687 asdebug.js:1
createRequestTask @ VM1687 asdebug.js:1
n @ VM1687 asdebug.js:1
invoke @ VM1689 WAService.js:2
l @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
y @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
rc @ VM1689 WAService.js:2
a @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
n @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
p.<computed> @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
loginBtnClick @ test.js? [sm]:36
r.safeCallback @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
c @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
r @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
(anonymous) @ VM1689 WAService.js:2
n @ VM1687 asdebug.js:1
(anonymous) @ VM1687 asdebug.js:1
(anonymous) @ VM1687 asdebug.js:1
_ws.onmessage @ VM1687 asdebug.js:1
VM1683:1 thirdScriptError
that is not defined;at api request success callback function
ReferenceError: that is not defined
at success (http://127.0.0.1:25869/appservice/pages/test/test.js:62:13)
at Object.o.<computed> (http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:1431866)
at http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:589634
at Module.c (http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:1591990)
at Function.<anonymous> (http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:589609)
at http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:127365
at E (http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:541004)
at i.<anonymous> (http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:920298)
at i.emit (http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:599114)
at ic (http://127.0.0.1:25869/appservice/__dev__/WAService.js:2:921160)