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

add miniprogram

This commit is contained in:
2022-11-05 15:28:03 +08:00
parent a410d97efd
commit 470d332fc2
155 changed files with 5371 additions and 0 deletions

View File

@@ -0,0 +1,90 @@
var QR = require("../../../lib/qrcode.js");
Page({
/**
* 页面的初始数据
*/
data: {
canvasHidden: false,
imagePath: '',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
//option为上个页面传递过来的参数
var jiaoyanCode = 'sorry,jiaoyanCode is loss';
// if (options) {
// jiaoyanCode = options.jiaoyanCode;
// }
console.log(jiaoyanCode);
var size = this.setCanvasSize(); //动态设置画布大小
this.createQrCode(jiaoyanCode, "mycanvas", size.w, size.h);
},
//适配不同屏幕大小的canvas
setCanvasSize: function() {
var size = {};
try {
var res = wx.getSystemInfoSync();
var scale = 750 / 686; //不同屏幕下canvas的适配比例设计稿是750宽 686是因为样式wxss文件中设置的大小
var width = res.windowWidth / scale;
var height = width; //canvas画布为正方形
size.w = width;
size.h = height;
} catch (e) {
// Do something when catch error
console.log("获取设备信息失败" + e);
}
return size;
},
/**
* 绘制二维码图片
*/
createQrCode: function(url, canvasId, cavW, cavH) {
//调用插件中的draw方法绘制二维码图片
QR.api.draw(url, canvasId, cavW, cavH);
setTimeout(() => {
this.canvasToTempImage(canvasId);
}, 1000);
},
/**
* 获取临时缓存照片路径存入data中
*/
canvasToTempImage: function() {
var that = this;
//把当前画布指定区域的内容导出生成指定大小的图片,并返回文件路径。
wx.canvasToTempFilePath({
canvasId: 'mycanvas',
success: function(res) {
var tempFilePath = res.tempFilePath;
console.log(tempFilePath);
that.setData({
imagePath: tempFilePath,
// canvasHidden:true
});
},
fail: function(res) {
console.log(res);
}
});
},
/**
* 点击图片进行预览
*/
previewImg: function (e) {
var img = this.data.imagePath;
console.log(img);
wx.previewImage({
current: img, // 当前显示图片的http链接
urls: [img] // 需要预览的图片http链接列表
});
},
})

View File

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

View File

@@ -0,0 +1,9 @@
<view class='container'>
<image bindtap="previewImg" mode="scaleToFill" src="{{imagePath}}"></image>
</view>
<!-- 画布,用来画二维码,只用来站位,不用来显示-->
<view class="canvas-box">
<canvas hidden="{{canvasHidden}}" style="width: 686rpx;height: 686rpx;background:#f1f1f1;" canvas-id="mycanvas" />
</view>

View File

@@ -0,0 +1,20 @@
.container {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
}
.container image {
width: 686rpx;
height: 686rpx;
background-color: #f9f9f9;
}
.canvas-box {
position: fixed;
top: 999999rpx;
left: 0;
}

View File

