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

创建新的小程序,进出码,体温上报功能迁移基本完成

This commit is contained in:
2023-03-17 04:55:02 +08:00
parent 5b98be9bf9
commit b7bf3bfc15
88 changed files with 4337 additions and 276 deletions

View File

@@ -0,0 +1,111 @@
// pages/index/index.js
const menuItemDict = require('../../utils/menuList.js')
const getUserGroupByRole = require('../../utils/getUserGroupByRole.js')
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
debugText: "调试",
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log("index/index onLoad", options)
// console.log("wx.getLaunchOptionsSync()", wx.getLaunchOptionsSync())
this.setData({
debugText: JSON.stringify(options, null, 4),
})
console.log("menuItemDict", menuItemDict)
this.userInfo = wx.getStorageSync("userInfo")
this.displayUsername = this.userInfo?.username ?? "请登录"
if (!this.userInfo) {
console.log("用户未登录")
wx.redirectTo({
url: '/pages/index/login'
})
} else {
// 用户已登录
this.userGroup = getUserGroupByRole(this.userInfo.role)
this.debugObject = {
userGroup: this.userGroup
}
//判断用户是否是通过扫小程序码进来的
if (options.scene) {
// 扫门禁的小程序码
if (options.scene.split('%')[0] == "guard") {
options.scene = null
wx.navigateTo({
url: "/pages/scan/entrance"
})
}
}
}
// 开发模式下自动跳转到指定页面,节省开发时间
console.log("app.globalData", app.globalData)
if (app.globalData.debugMode) {
wx.switchTab({
url: '/pages/residents/report'
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
console.log("index/index onReady")
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
console.log("index/index onShow")
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
console.log("index/index onHide")
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
console.log("index/index onUnload")
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
console.log("index/index onPullDownRefresh")
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
console.log("index/index onReachBottom")
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
console.log("index/index onShareAppMessage")
}
})

View File

@@ -0,0 +1,5 @@
{
"usingComponents": {},
"navigationBarTitleText": "首页",
"navigationStyle": "custom"
}

View File

@@ -0,0 +1,21 @@
<!--pages/index/index.wxml-->
<view>
<image src="../../image/home.jpg" style="width: 100vw; height: 41.5vw;"></image>
<view style="display: block; padding-left: 30px; padding-top: 12px;">
<text>欢迎你,{{ displayUsername }}</text>
</view>
<view>
<text>调试信息:{{ debugText }}</text>
</view>
<view id="menu-view">
<view class="menu-item" v-for="menuItem in filterMenuItems" :key="menuItem.id">
<view :class="{ 'add-dot': menuItem.addDot }" style="display: inline-block;">
<image :src="'../../image/icon/' + menuItem.image" class="item-image" bindtap='switchTo(menuItem.switchFunc, menuItem.url)'></image>
</view>
<view>{{ menuItem.title }}</view>
</view>
</view>
<button type="primary" size="mini" bindtap="toggleDot('code', true)">显示小红点</button>
<button type="primary" size="mini" bindtap="toggleDot('code', false)">隐藏小红点</button>
<button type="warn" size="mini" bindtap="magicButton">魔法按钮</button>
</view>

View File

@@ -0,0 +1 @@
/* pages/index/index.wxss */

View File

@@ -0,0 +1,129 @@
// pages/index/login.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
username: '',
password: '',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
bindKeyInput: function (e) {
// console.log('e', e)
let newData = {}
newData[e.target.id] = e.detail.value
this.setData(newData)
},
login() {
console.log("login userInput", this.data.username, this.data.password)
if (!this.data.username || !this.data.password) {
wx.showToast({
title: "请完善登录信息",
icon: 'error',
duration: 2000
})
} else {
wx.showLoading({
title: '加载中'
})
wx.request({
url: `${app.globalData.baseUrl}/user/login`,
method: "POST",
header: {
"Content-Type": "application/x-www-form-urlencoded" //用于post
},
data: {
username: this.data.username,
password: this.data.password,
},
success: function (d) {
wx.hideLoading()
let result = d.data;
if (result.success) {
// 登录成功
wx.setStorageSync("userInfo", result.data.userInfo);
console.log("userInfo", wx.getStorageSync("userInfo"))
wx.switchTab({
url: '/pages/index/index'
})
} else {
wx.showToast({
title: result.msg,
icon: 'error',
duration: 2000
})
}
},
fail: function () {
wx.hideLoading()
wx.showToast({
title: "请求失败",
icon: 'error',
duration: 2000
})
}
})
}
}
})

