tijian_tieying/web/德城公账号小程序/pages/inquiry/inquiry.js

85 lines
2.5 KiB
JavaScript
Raw Permalink Normal View History

2025-02-20 12:14:39 +08:00
Page({
data: {
name:"",
listData: ""
},
onLoad: function (options) {
var that = this;
var username = options.name;
that.setData({
name: username
})
wx.request({
url: 'https://oa.dcqcdc.com/dccdc/Infection/GetAllHangIntheAirQuestion_OpenUserInfo',//请求地址
//url: 'https://oa.dcqcdc.com/InfectionWX/GetAllHangIntheAirQuestion'
data: {
username: username
},
header: {//请求头
"Content-Type": "application/x-www-form-urlencoded"
},
method: "POST",//get为默认方法/POST
success: function (res) {
console.log(res.data);//res.data相当于ajax里面的data,为后台返回的数据
console.log(that.data)
that.setData({
listData: res.data
})
},
fail: function (err) { console.log(err) },//请求失败
complete: function () { }//请求完成后执行的函数
})
},
jump: function (e) {
var that = this;
console.log(e)
var id = e.currentTarget.id;
var username = e.currentTarget.dataset.username;
console.log(username)
wx.navigateTo({
url: '../inquiryList/inquiryList?id=' + id + "&name=" + that.data.name + "&username=" + username,
success: function (res) {
},
fail: function (res) {
},
complete: function (res) {
},
})
},
formSubmit: function (e) {//定义函数名称
var that = this; // 这个地方非常重要重置data{}里数据时候setData方法的this应为以及函数的this, 如果在下方的sucess直接写this就变成了wx.request()的this了
var username = e.detail.value.username;
var userunit = e.detail.value.unit;
var userphone = e.detail.value.phone;
wx.request({
url: 'https://oa.dcqcdc.com/dccdc/Infection/GetDataListNameUnitPhone_OpenUserInfo',//请求地址
//url: 'https://oa.dcqcdc.com/InfectionWX/GetAllHangIntheAirQuestion'
data: {//发送给后台的数据
"name":username,
"unit":userunit,
"phone":userphone
},
header: {//请求头
"Content-Type": "application/x-www-form-urlencoded"
},
method: "POST",//get为默认方法/POST
success: function (res) {
console.log(res.data)
that.setData({
listData: res.data
})
},
fail: function (err) { console.log(err) },//请求失败
complete: function () { }//请求完成后执行的函数
})
}
})