@@ -0,0 +1,159 @@
// pages/home/home.js
Page({
/**
* 页面的初始数据
*/
data: {
isManager:false,
isStudent:false,
notice:''
},
goWebPage: function (event) {
wx.navigateTo({
url: '../webPage/'+event.target.dataset.web,
})
},
toRedList: function (event) {
wx.navigateTo({
url: '../other/redList'
})
},
goCode:function() {
wx.navigateTo({
url: '../other/redList2'
})
},
goCount: function () {
wx.navigateTo({
url: '../person/count'
})
},
goNotice:function () {
wx.navigateTo({
url: '../notice/notice'
})
},
goVisitor:function () {
wx.navigateTo({
url: '../visitor/visitorReplay'
})
},
goFeedback: function () {
wx.navigateTo({
url: '../other/feedback'
})
},
goFeedbackReplay: function () {
wx.navigateTo({
url: '../other/feedbackReplay'
})
},
goApply: function () {
wx.navigateTo({
url: '../apply/myapply'
})
},
goApplyReplay: function () {
wx.navigateTo({
url: '../apply/applyReplay'
})
},
goUpdPwd: function () {
wx.navigateTo({
url: '../other/password'
})
},
goKf: function () {
wx.navigateTo({
url: '../person/issues'
})
},
goReport: function () {
wx.switchTab({
url: '../report/report'
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
if(!wx.getStorageSync("username")){
wx.navigateTo({
url: '../login/login'
})
}
if(wx.getStorageSync("role") == 2){
this.setData({
isManager: false,
isStudent: true,
})
}else if(wx.getStorageSync("role") == 1){
this.setData({
isManager: true,
isStudent: false,
})
}
var that = this;
wx.request({
url: 'http://127.0.0.1:8080/notice/noticeList',
data:{limit:3},
success: function (d) {
that.setData({
notice: d.data.data
})
}
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

View File

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

View File

@@ -0,0 +1,97 @@
<!--pages/home/home.wxml-->
<view style="background-color: #F6F6F6;height: 100%;">
<image src="../../img/home.jpg" style="width: 100%;height: 130px;"></image>
<view style="display: block;" wx:if="{{isManager}}">
<view style="display: flex;text-align: center;margin-top: 20px;">
<view style="width: 25%;">
<image src="../../icon/logo.png" style="width: 40px;height: 40px;" data-web="schoolWeb" bindtap='goWebPage'></image>
<view>学校官网</view>
</view>
<view style="width: 25%;">
<image src="../../icon/danger.png" style="width: 40px;height: 40px;" bindtap='goCode'></image>
<view>不健康人员</view>
</view>
<view style="width: 25%;">
<image src="../../icon/feedback.png" style="width: 40px;height: 40px;" bindtap='goFeedbackReplay'></image>
<view>反馈回复</view>
</view>
<view style="width: 25%;">
<image src="../../icon/apply.png" style="width: 40px;height: 40px;" bindtap='goApplyReplay'></image>
<view>申请审批</view>
</view>
</view>
<view style="display: flex;text-align: center;margin-top: 20px;">
<view style="width: 25%;">
<image src="../../icon/gg.png" style="width: 40px;height: 40px;" data-web="xgPage" bindtap='goNotice'></image>
<view>公告发布</view>
</view>
<view style="width: 25%;">
<image src="../../icon/visitor.png" style="width: 40px;height: 40px;" bindtap="goVisitor"></image>
<view>访客审批</view>
</view>
<view style="width: 25%;">
<image src="../../icon/count.png" style="width: 40px;height: 40px;" bindtap='goCount'></image>
<view>分配账号</view>
</view>
<view style="width: 25%;">
<image src="../../icon/_report.png" style="width: 40px;height: 40px;" bindtap='toRedList'></image>
<view>今日未填</view>
</view>
</view>
</view>
<view style="display: block;" wx:if="{{isStudent}}">
<view style="display: flex;text-align: center;margin-top: 20px;">
<view style="width: 25%;">
<image src="../../icon/logo.png" style="width: 40px;height: 40px;" data-web="schoolWeb" bindtap='goWebPage'></image>
<view>学校官网</view>
</view>
<view style="width: 25%;">
<image src="../../icon/code.png" style="width: 40px;height: 40px;" bindtap='goCode'></image>
<view>进校码</view>
</view>
<view style="width: 25%;">
<image src="../../icon/feedback.png" style="width: 40px;height: 40px;" bindtap='goFeedback'></image>
<view>反馈查看</view>
</view>
<view style="width: 25%;">
<image src="../../icon/apply.png" style="width: 40px;height: 40px;" bindtap='goApply'></image>
<view>申请记录</view>
</view>
</view>
<view style="display: flex;text-align: center;margin-top: 20px;">
<view style="width: 25%;">
<image src="../../icon/yq.png" style="width: 40px;height: 40px;" data-web="xgPage" bindtap='goWebPage'></image>
<view>疫情追踪</view>
</view>
<view style="width: 25%;">
<image src="../../icon/report.png" style="width: 40px;height: 40px;" bindtap='goReport'></image>
<view>今日日报</view>
</view>
<view style="width: 25%;">
<image src="../../icon/UpdPwd.png" style="width: 40px;height: 40px;" bindtap='goUpdPwd'></image>
<view>密码修改</view>
</view>
<view style="width: 25%;">
<image src="../../icon/fk.png" style="width: 40px;height: 40px;" bindtap='goKf'></image>
<view>提交反馈</view>
</view>
</view>
</view>
<view style="background-color:white; border-radius: 50px;width: 30%;margin:10px;margin-top: 20px;">
<view style="display: flex;">
<image src="../../icon/notice.png" style="height: 30px;width: 30px;margin:5px"></image>
<text style="margin-top: 7px;">系统公告</text>
</view>
<view>
</view>
</view>
<view style="height: 200px;width: 350px;border: black solid 1px;margin-left: 12px;border-radius: 5%;">
<view wx:for="{{notice}}">
<view style="margin: 20px;"> {{item.title}}
<text class="noticeTime">{{item.time}}</text>
<view class="line"></view>
</view>
</view>
</view>
</view>

View File

@@ -0,0 +1,14 @@
/* pages/home/home.wxss */
page{
height: 100%;
}
.line{
width: 100%;
height: 1px;
background-color: #cccccc;
margin-top: 10px;
}
.noticeTime{
float: right;
font-size: small;
}