View File

@@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "登录"
}

View File

@@ -0,0 +1,19 @@
<!--pages/index/login.wxml-->
<view class="container">
<view class="login-icon">
<image class="login-img" src="../../image/icon/login-background.svg"></image>
</view>
<view class="login-from">
<view class="inputView">
<!--账号-->
<input class="inputText" placeholder="账号" id="username" bindinput="bindKeyInput" />
<!--密码-->
<input class="inputText" placeholder="密码" id="password" bindinput="bindKeyInput" password="true" />
</view>
<view class="loginBtnView">
<!--按钮-->
<button class="loginBtn" type="primary" bindtap="login">登录</button>
<button class="loginBtn" type="secondary" bindtap="visitor">访客申请</button>
</view>
</view>
</view>

View File

@@ -0,0 +1,31 @@
/* pages/index/login.wxss */
.container {
line-height: 1.5em;
padding: 30px 0;
}
.login-icon {
text-align: center;
height: 35vh;
}
.login-img {
width: 50vw;
}
.login-from {
padding: 0 20vw;
}
.inputText {
width: 95%;
border-bottom: solid 1px;
margin-bottom: 50px;
}
.loginBtnView {
margin-top: 70px;
}
.loginBtn {
margin-bottom: 25px;
}

View File

@@ -0,0 +1,48 @@
// index.js
// 获取应用实例
const app = getApp()
Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
canIUseGetUserProfile: false,
canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false
},
// 事件处理函数
bindViewTap() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad() {
if (wx.getUserProfile) {
this.setData({
canIUseGetUserProfile: true
})
}
},
getUserProfile(e) {
// 推荐使用wx.getUserProfile获取用户信息开发者每次通过该接口获取用户个人信息均需用户确认开发者妥善保管用户快速填写的头像昵称避免重复弹窗
wx.getUserProfile({
desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
console.log(res)
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
},
getUserInfo(e) {
// 不推荐使用getUserInfo获取用户信息预计自2021年4月13日起getUserInfo将不再弹出弹窗并直接返回匿名的用户个人信息
console.log(e)
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})

View File

@@ -0,0 +1,3 @@
{
"usingComponents": {}
}

View File

@@ -0,0 +1,23 @@
<!--index.wxml-->
<view class="container">
<view class="userinfo">
<block wx:if="{{canIUseOpenData}}">
<view class="userinfo-avatar" bindtap="bindViewTap">
<open-data type="userAvatarUrl"></open-data>
</view>
<open-data type="userNickName"></open-data>
</block>
<block wx:elif="{{!hasUserInfo}}">
<button wx:if="{{canIUseGetUserProfile}}" bindtap="getUserProfile"> 获取头像昵称 </button>
<button wx:elif="{{canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
<view wx:else> 请使用1.4.4及以上版本基础库 </view>
</block>
<block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</block>
</view>
<view class="usermotto">
<text class="user-motto">{{motto}}</text>
</view>
</view>

View File

@@ -0,0 +1,19 @@
/**index.wxss**/
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
color: #aaa;
}
.userinfo-avatar {
overflow: hidden;
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
}
.usermotto {
margin-top: 200px;
}

View File

@@ -0,0 +1,18 @@
// logs.js
const util = require('../../utils/util.js')
Page({
data: {
logs: []
},
onLoad() {
this.setData({
logs: (wx.getStorageSync('logs') || []).map(log => {
return {
date: util.formatTime(new Date(log)),
timeStamp: log
}
})
})
}
})

View File

