1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

210 lines
4.2 KiB
JavaScript
Raw Normal View History

const app = getApp()
const baseUrl = app.globalData.baseUrl
// console.log("baseUrl", baseUrl)
2022-11-05 15:28:03 +08:00
var util = require('../../utils/util')
Page({
/**
* 页面的初始数据
*/
data: {
id: '',
2022-11-05 15:28:03 +08:00
address: '',
time: '',
radio1: [{
value: '正常',
checked: 'true'
}, {
value: '发热'
}],
radio2: [{
value: '无需隔离',
checked: 'true'
}, {
value: '居家隔离'
}, {
value: '集中隔离'
}, {
value: '入院隔离'
}],
normal: '正常',
isolation: '无需隔离',
2022-11-05 15:28:03 +08:00
name: '',
stuId: '',
yes_noon_temp: 36.2,
yes_night_temp: 36.4,
today_morning_temp: 36.2
2022-11-05 15:28:03 +08:00
},
radioChange1: function (e) {
2022-11-05 15:28:03 +08:00
this.setData({
normal: e.detail.value
2022-11-05 15:28:03 +08:00
})
},
radioChange2: function (e) {
2022-11-05 15:28:03 +08:00
this.setData({
isolation: e.detail.value
2022-11-05 15:28:03 +08:00
})
},
2022-11-05 15:28:03 +08:00
chooseLocation: function () {
var that = this;
wx.getSetting({
success(res) {
if (!res.authSetting['scope.userLocation']) {
wx.authorize({
scope: 'scope.userLocationBackground',
success() {
2022-11-05 15:28:03 +08:00
that.location();
}
})
} else {
that.location();
}
}
})
},
location: function () {
2022-11-05 15:28:03 +08:00
var that = this;
wx.chooseLocation({
success: function (res) {
that.setData({
'address': res.address,
})
},
fail: function () {
wx.showToast({
title: "请获取当前位置",
icon: 'error'
})
},
})
},
myreport: function () {
2022-11-05 15:28:03 +08:00
wx.navigateTo({
url: './myreport'
})
},
report: function () {
var that = this
if (this.data.address == '') {
2022-11-05 15:28:03 +08:00
wx.showToast({
title: '请先选择地址',
icon: 'none',
duration: 2000
})
} else {
2022-11-05 15:28:03 +08:00
wx.request({
url: `${baseUrl}/report/doReport`,
2022-11-05 15:28:03 +08:00
data: {
user_id: this.data.id,
name: this.data.name,
2022-11-05 15:28:03 +08:00
address: this.data.address,
time: this.data.time,
normal: this.data.normal,
yes_noon_temp: this.data.yes_noon_temp,
yes_night_temp: this.data.yes_night_temp,
today_morning_temp: this.data.today_morning_temp,
isolation: this.data.isolation
2022-11-05 15:28:03 +08:00
},
success: function (d) {
2022-11-05 15:28:03 +08:00
if (d.data == "填报成功") {
wx.showToast({
title: d.data,
icon: 'success',
success: function () {
if (that.data.normal != "发热" && that.data.isolation == "无需隔离") {
wx.setStorageSync("state", that.formatDate(new Date()))
} else {
wx.setStorageSync("state", "1999-01-01")
2022-11-05 15:28:03 +08:00
}
2022-11-05 15:28:03 +08:00
}
})
} else {
wx.showToast({
title: d.data,
icon: 'error',
duration: 2000
})
}
}
})
}
},
formatDate: function (date) {
2022-11-05 15:28:03 +08:00
let year = date.getFullYear()
let month = date.getMonth() + 1
month = month.toString()
month[1] ? month = month : month = '0' + month
2022-11-05 15:28:03 +08:00
let day = date.getDate()
day = day.toString()
day[1] ? day = day : day = '0' + day
return year + "-" + month + "-" + day
},
2022-11-05 15:28:03 +08:00
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
var TIME = util.formatTime(new Date());
this.setData({
time: TIME,
name: wx.getStorageSync('name'),
stuId: wx.getStorageSync('stuId'),
id: wx.getStorageSync('id')
2022-11-05 15:28:03 +08:00
});
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})