@@ -0,0 +1,4 @@
{
"navigationBarTitleText": "查看启动日志",
"usingComponents": {}
}

View File

@@ -0,0 +1,6 @@
<!--logs.wxml-->
<view class="container log-list">
<block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
<text class="log-item">{{index + 1}}. {{log.date}}</text>
</block>
</view>

View File

@@ -0,0 +1,8 @@
.log-list {
display: flex;
flex-direction: column;
padding: 40rpx;
}
.log-item {
margin: 10rpx;
}

View File

@@ -0,0 +1,66 @@
// pages/person/person.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

View File

@@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "我"
}

View File

@@ -0,0 +1,2 @@
<!--pages/person/person.wxml-->
<text>pages/person/person.wxml</text>

View File

@@ -0,0 +1 @@
/* pages/person/person.wxss */

View File

@@ -0,0 +1,215 @@
// pages/residents/code.js
import SparkMD5 from '../../utils/spark-md5.min'
import utils from '../../utils/util'
import drawQrcode from '../../utils/qrcode/index'
import scanQRCode from '../../utils/scanQRCode'
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
timeInterval: null,
isShow: 'none',
userText: '',
showText: '',
showTextColor: '',
time: '',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
console.log('onShow')
// setTimeout(this.refershData, 100)
this.refershData()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
console.log('onHide')
clearInterval(this.data.timeInterval);
this.setData({
isShow: 'none',
time: ''
})
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
console.log('onUnload')
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
console.log('onPullDownRefresh')
this.refershData(() => {
wx.stopPullDownRefresh();
});
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
refershData(callback) {
console.log('this.refershData()')
wx.showNavigationBarLoading();
clearInterval(this.data.timeInterval);
this.setData({
isShow: 'none',
time: '',
userInfo: wx.getStorageSync("userInfo"),
})
if (!this.data.userInfo) {
wx.redirectTo({
url: '/pages/index/login'
})
}
wx.showLoading({
title: '加载中'
})
var that = this;
wx.request({
url: `${app.globalData.baseUrl}/access/code/getCodeInfo`,
method: "POST",
header: {
"Content-Type": "application/x-www-form-urlencoded" //用于post
},
data: {
id: this.data.userInfo.id,
},
success: function (d) {
console.log("begin success")
wx.hideLoading()
let result = d.data;
if (result.success) {
console.log("result.data", result.data);
that.setData({
userText: `${that.data.userInfo.id} | ${that.data.userInfo.realname}`,
showText: result.data.infoText,
showTextColor: result.data.infoTextColor
})
let t = Date.now();
let chksum = SparkMD5.hash(JSON.stringify({
id: that.data.userInfo.id,
t: t
}));
console.log("chksum", chksum)
that.drawCode(`https://epp.cxyxiaomo.com/access/validCode?id=${that.data.userInfo.id}&t=${t}&chksum=${chksum}`, result.data.qrcodeColor)
} else {
wx.showToast({
title: result.msg,
icon: 'error',
duration: 2000
})
}
that.setData({
isShow: ''
})
console.log("end success")
},
fail: function () {
console.log("begin fail")
wx.hideLoading()
wx.showToast({
title: "请求失败",
icon: 'error',
duration: 2000
})
console.log("end fail")
},
complete: function () {
console.log("begin complete")
if (typeof (callback) === "function")
callback();
wx.hideNavigationBarLoading();
console.log("end complete")
}
})
},
drawCode(text = 'https://www.baidu.com/', foreground = 'red') {
console.log("drawCode was called.")
var that = this;
const query = wx.createSelectorQuery()
query.select('#myQrcode')
.fields({
node: true,
size: true
})
.exec(async (res) => {
console.log("before drawQrcode")
var canvas = res[0].node
if (!canvas) {
wx.showToast({
title: "canvas获取失败",
icon: 'error',
duration: 2000
})
return
}
console.log("canvas:", canvas, "res:", res)
// 调用方法drawQrcode生成二维码
await drawQrcode(wx, {
canvas: canvas,
canvasId: 'myQrcode',
width: 150,
padding: 0,
background: '#ffffff',
foreground: foreground,
text: text,
})
console.log("end drawQrcode")
this.updateTime();
this.setData({
timeInterval: setInterval(this.updateTime, 1000)
})
})
},
updateTime() {
this.setData({
time: utils.formatTime(new Date())
})
console.log("刷新时间")
},
scan() {
scanQRCode(wx)
}
})

View File

@@ -0,0 +1,5 @@
{
"usingComponents": {},
"navigationBarTitleText": "身份码",
"enablePullDownRefresh": true
}

View File

@@ -0,0 +1,10 @@
<!--pages/residents/code.wxml-->
<view id="codeView" :style="{ display: isShow }">
<view id="user-text"><text>{{ userText }}</text></view>
<view id="time-text"><text>{{ time }}</text></view>
<canvas type="2d" style="width: 250px; height: 250px;" id="myQrcode"></canvas>
<view id="show-text"><text style="color: {{ showTextColor }}">{{ showText }}</text></view>
<view id="small-text"><text>下拉可刷新</text></view>
<button id="scan-btn" size="mini" bindtap="scan">扫门禁码</button>
</view>

View File

@@ -0,0 +1,37 @@
/* pages/residents/code.wxss */
#codeView {
text-align: center;
margin-top: 50px;
}
#user-text {
font-size: 18px;
}
#time-text {
font-weight: bold;
font-size: 22px;
margin-top: 30px;
}
#myQrcode {
display: block;
margin: 30px auto;
}
#show-text {
font-weight: bold;
font-size: 25px;
}
#small-text {
margin-top: 30px;
color: grey;
font-size: small;
}
#scan-btn {
margin-top: 20px;
padding: 9px 60px;
font-size: initial;
}

View File

@@ -0,0 +1,291 @@
// pages/residents/report.js
import utils from '../../utils/util'
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
isSkipOnShowFunc: false, // 是否跳过 onShow
userInfo: null,
timeInterval: null,
formData: {
userId: '',
userRealname: '',
address: '',
time: '',
timestamp: '',
temperature: 0,
},
// 是否填报过
isFilled: true,
filledMsg: "",
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
if (this.data.isSkipOnShowFunc) {
this.setData({
isSkipOnShowFunc: false,
})
return
}
console.log('onShow')
let userInfo = wx.getStorageSync("userInfo")
console.log("userInfo", userInfo)
this.setData({
userInfo: userInfo,
"formData.userId": userInfo.id,
"formData.userRealname": userInfo.realname,
timeInterval: setInterval(this.updateTime, 1000)
})
console.log("formData", this.data.formData)
this.updateTime();
// 获取用户当日是否填报过
wx.showLoading({
title: '加载中'
})
var that = this;
wx.request({
url: `${app.globalData.baseUrl}/access/report/getLatestRecord`,
method: "POST",
header: {
"Content-Type": "application/x-www-form-urlencoded" //用于post
},
data: {
userId: this.data.userInfo.id
},
success: function (d) {
wx.hideLoading()
let result = d.data
console.log("result", result)
if (result.success) {
console.log("result.data", result.data);
if (result.data == null || new Date(result.data.time) < new Date(new Date().toISOString().substring(0, 10))) {
// 如果没有填报记录,或者填报记录不是今天,那么说明没有填报过
that.setData({
isFilled: false
})
} else {
// 有今日记录,说明已经填报过
that.setData({
isFilled: true,
filledMsg: "您已完成今日体温填报"
})
}
} else {
wx.showToast({
title: "加载填报信息失败",
icon: 'error',
duration: 2000
})
}
},
fail: function () {
wx.hideLoading()
wx.showToast({
title: "请求失败",
icon: 'error',
duration: 2000
})
},
complete: function () {
wx.hideNavigationBarLoading();
}
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
bindTemperatureChanged(e) {
this.setData({
"formData.temperature": e.detail.value
})
},
updateTime() {
let timestamp = Date.now()
this.setData({
"formData.timestamp": timestamp,
"formData.time": utils.formatTime(new Date(timestamp))
})
},
chooseLocation: async function () {
wx.showLoading({
title: '正在获取权限'
})
await new Promise((resolve) => {
wx.getSetting({
success(res) {
wx.hideLoading()
if (!res.authSetting['scope.userLocation']) {
wx.authorize({
scope: 'scope.userLocationBackground',
success() {
resolve();
}
})
} else {
resolve();
}
}
})
});
wx.showLoading({
title: '正在定位'
})
var that = this;
this.setData({
isSkipOnShowFunc: true, // 关闭位置选择器后,会触发 onShow这里避免掉
})
wx.chooseLocation({
success: function (res) {
console.log("wx.chooseLocation success")
that.setData({
"formData.address": res.address
})
},
fail: function () {
console.log("wx.chooseLocation fail", that.data.formData)
if (!that.data.formData.address) {
wx.showToast({
title: "请获取当前位置",
icon: 'error'
})
}
},
})
wx.hideLoading()
},
// 体温上报 提交按钮
report() {
console.log("点击提交", "this.data.formData", this.data.formData)
if (!this.data.formData.address) {
wx.showToast({
title: "请获取当前位置",
icon: 'error'
})
return;
}
wx.showLoading({
title: '加载中'
})
var that = this;
wx.request({
url: `${app.globalData.baseUrl}/access/report/submit`,
method: "POST",
header: {
"Content-Type": "application/x-www-form-urlencoded" //用于post
},
data: {
...this.data.formData,
},
success: function (d) {
console.log("begin success")
wx.hideLoading()
let result = d.data;
if (result.success) {
// 填报完成
that.setData({
isFilled: true,
filledMsg: "您已完成今日体温填报"
})
console.log("result.data", result.data);
wx.showToast({
title: "填报成功",
icon: 'success',
duration: 2000
})
} else {
wx.showToast({
title: result.msg || "出错啦",
icon: 'error',
duration: 2000
})
}
that.isShow = ''
console.log("end success")
},
fail: function () {
console.log("begin fail")
wx.hideLoading()
wx.showToast({
title: "请求失败",
icon: 'error',
duration: 2000
})
console.log("end fail")
},
complete: function () {
console.log("begin complete")
if (typeof (callback) === "function")
callback();
wx.hideNavigationBarLoading();
console.log("end complete")
}
})
},
// 历史填报
myreport() {
wx.navigateTo({
url: "/pages/residents/reportHistory"
})
}
})

View File

@@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "体温上报"
}

View File

@@ -0,0 +1,59 @@
<!--pages/residents/report.wxml-->
<view>
<view wx:if="{{ !isFilled }}" class="form">
<view class="row">
<view class="rowItem rowLeft center">
<text>姓名</text>
</view>
<view class="rowItem rowRight center">
<input class="rowRightElement" value="{{ formData.userRealname }}" disabled="true" />
</view>
</view>
<view class="row">
<view class="rowItem rowLeft center">
<text>填报时间</text>
</view>
<view class="rowItem rowRight center">
<input class="rowRightElement" value="{{ formData.time }}" disabled="true" />
</view>
</view>
<view class="row">
<view class="rowItem rowLeft center">
<text>地址</text>
</view>
<view class="rowItem rowRight center" bindtap="chooseLocation">
<input class="rowRightElement" placeholder="点击获取当前位置" value="{{ formData.address }}" disabled="true" maxlength="500" />
</view>
</view>
<view class="row">
<view class="rowItem rowLeft center">
<text>今日体温</text>
</view>
<view class="rowItem rowRight center">
<radio-group class="rowRightElement" bindchange="bindTemperatureChanged">
<radio value="0" checked="true" />正常
<radio value="1" />异常(≥37.3°)
</radio-group>
</view>
</view>
<view class="tips-area">
<view class="tips" style="color: red;">
* 本人承诺以上所填报的内容全部真实,并愿意承担相应责任。
</view>
</view>
<view style="text-align: center;">
<button class="controlBtn" size="mini" type="none" bindtap="myreport">历史填报</button>
<button class="controlBtn" size="mini" type="primary" bindtap="report">提交</button>
</view>
</view>
<view wx:else style="text-align: center;">
<!-- -->
<view style="margin: 40px 0;">{{ filledMsg }}</view>
<button class="controlBtn" size="mini" type="none" bindtap="myreport">历史填报</button>
</view>
</view>

View File

@@ -0,0 +1,39 @@
/* pages/residents/report.wxss */
.form {
padding: 20px 30px;
}
.row {
margin: 30px 0;
border-bottom: 2px solid grey;
}
.rowItem {
margin: 0;
padding: 0;
display: inline-block;
vertical-align: middle;
height: 1.6rem;
}
.rowLeft {
width: 30%;
}
.rowRight {
width: 70%;
}
.rowRightElement {
width: 100%;
}
.center {
text-align: center;
}
.controlBtn {
width: 250px;
margin: 0 30px;
}

View File

@@ -0,0 +1,125 @@
// pages/residents/reportHistory.js
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
userInfo: null,
displayName: '',
displayResult: [],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
console.log('onShow')
let userInfo = wx.getStorageSync("userInfo")
this.setData({
userInfo: userInfo,
displayName: userInfo.realname
})
// 获取用户填报历史
wx.showLoading({
title: '加载中'
})
var that = this;
wx.request({
url: `${app.globalData.baseUrl}/access/report/getRecordList`,
method: "POST",
header: {
"Content-Type": "application/x-www-form-urlencoded" //用于post
},
data: {
userId: this.data.userInfo.id
},
success: function (d) {
wx.hideLoading()
let result = d.data
console.log("result", result)
if (result.success) {
console.log("result.data", result.data)
that.setData({
displayResult: result.data.map(item => {
// 时间友好化显示
let t = new Date(item.time).getTime() + 8 * 3600 * 1000
item.time = new Date(t).toISOString().substring(0, 19).replace("T", " ")
return item
})
})
} else {
wx.showToast({
title: "加载填报信息失败",
icon: 'error',
duration: 2000
})
}
},
fail: function () {
wx.hideLoading()
wx.showToast({
title: "请求失败",
icon: 'error',
duration: 2000
})
},
complete: function () {
wx.hideNavigationBarLoading();
}
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

View File

@@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "体温上报 - 历史记录"
}

View File

@@ -0,0 +1,21 @@
<!--pages/residents/reportHistory.wxml-->
<view>
<view style="margin: 20px; text-align: center;">
<text>姓名:{{ displayName }}</text>
</view>
<view class="container">
<view class="item {{ item.temperature == 1 ? 'abnormal' : 'normal' }}" wx:for="{{displayResult}}" wx:for-item="item">
<view>
<view class="record_time">
<!-- 填报时间: -->
{{ item.time }}
</view>
<view class="record_address">
<!-- 地址: -->
{{ item.address }}
</view>
</view>
<view class="statusText">{{ item.temperature == 1 ? "异常" : "正常" }}</view>
</view>
</view>
</view>

View File

@@ -0,0 +1,33 @@
/* pages/residents/reportHistory.wxss */
.item {
/* background-color: #dedede; */
border-radius: 8px;
margin: 12px 20px;
padding: 18px;
display: grid;
grid-template-columns: 1fr auto;
place-items: center;
color: white;
}
.item.normal {
background-color: green;
}
.item.abnormal {
background-color: red;
}
.record_time {
font-size: 17px;
}
.record_address {
font-size: 15px;
}
.statusText {
font-size: large;
font-weight: bold;
padding: 0 20px;
}

View File

@@ -0,0 +1,66 @@
// pages/scan/entrance.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

View File

@@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "进入社区"
}

View File

@@ -0,0 +1,4 @@
<!--pages/scan/entrance.wxml-->
<view>
您将要进入社区
</view>

View File

@@ -0,0 +1 @@
/* pages/scan/entrance.wxss */