diff --git a/TODOs.md b/TODOs.md index 0f837a0..a206a19 100644 --- a/TODOs.md +++ b/TODOs.md @@ -1,8 +1,11 @@ -启动 Nacos +# 启动 Nacos E: cd E:\nacos\bin startup.cmd -m standalone +# 内网穿透 +cd E:\Project\毕业设计\epp\intranet-penetration\bin +rathole.exe ../conf/client.toml ----- Nacos CPU 跑满问题 我提的 GitHub issue diff --git a/backend/microservice-provider-user-8001/pom.xml b/backend/microservice-provider-user-8001/pom.xml index b11dff7..bfa0d1d 100644 --- a/backend/microservice-provider-user-8001/pom.xml +++ b/backend/microservice-provider-user-8001/pom.xml @@ -82,6 +82,12 @@ spring-cloud-starter-alibaba-nacos-discovery + + + commons-codec + commons-codec + + diff --git a/backend/microservice-provider-user-8001/src/main/java/com/cxyxiaomo/epp/user/controller/UserController.java b/backend/microservice-provider-user-8001/src/main/java/com/cxyxiaomo/epp/user/controller/UserController.java index f6c1498..fa29739 100644 --- a/backend/microservice-provider-user-8001/src/main/java/com/cxyxiaomo/epp/user/controller/UserController.java +++ b/backend/microservice-provider-user-8001/src/main/java/com/cxyxiaomo/epp/user/controller/UserController.java @@ -4,6 +4,7 @@ import com.cxyxiaomo.epp.common.pojo.User; import com.cxyxiaomo.epp.common.response.Res; import com.cxyxiaomo.epp.common.vo.UserVO; import com.cxyxiaomo.epp.user.service.UserServiceImpl; +import org.apache.commons.codec.digest.DigestUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PostMapping; @@ -32,8 +33,8 @@ public class UserController { public Res login(@RequestParam("username") String username, @RequestParam("password") String password) { User user = userService.getUserByUsername(username); if (user != null) { - String passwordHash = user.getPassword(); - if (passwordHash.equals(password)) { + String passwordHash = DigestUtils.sha512Hex(password); + if (passwordHash.equals(user.getPassword())) { HashMap map = new HashMap<>(); map.put("userInfo", UserVO.convertFrom(user)); return Res.success(map); diff --git a/backend/pom.xml b/backend/pom.xml index f39cca6..4aa923a 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -158,6 +158,13 @@ ${jackson.version} + + + commons-codec + commons-codec + 1.15 + + diff --git a/database/epp.sql b/database/epp.sql index 6d518bf..d08f81f 100644 --- a/database/epp.sql +++ b/database/epp.sql @@ -1,272 +1,271 @@ -/* - Navicat Premium Data Transfer - - Source Server : localhost MySQL 8.0 - Source Server Type : MySQL - Source Server Version : 80012 - Source Host : localhost:3306 - Source Schema : epp - - Target Server Type : MySQL - Target Server Version : 80012 - File Encoding : 65001 - - Date: 15/03/2023 15:55:32 -*/ - -SET NAMES utf8mb4; -SET FOREIGN_KEY_CHECKS = 0; - --- ---------------------------- --- Table structure for apply1 --- ---------------------------- -DROP TABLE IF EXISTS `apply1`; -CREATE TABLE `apply1` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `stu_id` int(11) NULL DEFAULT NULL COMMENT '用户id', - `issue` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '申请事由', - `transport` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '出行方式', - `place` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '目的地', - `start_time` datetime NULL DEFAULT NULL COMMENT '开始时间', - `end_time` datetime NULL DEFAULT NULL COMMENT '结束时间', - `state` int(11) NULL DEFAULT 0 COMMENT '状态(0:审批中,1:通过,2:驳回)', - `reason` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '驳回原因', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; - --- ---------------------------- --- Records of apply1 --- ---------------------------- -INSERT INTO `apply1` VALUES (1, 1, '11', '飞机', '33', '2022-02-15 11:20:00', '2022-02-15 13:20:00', 2, '格式错误'); -INSERT INTO `apply1` VALUES (2, 2, '333', '大巴', '333', '2022-02-15 11:51:00', '2022-02-15 13:51:00', 1, ''); -INSERT INTO `apply1` VALUES (3, 2, '333', '大巴', '333', '2022-02-15 11:51:00', '2022-02-15 13:51:00', 2, '格式错误'); -INSERT INTO `apply1` VALUES (4, 2, '1', '动车', '2', '2022-03-12 13:45:00', '2022-03-12 15:45:00', 1, ''); -INSERT INTO `apply1` VALUES (5, 2, '11', '飞机', '22', '2022-03-12 20:29:00', '2022-03-12 22:29:00', 1, ''); -INSERT INTO `apply1` VALUES (6, 1, '123', '飞机', '123', '2022-03-19 13:37:00', '2022-03-19 15:37:00', 1, ''); -INSERT INTO `apply1` VALUES (9, 10, '1', '飞机', '1', '2022-06-15 10:41:00', '2022-06-15 12:41:00', 1, ''); -INSERT INTO `apply1` VALUES (10, 12, '1', '飞机', '1', '2022-06-15 10:53:00', '2022-06-15 12:53:00', 2, '格式错误'); -INSERT INTO `apply1` VALUES (11, 2, '1', '飞机', '1', '2022-10-23 16:17:00', '2022-10-23 18:17:00', 1, ''); -INSERT INTO `apply1` VALUES (12, 13, '1', '飞机', '1', '2022-10-26 19:25:00', '2022-10-26 21:25:00', 1, ''); - --- ---------------------------- --- Table structure for count1 --- ---------------------------- -DROP TABLE IF EXISTS `count1`; -CREATE TABLE `count1` ( - `date` date NOT NULL COMMENT '日期', - `time` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '时间', - `in_num` int(11) NULL DEFAULT NULL COMMENT '入校人数', - `out_num` int(11) NULL DEFAULT NULL COMMENT '出校人数', - PRIMARY KEY (`date`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; - --- ---------------------------- --- Records of count1 --- ---------------------------- - --- ---------------------------- --- Table structure for feedback1 --- ---------------------------- -DROP TABLE IF EXISTS `feedback1`; -CREATE TABLE `feedback1` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '反馈标题', - `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '反馈内容', - `time` datetime NULL DEFAULT NULL COMMENT '反馈时间', - `user_id` int(11) NULL DEFAULT NULL COMMENT '反馈用户id', - `reply` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '回复', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; - --- ---------------------------- --- Records of feedback1 --- ---------------------------- -INSERT INTO `feedback1` VALUES (1, '111', '222', '2022-02-14 10:18:29', 1, '22'); -INSERT INTO `feedback1` VALUES (2, '111', '222', '2022-02-14 10:20:05', 1, '33'); -INSERT INTO `feedback1` VALUES (3, '22', '33', '2022-02-14 10:20:29', 1, 'no'); -INSERT INTO `feedback1` VALUES (4, '``', '11', '2022-02-14 10:22:12', 1, '111'); -INSERT INTO `feedback1` VALUES (5, '123', '123456', '2022-03-28 19:34:04', 2, NULL); - --- ---------------------------- --- Table structure for goods --- ---------------------------- -DROP TABLE IF EXISTS `goods`; -CREATE TABLE `goods` ( - `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, - `goods_name` varchar(127) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品名称', - `category_id` int(11) NULL DEFAULT 0 COMMENT '商品所属类目ID', - `brand` int(11) NULL DEFAULT 0 COMMENT '商品品牌', - `gallery` varchar(1023) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品宣传图片列表,采用JSON数组格式', - `brief` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品简介', - `is_on_sale` tinyint(1) NULL DEFAULT 1 COMMENT '是否上架', - `sort_order` smallint(4) NULL DEFAULT 100 COMMENT '排序', - `pic_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品页面商品图片', - `type` tinyint(1) NULL DEFAULT 0 COMMENT '商品类型', - `unit` varchar(31) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '’件‘' COMMENT '商品单位,例如件、盒', - `counter_price` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '专柜价格', - `retail_price` decimal(10, 2) NULL DEFAULT 100000.00 COMMENT '零售价格', - `detail` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '商品详细介绍,是富文本格式', - `deleted` tinyint(1) NULL DEFAULT 0 COMMENT '逻辑删除 0为正常 1为删除', - PRIMARY KEY (`id`) USING BTREE, - INDEX `category_id`(`category_id`) USING BTREE, - INDEX `brand_id`(`brand`) USING BTREE, - INDEX `sort_order`(`sort_order`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '商品基本信息表' ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of goods --- ---------------------------- -INSERT INTO `goods` VALUES (1, '口罩', 0, 0, NULL, NULL, 1, 100, NULL, 0, '’件‘', 0.00, 100000.00, NULL, 0); - --- ---------------------------- --- Table structure for goods_category --- ---------------------------- -DROP TABLE IF EXISTS `goods_category`; -CREATE TABLE `goods_category` ( - `id` int(11) NOT NULL, - `category_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品分类名', - `order` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '排序', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of goods_category --- ---------------------------- - --- ---------------------------- --- Table structure for notice1 --- ---------------------------- -DROP TABLE IF EXISTS `notice1`; -CREATE TABLE `notice1` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '标题', - `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '内容', - `time` date NULL DEFAULT NULL COMMENT '时间', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; - --- ---------------------------- --- Records of notice1 --- ---------------------------- -INSERT INTO `notice1` VALUES (1, '请各位学生戴好口罩', NULL, '2022-03-15'); -INSERT INTO `notice1` VALUES (2, '请各位学生不要随意出入校门', NULL, '2022-03-15'); -INSERT INTO `notice1` VALUES (7, '11', '22', '2022-03-22'); -INSERT INTO `notice1` VALUES (8, '22', '22', '2022-04-14'); -INSERT INTO `notice1` VALUES (9, '33', '33', '2022-04-14'); - --- ---------------------------- --- Table structure for report --- ---------------------------- -DROP TABLE IF EXISTS `report`; -CREATE TABLE `report` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `user_id` int(11) NULL DEFAULT NULL COMMENT '用户id', - `name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '姓名', - `time` datetime NULL DEFAULT NULL COMMENT '填报时间', - `temperature` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '体温是否正常', - `address` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '地址', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 58 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; - --- ---------------------------- --- Records of report --- ---------------------------- -INSERT INTO `report` VALUES (53, 1, '管理员 密码root', '2022-12-26 20:35:38', '1', '湖北省武汉市洪山区文治街南湖雅园(洪山区信访局对面)'); -INSERT INTO `report` VALUES (55, 1, '管理员 密码root', '2022-12-27 21:03:24', '0', '湖北省武汉市洪山区文治街508号南湖雅园F栋2-104号'); -INSERT INTO `report` VALUES (57, 1, '管理员 密码root', '2022-12-28 21:47:57', '0', '湖北省武汉市洪山区文治街南湖雅园(洪山区信访局对面)'); -INSERT INTO `report` VALUES (58, 1, '管理员 密码root', '2022-12-29 18:20:00', '1', '湖北省武汉市洪山区鲁磨路209号'); - --- ---------------------------- --- Table structure for setting --- ---------------------------- -DROP TABLE IF EXISTS `setting`; -CREATE TABLE `setting` ( - `key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, - `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, - `time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间或失效时间(具体根据key来判断)', - UNIQUE INDEX `key`(`key`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic; - --- ---------------------------- --- Records of setting --- ---------------------------- -INSERT INTO `setting` VALUES ('wechat_access_token', '66_sC2-1ygooBWjbLaEz2-or6IGqFs76UvUnRIpxXo_rJqw2BS45J_X128_xks1ekQPvF6LK22AcfA6d7OmcBWeulrRhUFNO3MPaog-_u-TqJxQ6XoRUPN9iUWR0Y8HQWiAGAUDJ', '2023-03-07 01:19:44'); - --- ---------------------------- --- Table structure for user --- ---------------------------- -DROP TABLE IF EXISTS `user`; -CREATE TABLE `user` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `username` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户名', - `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '密码', - `realname` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '真实姓名', - `id_number` varchar(18) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '身份证号', - `phone_number` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '手机号', - `role` int(11) NOT NULL COMMENT '角色 (0-超级管理员 1-工作人员 2-社区居民_房主 3-社区居民_家庭成员 4-社区居民_租客 5-访客)', - `building_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '门栋号+单元号', - `doorplate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '门牌号', - `permission` int(11) NOT NULL DEFAULT 0 COMMENT '进出权限 (0-无 1-继承(普通居民) 2-永久 3-限时)', - `permission_time` datetime NULL DEFAULT NULL COMMENT '进出权限失效时间', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; - --- ---------------------------- --- Records of user --- ---------------------------- -INSERT INTO `user` VALUES (1, 'root', '63a9f0ea7bb98050796b649e85481845', '管理员 密码root', '420111111111111111', NULL, 1, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (2, 'lhz', 'lhz', '廖鸿志', NULL, NULL, 2, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (3, '21180000', '21180000', '李', NULL, NULL, 2, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (4, '211', '211', '11', NULL, NULL, 2, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (5, '2111', '2111', '111', NULL, NULL, 1, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (6, '222', '222', '33', NULL, NULL, 2, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (7, '33', '33', '44', NULL, NULL, 2, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (8, 'test', '1', 'test', NULL, NULL, 3, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (9, '123456', '123456', '123456', NULL, NULL, 2, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (10, '211806336', '211806336', '211806336', NULL, NULL, 2, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (11, '001', '001', '老师', NULL, NULL, 1, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (12, '002', '002', '刘鸿宇', NULL, NULL, 2, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (13, 'z', 'zz', 'z', NULL, NULL, 2, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (14, '111', '222', '222', NULL, NULL, 222, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (15, '222', '222', '222', NULL, NULL, 222, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (16, '222', '222', '222', NULL, NULL, 222, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (17, '111111111111', '111111111111', '111111111111', NULL, NULL, 2, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (18, '12', '12', '12', NULL, NULL, 2, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (19, '210602212109', '210602212109', '曾子华', NULL, NULL, 2, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (20, 'undefined', 'undefined', '信息2121', NULL, NULL, 2, NULL, NULL, 0, NULL); -INSERT INTO `user` VALUES (21, '2', '2', '曾', NULL, NULL, 2, NULL, NULL, 0, NULL); - --- ---------------------------- --- Table structure for visitor1 --- ---------------------------- -DROP TABLE IF EXISTS `visitor1`; -CREATE TABLE `visitor1` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `time` datetime NULL DEFAULT NULL COMMENT '预约时间', - `phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预约用户id', - `issue` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预约事由', - `meet_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '会见人姓名', - `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', - `state` int(11) NULL DEFAULT 0 COMMENT '状态(0:审批中,1:成功,2:驳回)', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 14 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; - --- ---------------------------- --- Records of visitor1 --- ---------------------------- -INSERT INTO `visitor1` VALUES (1, '2022-03-09 09:46:50', '136', NULL, NULL, NULL, 1); -INSERT INTO `visitor1` VALUES (2, '2022-03-09 00:00:00', '1', '2', '王老师', NULL, 1); -INSERT INTO `visitor1` VALUES (3, '2022-03-13 00:00:00', '123', '123', '123', NULL, 1); -INSERT INTO `visitor1` VALUES (4, '2022-03-17 00:00:00', '183', '11', '1111', NULL, 1); -INSERT INTO `visitor1` VALUES (5, '2022-03-20 07:00:00', '15555150781', '测试', '王德发', NULL, 1); -INSERT INTO `visitor1` VALUES (6, '2022-03-20 07:00:00', '15555150782', '测试', '王德发', NULL, 1); -INSERT INTO `visitor1` VALUES (7, '2022-03-20 00:00:00', '12345', '返校', '自己', NULL, 1); -INSERT INTO `visitor1` VALUES (8, '2022-03-21 00:00:00', '1', '1', '1', NULL, 1); -INSERT INTO `visitor1` VALUES (9, '2022-03-22 00:00:00', '11', '11', '1', NULL, 1); -INSERT INTO `visitor1` VALUES (10, '2022-03-22 00:00:00', '183', '1', '123', NULL, 1); -INSERT INTO `visitor1` VALUES (11, '2022-04-20 00:00:00', '19851691582', '看吧', '哈哈', NULL, 0); -INSERT INTO `visitor1` VALUES (12, '2022-04-26 00:00:00', '18835381168', 'jin', 'zhang ', NULL, 0); -INSERT INTO `visitor1` VALUES (13, '2022-06-15 00:00:00', '18250314786', '1', '1', NULL, 1); -INSERT INTO `visitor1` VALUES (14, '2022-10-08 00:00:00', '151000', '入校', '王龙', NULL, 0); - -SET FOREIGN_KEY_CHECKS = 1; +/* + Navicat Premium Data Transfer + + Source Server : 192.168.2.29 测试库(装Nacos的Ubuntu) + Source Server Type : MySQL + Source Server Version : 80032 + Source Host : 192.168.2.29:3306 + Source Schema : epp + + Target Server Type : MySQL + Target Server Version : 80032 + File Encoding : 65001 + + Date: 17/03/2023 02:12:17 +*/ + +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for apply1 +-- ---------------------------- +DROP TABLE IF EXISTS `apply1`; +CREATE TABLE `apply1` ( + `id` int NOT NULL AUTO_INCREMENT, + `stu_id` int NULL DEFAULT NULL COMMENT '用户id', + `issue` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '申请事由', + `transport` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '出行方式', + `place` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '目的地', + `start_time` datetime NULL DEFAULT NULL COMMENT '开始时间', + `end_time` datetime NULL DEFAULT NULL COMMENT '结束时间', + `state` int NULL DEFAULT 0 COMMENT '状态(0:审批中,1:通过,2:驳回)', + `reason` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '驳回原因', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 12 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of apply1 +-- ---------------------------- +INSERT INTO `apply1` VALUES (1, 1, '11', '飞机', '33', '2022-02-15 11:20:00', '2022-02-15 13:20:00', 2, '格式错误'); +INSERT INTO `apply1` VALUES (2, 2, '333', '大巴', '333', '2022-02-15 11:51:00', '2022-02-15 13:51:00', 1, ''); +INSERT INTO `apply1` VALUES (3, 2, '333', '大巴', '333', '2022-02-15 11:51:00', '2022-02-15 13:51:00', 2, '格式错误'); +INSERT INTO `apply1` VALUES (4, 2, '1', '动车', '2', '2022-03-12 13:45:00', '2022-03-12 15:45:00', 1, ''); +INSERT INTO `apply1` VALUES (5, 2, '11', '飞机', '22', '2022-03-12 20:29:00', '2022-03-12 22:29:00', 1, ''); +INSERT INTO `apply1` VALUES (6, 1, '123', '飞机', '123', '2022-03-19 13:37:00', '2022-03-19 15:37:00', 1, ''); +INSERT INTO `apply1` VALUES (9, 10, '1', '飞机', '1', '2022-06-15 10:41:00', '2022-06-15 12:41:00', 1, ''); +INSERT INTO `apply1` VALUES (10, 12, '1', '飞机', '1', '2022-06-15 10:53:00', '2022-06-15 12:53:00', 2, '格式错误'); +INSERT INTO `apply1` VALUES (11, 2, '1', '飞机', '1', '2022-10-23 16:17:00', '2022-10-23 18:17:00', 1, ''); +INSERT INTO `apply1` VALUES (12, 13, '1', '飞机', '1', '2022-10-26 19:25:00', '2022-10-26 21:25:00', 1, ''); + +-- ---------------------------- +-- Table structure for count1 +-- ---------------------------- +DROP TABLE IF EXISTS `count1`; +CREATE TABLE `count1` ( + `date` date NOT NULL COMMENT '日期', + `time` datetime NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '时间', + `in_num` int NULL DEFAULT NULL COMMENT '入校人数', + `out_num` int NULL DEFAULT NULL COMMENT '出校人数', + PRIMARY KEY (`date`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of count1 +-- ---------------------------- + +-- ---------------------------- +-- Table structure for feedback1 +-- ---------------------------- +DROP TABLE IF EXISTS `feedback1`; +CREATE TABLE `feedback1` ( + `id` int NOT NULL AUTO_INCREMENT, + `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '反馈标题', + `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '反馈内容', + `time` datetime NULL DEFAULT NULL COMMENT '反馈时间', + `user_id` int NULL DEFAULT NULL COMMENT '反馈用户id', + `reply` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '回复', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of feedback1 +-- ---------------------------- +INSERT INTO `feedback1` VALUES (1, '111', '222', '2022-02-14 10:18:29', 1, '22'); +INSERT INTO `feedback1` VALUES (2, '111', '222', '2022-02-14 10:20:05', 1, '33'); +INSERT INTO `feedback1` VALUES (3, '22', '33', '2022-02-14 10:20:29', 1, 'no'); +INSERT INTO `feedback1` VALUES (4, '``', '11', '2022-02-14 10:22:12', 1, '111'); +INSERT INTO `feedback1` VALUES (5, '123', '123456', '2022-03-28 19:34:04', 2, NULL); + +-- ---------------------------- +-- Table structure for goods +-- ---------------------------- +DROP TABLE IF EXISTS `goods`; +CREATE TABLE `goods` ( + `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, + `goods_name` varchar(127) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品名称', + `category_id` int NULL DEFAULT 0 COMMENT '商品所属类目ID', + `brand` int NULL DEFAULT 0 COMMENT '商品品牌', + `gallery` varchar(1023) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品宣传图片列表,采用JSON数组格式', + `brief` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品简介', + `is_on_sale` tinyint(1) NULL DEFAULT 1 COMMENT '是否上架', + `sort_order` smallint NULL DEFAULT 100 COMMENT '排序', + `pic_url` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品页面商品图片', + `type` tinyint(1) NULL DEFAULT 0 COMMENT '商品类型', + `unit` varchar(31) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '’件‘' COMMENT '商品单位,例如件、盒', + `counter_price` decimal(10, 2) NULL DEFAULT 0.00 COMMENT '专柜价格', + `retail_price` decimal(10, 2) NULL DEFAULT 100000.00 COMMENT '零售价格', + `detail` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL COMMENT '商品详细介绍,是富文本格式', + `deleted` tinyint(1) NULL DEFAULT 0 COMMENT '逻辑删除 0为正常 1为删除', + PRIMARY KEY (`id`) USING BTREE, + INDEX `category_id`(`category_id`) USING BTREE, + INDEX `brand_id`(`brand`) USING BTREE, + INDEX `sort_order`(`sort_order`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '商品基本信息表' ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of goods +-- ---------------------------- +INSERT INTO `goods` VALUES (1, '口罩', 0, 0, NULL, NULL, 1, 100, NULL, 0, '’件‘', 0.00, 100000.00, NULL, 0); + +-- ---------------------------- +-- Table structure for goods_category +-- ---------------------------- +DROP TABLE IF EXISTS `goods_category`; +CREATE TABLE `goods_category` ( + `id` int NOT NULL, + `category_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品分类名', + `order` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '排序', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of goods_category +-- ---------------------------- + +-- ---------------------------- +-- Table structure for notice1 +-- ---------------------------- +DROP TABLE IF EXISTS `notice1`; +CREATE TABLE `notice1` ( + `id` int NOT NULL AUTO_INCREMENT, + `title` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '标题', + `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '内容', + `time` date NULL DEFAULT NULL COMMENT '时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of notice1 +-- ---------------------------- +INSERT INTO `notice1` VALUES (1, '请各位学生戴好口罩', NULL, '2022-03-15'); +INSERT INTO `notice1` VALUES (2, '请各位学生不要随意出入校门', NULL, '2022-03-15'); +INSERT INTO `notice1` VALUES (7, '11', '22', '2022-03-22'); +INSERT INTO `notice1` VALUES (8, '22', '22', '2022-04-14'); +INSERT INTO `notice1` VALUES (9, '33', '33', '2022-04-14'); + +-- ---------------------------- +-- Table structure for report +-- ---------------------------- +DROP TABLE IF EXISTS `report`; +CREATE TABLE `report` ( + `id` int NOT NULL AUTO_INCREMENT, + `user_id` int NULL DEFAULT NULL COMMENT '用户id', + `name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '姓名', + `time` datetime NULL DEFAULT NULL COMMENT '填报时间', + `temperature` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '体温是否正常', + `address` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '地址', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 58 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of report +-- ---------------------------- +INSERT INTO `report` VALUES (53, 1, '管理员 密码root', '2022-12-26 20:35:38', '1', '湖北省武汉市洪山区文治街南湖雅园(洪山区信访局对面)'); +INSERT INTO `report` VALUES (55, 1, '管理员 密码root', '2022-12-27 21:03:24', '0', '湖北省武汉市洪山区文治街508号南湖雅园F栋2-104号'); +INSERT INTO `report` VALUES (57, 1, '管理员 密码root', '2022-12-28 21:47:57', '0', '湖北省武汉市洪山区文治街南湖雅园(洪山区信访局对面)'); +INSERT INTO `report` VALUES (58, 1, '管理员 密码root', '2022-12-29 18:20:00', '1', '湖北省武汉市洪山区鲁磨路209号'); + +-- ---------------------------- +-- Table structure for setting +-- ---------------------------- +DROP TABLE IF EXISTS `setting`; +CREATE TABLE `setting` ( + `key` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `value` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL, + `time` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间或失效时间(具体根据key来判断)', + UNIQUE INDEX `key`(`key`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of setting +-- ---------------------------- + +-- ---------------------------- +-- Table structure for user +-- ---------------------------- +DROP TABLE IF EXISTS `user`; +CREATE TABLE `user` ( + `id` int NOT NULL AUTO_INCREMENT, + `username` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '用户名', + `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '密码', + `realname` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '真实姓名', + `id_number` varchar(18) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '身份证号', + `phone_number` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '手机号', + `role` int NOT NULL COMMENT '角色 (0-超级管理员 1-工作人员 2-社区居民_房主 3-社区居民_家庭成员 4-社区居民_租客 5-访客)', + `building_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '门栋号+单元号', + `doorplate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '门牌号', + `permission` int NOT NULL DEFAULT 0 COMMENT '进出权限 (0-无 1-继承(普通居民) 2-永久 3-限时)', + `permission_time` datetime NULL DEFAULT NULL COMMENT '进出权限失效时间', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of user +-- ---------------------------- +INSERT INTO `user` VALUES (1, 'root', '99adc231b045331e514a516b4b7680f588e3823213abe901738bc3ad67b2f6fcb3c64efb93d18002588d3ccc1a49efbae1ce20cb43df36b38651f11fa75678e8', '管理员 密码root', '420111111111111111', NULL, 1, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (2, 'lhz', 'lhz', '廖鸿志', NULL, NULL, 2, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (3, '21180000', '21180000', '李', NULL, NULL, 2, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (4, '211', '211', '11', NULL, NULL, 2, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (5, '2111', '2111', '111', NULL, NULL, 1, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (6, '222', '222', '33', NULL, NULL, 2, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (7, '33', '33', '44', NULL, NULL, 2, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (8, 'test', '1', 'test', NULL, NULL, 3, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (9, '123456', '123456', '123456', NULL, NULL, 2, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (10, '211806336', '211806336', '211806336', NULL, NULL, 2, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (11, '001', '001', '老师', NULL, NULL, 1, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (12, '002', '002', '刘鸿宇', NULL, NULL, 2, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (13, 'z', 'zz', 'z', NULL, NULL, 2, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (14, '111', '222', '222', NULL, NULL, 222, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (15, '222', '222', '222', NULL, NULL, 222, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (16, '222', '222', '222', NULL, NULL, 222, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (17, '111111111111', '111111111111', '111111111111', NULL, NULL, 2, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (18, '12', '12', '12', NULL, NULL, 2, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (19, '210602212109', '210602212109', '曾子华', NULL, NULL, 2, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (20, 'undefined', 'undefined', '信息2121', NULL, NULL, 2, NULL, NULL, 0, NULL); +INSERT INTO `user` VALUES (21, '2', '2', '曾', NULL, NULL, 2, NULL, NULL, 0, NULL); + +-- ---------------------------- +-- Table structure for visitor1 +-- ---------------------------- +DROP TABLE IF EXISTS `visitor1`; +CREATE TABLE `visitor1` ( + `id` int NOT NULL AUTO_INCREMENT, + `time` datetime NULL DEFAULT NULL COMMENT '预约时间', + `phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预约用户id', + `issue` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预约事由', + `meet_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '会见人姓名', + `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', + `state` int NULL DEFAULT 0 COMMENT '状态(0:审批中,1:成功,2:驳回)', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 14 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC; + +-- ---------------------------- +-- Records of visitor1 +-- ---------------------------- +INSERT INTO `visitor1` VALUES (1, '2022-03-09 09:46:50', '136', NULL, NULL, NULL, 1); +INSERT INTO `visitor1` VALUES (2, '2022-03-09 00:00:00', '1', '2', '王老师', NULL, 1); +INSERT INTO `visitor1` VALUES (3, '2022-03-13 00:00:00', '123', '123', '123', NULL, 1); +INSERT INTO `visitor1` VALUES (4, '2022-03-17 00:00:00', '183', '11', '1111', NULL, 1); +INSERT INTO `visitor1` VALUES (5, '2022-03-20 07:00:00', '15555150781', '测试', '王德发', NULL, 1); +INSERT INTO `visitor1` VALUES (6, '2022-03-20 07:00:00', '15555150782', '测试', '王德发', NULL, 1); +INSERT INTO `visitor1` VALUES (7, '2022-03-20 00:00:00', '12345', '返校', '自己', NULL, 1); +INSERT INTO `visitor1` VALUES (8, '2022-03-21 00:00:00', '1', '1', '1', NULL, 1); +INSERT INTO `visitor1` VALUES (9, '2022-03-22 00:00:00', '11', '11', '1', NULL, 1); +INSERT INTO `visitor1` VALUES (10, '2022-03-22 00:00:00', '183', '1', '123', NULL, 1); +INSERT INTO `visitor1` VALUES (11, '2022-04-20 00:00:00', '19851691582', '看吧', '哈哈', NULL, 0); +INSERT INTO `visitor1` VALUES (12, '2022-04-26 00:00:00', '18835381168', 'jin', 'zhang ', NULL, 0); +INSERT INTO `visitor1` VALUES (13, '2022-06-15 00:00:00', '18250314786', '1', '1', NULL, 1); +INSERT INTO `visitor1` VALUES (14, '2022-10-08 00:00:00', '151000', '入校', '王龙', NULL, 0); + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/miniprogram/src/pages/residents/reportHistory.vue b/miniprogram/src/pages/residents/reportHistory.vue index 54fb4a1..e7cac4a 100644 --- a/miniprogram/src/pages/residents/reportHistory.vue +++ b/miniprogram/src/pages/residents/reportHistory.vue @@ -88,7 +88,6 @@ export default { onHide() { console.log('onHide') - clearInterval(this.timeInterval) }, methods: { diff --git a/weixin-miniprogram/.eslintrc.js b/weixin-miniprogram/.eslintrc.js new file mode 100644 index 0000000..115cc02 --- /dev/null +++ b/weixin-miniprogram/.eslintrc.js @@ -0,0 +1,31 @@ +/* + * Eslint config file + * Documentation: https://eslint.org/docs/user-guide/configuring/ + * Install the Eslint extension before using this feature. + */ +module.exports = { + env: { + es6: true, + browser: true, + node: true, + }, + ecmaFeatures: { + modules: true, + }, + parserOptions: { + ecmaVersion: 2018, + sourceType: 'module', + }, + globals: { + wx: true, + App: true, + Page: true, + getCurrentPages: true, + getApp: true, + Component: true, + requirePlugin: true, + requireMiniProgram: true, + }, + // extends: 'eslint:recommended', + rules: {}, +} diff --git a/weixin-miniprogram/app.js b/weixin-miniprogram/app.js new file mode 100644 index 0000000..dc9d8bd --- /dev/null +++ b/weixin-miniprogram/app.js @@ -0,0 +1,23 @@ +// app.js +App({ + onLaunch() { + // 展示本地存储能力 + const logs = wx.getStorageSync('logs') || [] + logs.unshift(Date.now()) + wx.setStorageSync('logs', logs) + + // 登录 + wx.login({ + success: res => { + // 发送 res.code 到后台换取 openId, sessionKey, unionId + } + }) + }, + globalData: { + debugMode: true, // 是否展示调试内容 + baseUrl: true ? // Api 请求域名 不带最后的 / + "https://epp.only4.work" : + "http://localhost", + userInfo: null + } +}) diff --git a/weixin-miniprogram/app.json b/weixin-miniprogram/app.json new file mode 100644 index 0000000..f091548 --- /dev/null +++ b/weixin-miniprogram/app.json @@ -0,0 +1,61 @@ +{ + "pages": [ + "pages/index/index", + "pages/index2/index", + "pages/logs/logs", + "pages/residents/code", + "pages/residents/report", + "pages/index/login", + "pages/scan/entrance", + "pages/person/person", + "pages/residents/reportHistory" + ], + "window": { + "backgroundTextStyle": "dark", + "navigationBarBackgroundColor": "#000", + "navigationBarTitleText": "Weixin", + "navigationBarTextStyle": "white" + }, + "tabBar": { + "custom": false, + "color": "#000000", + "backgroundColor": "#fff", + "selectedColor": "#FF8966", + "list": [ + { + "pagePath": "pages/index/index", + "text": "首页", + "iconPath": "image/icon/_home.png", + "selectedIconPath": "image/icon/home.png" + }, + { + "pagePath": "pages/residents/code", + "text": "进出码", + "iconPath": "image/icon/_code.png", + "selectedIconPath": "image/icon/code.png" + }, + { + "pagePath": "pages/residents/report", + "text": "体温上报", + "iconPath": "image/icon/_report.png", + "selectedIconPath": "image/icon/report.png" + }, + { + "pagePath": "pages/person/person", + "text": "我", + "iconPath": "image/icon/_person.png", + "selectedIconPath": "image/icon/person.png" + } + ] + }, + "permission": { + "scope.userLocation": { + "desc": "你的位置信息将用于体温上报" + } + }, + "requiredPrivateInfos": [ + "chooseLocation" + ], + "style": "v2", + "sitemapLocation": "sitemap.json" +} \ No newline at end of file diff --git a/weixin-miniprogram/app.wxss b/weixin-miniprogram/app.wxss new file mode 100644 index 0000000..75f4fde --- /dev/null +++ b/weixin-miniprogram/app.wxss @@ -0,0 +1 @@ +/**app.wxss**/ diff --git a/weixin-miniprogram/image/home.jpg b/weixin-miniprogram/image/home.jpg new file mode 100644 index 0000000..ad08a53 Binary files /dev/null and b/weixin-miniprogram/image/home.jpg differ diff --git a/weixin-miniprogram/image/icon/_code.png b/weixin-miniprogram/image/icon/_code.png new file mode 100644 index 0000000..4b03aa6 Binary files /dev/null and b/weixin-miniprogram/image/icon/_code.png differ diff --git a/weixin-miniprogram/image/icon/_home.png b/weixin-miniprogram/image/icon/_home.png new file mode 100644 index 0000000..2a4c773 Binary files /dev/null and b/weixin-miniprogram/image/icon/_home.png differ diff --git a/weixin-miniprogram/image/icon/_person.png b/weixin-miniprogram/image/icon/_person.png new file mode 100644 index 0000000..956c7fc Binary files /dev/null and b/weixin-miniprogram/image/icon/_person.png differ diff --git a/weixin-miniprogram/image/icon/_report.png b/weixin-miniprogram/image/icon/_report.png new file mode 100644 index 0000000..c61edf6 Binary files /dev/null and b/weixin-miniprogram/image/icon/_report.png differ diff --git a/weixin-miniprogram/image/icon/apply.png b/weixin-miniprogram/image/icon/apply.png new file mode 100644 index 0000000..8483ec4 Binary files /dev/null and b/weixin-miniprogram/image/icon/apply.png differ diff --git a/weixin-miniprogram/image/icon/code.png b/weixin-miniprogram/image/icon/code.png new file mode 100644 index 0000000..0822bcf Binary files /dev/null and b/weixin-miniprogram/image/icon/code.png differ diff --git a/weixin-miniprogram/image/icon/count.png b/weixin-miniprogram/image/icon/count.png new file mode 100644 index 0000000..8a49281 Binary files /dev/null and b/weixin-miniprogram/image/icon/count.png differ diff --git a/weixin-miniprogram/image/icon/danger.png b/weixin-miniprogram/image/icon/danger.png new file mode 100644 index 0000000..0626cff Binary files /dev/null and b/weixin-miniprogram/image/icon/danger.png differ diff --git a/weixin-miniprogram/image/icon/feedback.png b/weixin-miniprogram/image/icon/feedback.png new file mode 100644 index 0000000..b3f53b9 Binary files /dev/null and b/weixin-miniprogram/image/icon/feedback.png differ diff --git a/weixin-miniprogram/image/icon/fk.png b/weixin-miniprogram/image/icon/fk.png new file mode 100644 index 0000000..0044906 Binary files /dev/null and b/weixin-miniprogram/image/icon/fk.png differ diff --git a/weixin-miniprogram/image/icon/gg.png b/weixin-miniprogram/image/icon/gg.png new file mode 100644 index 0000000..a64871c Binary files /dev/null and b/weixin-miniprogram/image/icon/gg.png differ diff --git a/weixin-miniprogram/image/icon/home.png b/weixin-miniprogram/image/icon/home.png new file mode 100644 index 0000000..5190acb Binary files /dev/null and b/weixin-miniprogram/image/icon/home.png differ diff --git a/weixin-miniprogram/image/icon/login-background.svg b/weixin-miniprogram/image/icon/login-background.svg new file mode 100644 index 0000000..0b7b2cb --- /dev/null +++ b/weixin-miniprogram/image/icon/login-background.svg @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/weixin-miniprogram/image/icon/notice.png b/weixin-miniprogram/image/icon/notice.png new file mode 100644 index 0000000..3d5c13e Binary files /dev/null and b/weixin-miniprogram/image/icon/notice.png differ diff --git a/weixin-miniprogram/image/icon/password.png b/weixin-miniprogram/image/icon/password.png new file mode 100644 index 0000000..2eed77e Binary files /dev/null and b/weixin-miniprogram/image/icon/password.png differ diff --git a/weixin-miniprogram/image/icon/person.png b/weixin-miniprogram/image/icon/person.png new file mode 100644 index 0000000..79da453 Binary files /dev/null and b/weixin-miniprogram/image/icon/person.png differ diff --git a/weixin-miniprogram/image/icon/report.png b/weixin-miniprogram/image/icon/report.png new file mode 100644 index 0000000..5f09c6b Binary files /dev/null and b/weixin-miniprogram/image/icon/report.png differ diff --git a/weixin-miniprogram/image/icon/updPwd.png b/weixin-miniprogram/image/icon/updPwd.png new file mode 100644 index 0000000..c4e02f0 Binary files /dev/null and b/weixin-miniprogram/image/icon/updPwd.png differ diff --git a/weixin-miniprogram/image/icon/username.png b/weixin-miniprogram/image/icon/username.png new file mode 100644 index 0000000..f528050 Binary files /dev/null and b/weixin-miniprogram/image/icon/username.png differ diff --git a/weixin-miniprogram/image/icon/visitor.png b/weixin-miniprogram/image/icon/visitor.png new file mode 100644 index 0000000..4dd52d1 Binary files /dev/null and b/weixin-miniprogram/image/icon/visitor.png differ diff --git a/weixin-miniprogram/node_modules/.package-lock.json b/weixin-miniprogram/node_modules/.package-lock.json new file mode 100644 index 0000000..9e0e572 --- /dev/null +++ b/weixin-miniprogram/node_modules/.package-lock.json @@ -0,0 +1,12 @@ +{ + "name": "weixin-miniprogram", + "lockfileVersion": 3, + "requires": true, + "packages": { + "node_modules/blueimp-md5": { + "version": "2.19.0", + "resolved": "https://registry.npmmirror.com/blueimp-md5/-/blueimp-md5-2.19.0.tgz", + "integrity": "sha512-DRQrD6gJyy8FbiE4s+bDoXS9hiW3Vbx5uCdwvcCf3zLHL+Iv7LtGHLpr+GZV8rHG8tK766FGYBwRbu8pELTt+w==" + } + } +} diff --git a/weixin-miniprogram/node_modules/blueimp-md5/LICENSE.txt b/weixin-miniprogram/node_modules/blueimp-md5/LICENSE.txt new file mode 100644 index 0000000..d6a9d74 --- /dev/null +++ b/weixin-miniprogram/node_modules/blueimp-md5/LICENSE.txt @@ -0,0 +1,20 @@ +MIT License + +Copyright © 2011 Sebastian Tschan, https://blueimp.net + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/weixin-miniprogram/node_modules/blueimp-md5/README.md b/weixin-miniprogram/node_modules/blueimp-md5/README.md new file mode 100644 index 0000000..d62931b --- /dev/null +++ b/weixin-miniprogram/node_modules/blueimp-md5/README.md @@ -0,0 +1,134 @@ +# JavaScript MD5 + +## Contents + +- [Demo](https://blueimp.github.io/JavaScript-MD5/) +- [Description](#description) +- [Usage](#usage) + - [Client-side](#client-side) + - [Server-side](#server-side) +- [Requirements](#requirements) +- [API](#api) +- [Tests](#tests) +- [License](#license) + +## Description + +JavaScript [MD5](https://en.wikipedia.org/wiki/MD5) implementation. +Compatible with server-side environments like [Node.js](https://nodejs.org/), +module loaders like [RequireJS](https://requirejs.org/) or +[webpack](https://webpack.js.org/) and all web browsers. + +## Usage + +### Client-side + +Install the **blueimp-md5** package with [NPM](https://www.npmjs.org/): + +```sh +npm install blueimp-md5 +``` + +Include the (minified) JavaScript [MD5](https://en.wikipedia.org/wiki/MD5) +script in your HTML markup: + +```html + +``` + +In your application code, calculate the +([hex](https://en.wikipedia.org/wiki/Hexadecimal)-encoded) +[MD5](https://en.wikipedia.org/wiki/MD5) hash of a string by calling the **md5** +method with the string as argument: + +```js +var hash = md5('value') // "2063c1608d6e0baf80249c42e2be5804" +``` + +### Server-side + +The following is an example how to use the JavaScript MD5 module on the +server-side with [Node.js](https://nodejs.org/). + +Install the **blueimp-md5** package with [NPM](https://www.npmjs.org/): + +```sh +npm install blueimp-md5 +``` + +Add a file **server.js** with the following content: + +```js +require('http') + .createServer(function (req, res) { + // The md5 module exports the md5() function: + var md5 = require('./md5'), + // Use the following version if you installed the package with npm: + // var md5 = require("blueimp-md5"), + url = require('url'), + query = url.parse(req.url).query + res.writeHead(200, { 'Content-Type': 'text/plain' }) + // Calculate and print the MD5 hash of the url query: + res.end(md5(query)) + }) + .listen(8080, 'localhost') +console.log('Server running at http://localhost:8080/') +``` + +Run the application with the following command: + +```sh +node server.js +``` + +## Requirements + +The JavaScript MD5 script has zero dependencies. + +## API + +Calculate the ([hex](https://en.wikipedia.org/wiki/Hexadecimal)-encoded) +[MD5](https://en.wikipedia.org/wiki/MD5) hash of a given string value: + +```js +var hash = md5('value') // "2063c1608d6e0baf80249c42e2be5804" +``` + +Calculate the ([hex](https://en.wikipedia.org/wiki/Hexadecimal)-encoded) +[HMAC](https://en.wikipedia.org/wiki/HMAC)-MD5 hash of a given string value and +key: + +```js +var hash = md5('value', 'key') // "01433efd5f16327ea4b31144572c67f6" +``` + +Calculate the raw [MD5](https://en.wikipedia.org/wiki/MD5) hash of a given +string value: + +```js +var hash = md5('value', null, true) +``` + +Calculate the raw [HMAC](https://en.wikipedia.org/wiki/HMAC)-MD5 hash of a given +string value and key: + +```js +var hash = md5('value', 'key', true) +``` + +## Tests + +The JavaScript MD5 project comes with +[Unit Tests](https://en.wikipedia.org/wiki/Unit_testing). +There are two different ways to run the tests: + +- Open test/index.html in your browser or +- run `npm test` in the Terminal in the root path of the repository package. + +The first one tests the browser integration, the second one the +[Node.js](https://nodejs.org/) integration. + +## License + +The JavaScript MD5 script is released under the +[MIT license](https://opensource.org/licenses/MIT). diff --git a/weixin-miniprogram/node_modules/blueimp-md5/js/md5.js b/weixin-miniprogram/node_modules/blueimp-md5/js/md5.js new file mode 100644 index 0000000..67cebfc --- /dev/null +++ b/weixin-miniprogram/node_modules/blueimp-md5/js/md5.js @@ -0,0 +1,402 @@ +/* + * JavaScript MD5 + * https://github.com/blueimp/JavaScript-MD5 + * + * Copyright 2011, Sebastian Tschan + * https://blueimp.net + * + * Licensed under the MIT license: + * https://opensource.org/licenses/MIT + * + * Based on + * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message + * Digest Algorithm, as defined in RFC 1321. + * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009 + * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet + * Distributed under the BSD License + * See http://pajhome.org.uk/crypt/md5 for more info. + */ + +/* global define */ + +/* eslint-disable strict */ + +;(function ($) { + 'use strict' + + /** + * Add integers, wrapping at 2^32. + * This uses 16-bit operations internally to work around bugs in interpreters. + * + * @param {number} x First integer + * @param {number} y Second integer + * @returns {number} Sum + */ + function safeAdd(x, y) { + var lsw = (x & 0xffff) + (y & 0xffff) + var msw = (x >> 16) + (y >> 16) + (lsw >> 16) + return (msw << 16) | (lsw & 0xffff) + } + + /** + * Bitwise rotate a 32-bit number to the left. + * + * @param {number} num 32-bit number + * @param {number} cnt Rotation count + * @returns {number} Rotated number + */ + function bitRotateLeft(num, cnt) { + return (num << cnt) | (num >>> (32 - cnt)) + } + + /** + * Basic operation the algorithm uses. + * + * @param {number} q q + * @param {number} a a + * @param {number} b b + * @param {number} x x + * @param {number} s s + * @param {number} t t + * @returns {number} Result + */ + function md5cmn(q, a, b, x, s, t) { + return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b) + } + /** + * Basic operation the algorithm uses. + * + * @param {number} a a + * @param {number} b b + * @param {number} c c + * @param {number} d d + * @param {number} x x + * @param {number} s s + * @param {number} t t + * @returns {number} Result + */ + function md5ff(a, b, c, d, x, s, t) { + return md5cmn((b & c) | (~b & d), a, b, x, s, t) + } + /** + * Basic operation the algorithm uses. + * + * @param {number} a a + * @param {number} b b + * @param {number} c c + * @param {number} d d + * @param {number} x x + * @param {number} s s + * @param {number} t t + * @returns {number} Result + */ + function md5gg(a, b, c, d, x, s, t) { + return md5cmn((b & d) | (c & ~d), a, b, x, s, t) + } + /** + * Basic operation the algorithm uses. + * + * @param {number} a a + * @param {number} b b + * @param {number} c c + * @param {number} d d + * @param {number} x x + * @param {number} s s + * @param {number} t t + * @returns {number} Result + */ + function md5hh(a, b, c, d, x, s, t) { + return md5cmn(b ^ c ^ d, a, b, x, s, t) + } + /** + * Basic operation the algorithm uses. + * + * @param {number} a a + * @param {number} b b + * @param {number} c c + * @param {number} d d + * @param {number} x x + * @param {number} s s + * @param {number} t t + * @returns {number} Result + */ + function md5ii(a, b, c, d, x, s, t) { + return md5cmn(c ^ (b | ~d), a, b, x, s, t) + } + + /** + * Calculate the MD5 of an array of little-endian words, and a bit length. + * + * @param {Array} x Array of little-endian words + * @param {number} len Bit length + * @returns {Array} MD5 Array + */ + function binlMD5(x, len) { + /* append padding */ + x[len >> 5] |= 0x80 << len % 32 + x[(((len + 64) >>> 9) << 4) + 14] = len + + var i + var olda + var oldb + var oldc + var oldd + var a = 1732584193 + var b = -271733879 + var c = -1732584194 + var d = 271733878 + + for (i = 0; i < x.length; i += 16) { + olda = a + oldb = b + oldc = c + oldd = d + + a = md5ff(a, b, c, d, x[i], 7, -680876936) + d = md5ff(d, a, b, c, x[i + 1], 12, -389564586) + c = md5ff(c, d, a, b, x[i + 2], 17, 606105819) + b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330) + a = md5ff(a, b, c, d, x[i + 4], 7, -176418897) + d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426) + c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341) + b = md5ff(b, c, d, a, x[i + 7], 22, -45705983) + a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416) + d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417) + c = md5ff(c, d, a, b, x[i + 10], 17, -42063) + b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162) + a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682) + d = md5ff(d, a, b, c, x[i + 13], 12, -40341101) + c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290) + b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329) + + a = md5gg(a, b, c, d, x[i + 1], 5, -165796510) + d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632) + c = md5gg(c, d, a, b, x[i + 11], 14, 643717713) + b = md5gg(b, c, d, a, x[i], 20, -373897302) + a = md5gg(a, b, c, d, x[i + 5], 5, -701558691) + d = md5gg(d, a, b, c, x[i + 10], 9, 38016083) + c = md5gg(c, d, a, b, x[i + 15], 14, -660478335) + b = md5gg(b, c, d, a, x[i + 4], 20, -405537848) + a = md5gg(a, b, c, d, x[i + 9], 5, 568446438) + d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690) + c = md5gg(c, d, a, b, x[i + 3], 14, -187363961) + b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501) + a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467) + d = md5gg(d, a, b, c, x[i + 2], 9, -51403784) + c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473) + b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734) + + a = md5hh(a, b, c, d, x[i + 5], 4, -378558) + d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463) + c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562) + b = md5hh(b, c, d, a, x[i + 14], 23, -35309556) + a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060) + d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353) + c = md5hh(c, d, a, b, x[i + 7], 16, -155497632) + b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640) + a = md5hh(a, b, c, d, x[i + 13], 4, 681279174) + d = md5hh(d, a, b, c, x[i], 11, -358537222) + c = md5hh(c, d, a, b, x[i + 3], 16, -722521979) + b = md5hh(b, c, d, a, x[i + 6], 23, 76029189) + a = md5hh(a, b, c, d, x[i + 9], 4, -640364487) + d = md5hh(d, a, b, c, x[i + 12], 11, -421815835) + c = md5hh(c, d, a, b, x[i + 15], 16, 530742520) + b = md5hh(b, c, d, a, x[i + 2], 23, -995338651) + + a = md5ii(a, b, c, d, x[i], 6, -198630844) + d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415) + c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905) + b = md5ii(b, c, d, a, x[i + 5], 21, -57434055) + a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571) + d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606) + c = md5ii(c, d, a, b, x[i + 10], 15, -1051523) + b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799) + a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359) + d = md5ii(d, a, b, c, x[i + 15], 10, -30611744) + c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380) + b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649) + a = md5ii(a, b, c, d, x[i + 4], 6, -145523070) + d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379) + c = md5ii(c, d, a, b, x[i + 2], 15, 718787259) + b = md5ii(b, c, d, a, x[i + 9], 21, -343485551) + + a = safeAdd(a, olda) + b = safeAdd(b, oldb) + c = safeAdd(c, oldc) + d = safeAdd(d, oldd) + } + return [a, b, c, d] + } + + /** + * Convert an array of little-endian words to a string + * + * @param {Array} input MD5 Array + * @returns {string} MD5 string + */ + function binl2rstr(input) { + var i + var output = '' + var length32 = input.length * 32 + for (i = 0; i < length32; i += 8) { + output += String.fromCharCode((input[i >> 5] >>> i % 32) & 0xff) + } + return output + } + + /** + * Convert a raw string to an array of little-endian words + * Characters >255 have their high-byte silently ignored. + * + * @param {string} input Raw input string + * @returns {Array} Array of little-endian words + */ + function rstr2binl(input) { + var i + var output = [] + output[(input.length >> 2) - 1] = undefined + for (i = 0; i < output.length; i += 1) { + output[i] = 0 + } + var length8 = input.length * 8 + for (i = 0; i < length8; i += 8) { + output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << i % 32 + } + return output + } + + /** + * Calculate the MD5 of a raw string + * + * @param {string} s Input string + * @returns {string} Raw MD5 string + */ + function rstrMD5(s) { + return binl2rstr(binlMD5(rstr2binl(s), s.length * 8)) + } + + /** + * Calculates the HMAC-MD5 of a key and some data (raw strings) + * + * @param {string} key HMAC key + * @param {string} data Raw input string + * @returns {string} Raw MD5 string + */ + function rstrHMACMD5(key, data) { + var i + var bkey = rstr2binl(key) + var ipad = [] + var opad = [] + var hash + ipad[15] = opad[15] = undefined + if (bkey.length > 16) { + bkey = binlMD5(bkey, key.length * 8) + } + for (i = 0; i < 16; i += 1) { + ipad[i] = bkey[i] ^ 0x36363636 + opad[i] = bkey[i] ^ 0x5c5c5c5c + } + hash = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8) + return binl2rstr(binlMD5(opad.concat(hash), 512 + 128)) + } + + /** + * Convert a raw string to a hex string + * + * @param {string} input Raw input string + * @returns {string} Hex encoded string + */ + function rstr2hex(input) { + var hexTab = '0123456789abcdef' + var output = '' + var x + var i + for (i = 0; i < input.length; i += 1) { + x = input.charCodeAt(i) + output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f) + } + return output + } + + /** + * Encode a string as UTF-8 + * + * @param {string} input Input string + * @returns {string} UTF8 string + */ + function str2rstrUTF8(input) { + return unescape(encodeURIComponent(input)) + } + + /** + * Encodes input string as raw MD5 string + * + * @param {string} s Input string + * @returns {string} Raw MD5 string + */ + function rawMD5(s) { + return rstrMD5(str2rstrUTF8(s)) + } + /** + * Encodes input string as Hex encoded string + * + * @param {string} s Input string + * @returns {string} Hex encoded string + */ + function hexMD5(s) { + return rstr2hex(rawMD5(s)) + } + /** + * Calculates the raw HMAC-MD5 for the given key and data + * + * @param {string} k HMAC key + * @param {string} d Input string + * @returns {string} Raw MD5 string + */ + function rawHMACMD5(k, d) { + return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d)) + } + /** + * Calculates the Hex encoded HMAC-MD5 for the given key and data + * + * @param {string} k HMAC key + * @param {string} d Input string + * @returns {string} Raw MD5 string + */ + function hexHMACMD5(k, d) { + return rstr2hex(rawHMACMD5(k, d)) + } + + /** + * Calculates MD5 value for a given string. + * If a key is provided, calculates the HMAC-MD5 value. + * Returns a Hex encoded string unless the raw argument is given. + * + * @param {string} string Input string + * @param {string} [key] HMAC key + * @param {boolean} [raw] Raw output switch + * @returns {string} MD5 output + */ + function md5(string, key, raw) { + if (!key) { + if (!raw) { + return hexMD5(string) + } + return rawMD5(string) + } + if (!raw) { + return hexHMACMD5(key, string) + } + return rawHMACMD5(key, string) + } + + if (typeof define === 'function' && define.amd) { + define(function () { + return md5 + }) + } else if (typeof module === 'object' && module.exports) { + module.exports = md5 + } else { + $.md5 = md5 + } +})(this) diff --git a/weixin-miniprogram/node_modules/blueimp-md5/js/md5.min.js b/weixin-miniprogram/node_modules/blueimp-md5/js/md5.min.js new file mode 100644 index 0000000..f414e7c --- /dev/null +++ b/weixin-miniprogram/node_modules/blueimp-md5/js/md5.min.js @@ -0,0 +1,2 @@ +!function(n){"use strict";function d(n,t){var r=(65535&n)+(65535&t);return(n>>16)+(t>>16)+(r>>16)<<16|65535&r}function f(n,t,r,e,o,u){return d((u=d(d(t,n),d(e,u)))<>>32-o,r)}function l(n,t,r,e,o,u,c){return f(t&r|~t&e,n,t,o,u,c)}function g(n,t,r,e,o,u,c){return f(t&e|r&~e,n,t,o,u,c)}function v(n,t,r,e,o,u,c){return f(t^r^e,n,t,o,u,c)}function m(n,t,r,e,o,u,c){return f(r^(t|~e),n,t,o,u,c)}function c(n,t){var r,e,o,u;n[t>>5]|=128<>>9<<4)]=t;for(var c=1732584193,f=-271733879,i=-1732584194,a=271733878,h=0;h>5]>>>e%32&255);return t}function a(n){var t=[];for(t[(n.length>>2)-1]=void 0,e=0;e>5]|=(255&n.charCodeAt(e/8))<>>4&15)+r.charAt(15&t);return e}function r(n){return unescape(encodeURIComponent(n))}function o(n){return i(c(a(n=r(n)),8*n.length))}function u(n,t){return function(n,t){var r,e=a(n),o=[],u=[];for(o[15]=u[15]=void 0,16 + + + + 欢迎你,{{ displayUsername }}! + + + 调试信息:{{ debugText }} + + + + + + + {{ menuItem.title }} + + + + + + \ No newline at end of file diff --git a/weixin-miniprogram/pages/index/index.wxss b/weixin-miniprogram/pages/index/index.wxss new file mode 100644 index 0000000..8e9c81f --- /dev/null +++ b/weixin-miniprogram/pages/index/index.wxss @@ -0,0 +1 @@ +/* pages/index/index.wxss */ \ No newline at end of file diff --git a/weixin-miniprogram/pages/index/login.js b/weixin-miniprogram/pages/index/login.js new file mode 100644 index 0000000..adc455c --- /dev/null +++ b/weixin-miniprogram/pages/index/login.js @@ -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 + }) + } + }) + } + } +}) diff --git a/weixin-miniprogram/pages/index/login.json b/weixin-miniprogram/pages/index/login.json new file mode 100644 index 0000000..a38ebaa --- /dev/null +++ b/weixin-miniprogram/pages/index/login.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "登录" +} \ No newline at end of file diff --git a/weixin-miniprogram/pages/index/login.wxml b/weixin-miniprogram/pages/index/login.wxml new file mode 100644 index 0000000..5c31198 --- /dev/null +++ b/weixin-miniprogram/pages/index/login.wxml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/weixin-miniprogram/pages/index/login.wxss b/weixin-miniprogram/pages/index/login.wxss new file mode 100644 index 0000000..4f022ab --- /dev/null +++ b/weixin-miniprogram/pages/index/login.wxss @@ -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; +} diff --git a/weixin-miniprogram/pages/index2/index.js b/weixin-miniprogram/pages/index2/index.js new file mode 100644 index 0000000..0bc1771 --- /dev/null +++ b/weixin-miniprogram/pages/index2/index.js @@ -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 + }) + } +}) diff --git a/weixin-miniprogram/pages/index2/index.json b/weixin-miniprogram/pages/index2/index.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/weixin-miniprogram/pages/index2/index.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/weixin-miniprogram/pages/index2/index.wxml b/weixin-miniprogram/pages/index2/index.wxml new file mode 100644 index 0000000..f00d294 --- /dev/null +++ b/weixin-miniprogram/pages/index2/index.wxml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + 请使用1.4.4及以上版本基础库 + + + + {{userInfo.nickName}} + + + + {{motto}} + + diff --git a/weixin-miniprogram/pages/index2/index.wxss b/weixin-miniprogram/pages/index2/index.wxss new file mode 100644 index 0000000..eb64203 --- /dev/null +++ b/weixin-miniprogram/pages/index2/index.wxss @@ -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; +} \ No newline at end of file diff --git a/weixin-miniprogram/pages/logs/logs.js b/weixin-miniprogram/pages/logs/logs.js new file mode 100644 index 0000000..85f6aac --- /dev/null +++ b/weixin-miniprogram/pages/logs/logs.js @@ -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 + } + }) + }) + } +}) diff --git a/weixin-miniprogram/pages/logs/logs.json b/weixin-miniprogram/pages/logs/logs.json new file mode 100644 index 0000000..3ee76c1 --- /dev/null +++ b/weixin-miniprogram/pages/logs/logs.json @@ -0,0 +1,4 @@ +{ + "navigationBarTitleText": "查看启动日志", + "usingComponents": {} +} \ No newline at end of file diff --git a/weixin-miniprogram/pages/logs/logs.wxml b/weixin-miniprogram/pages/logs/logs.wxml new file mode 100644 index 0000000..0b6b645 --- /dev/null +++ b/weixin-miniprogram/pages/logs/logs.wxml @@ -0,0 +1,6 @@ + + + + {{index + 1}}. {{log.date}} + + diff --git a/weixin-miniprogram/pages/logs/logs.wxss b/weixin-miniprogram/pages/logs/logs.wxss new file mode 100644 index 0000000..94d4b88 --- /dev/null +++ b/weixin-miniprogram/pages/logs/logs.wxss @@ -0,0 +1,8 @@ +.log-list { + display: flex; + flex-direction: column; + padding: 40rpx; +} +.log-item { + margin: 10rpx; +} diff --git a/weixin-miniprogram/pages/person/person.js b/weixin-miniprogram/pages/person/person.js new file mode 100644 index 0000000..e2a57e9 --- /dev/null +++ b/weixin-miniprogram/pages/person/person.js @@ -0,0 +1,66 @@ +// pages/person/person.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/weixin-miniprogram/pages/person/person.json b/weixin-miniprogram/pages/person/person.json new file mode 100644 index 0000000..a905e86 --- /dev/null +++ b/weixin-miniprogram/pages/person/person.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "我" +} \ No newline at end of file diff --git a/weixin-miniprogram/pages/person/person.wxml b/weixin-miniprogram/pages/person/person.wxml new file mode 100644 index 0000000..74f353a --- /dev/null +++ b/weixin-miniprogram/pages/person/person.wxml @@ -0,0 +1,2 @@ + +pages/person/person.wxml diff --git a/weixin-miniprogram/pages/person/person.wxss b/weixin-miniprogram/pages/person/person.wxss new file mode 100644 index 0000000..08f4ce6 --- /dev/null +++ b/weixin-miniprogram/pages/person/person.wxss @@ -0,0 +1 @@ +/* pages/person/person.wxss */ \ No newline at end of file diff --git a/weixin-miniprogram/pages/residents/code.js b/weixin-miniprogram/pages/residents/code.js new file mode 100644 index 0000000..2037260 --- /dev/null +++ b/weixin-miniprogram/pages/residents/code.js @@ -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) + } +}) diff --git a/weixin-miniprogram/pages/residents/code.json b/weixin-miniprogram/pages/residents/code.json new file mode 100644 index 0000000..977af0d --- /dev/null +++ b/weixin-miniprogram/pages/residents/code.json @@ -0,0 +1,5 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "身份码", + "enablePullDownRefresh": true +} \ No newline at end of file diff --git a/weixin-miniprogram/pages/residents/code.wxml b/weixin-miniprogram/pages/residents/code.wxml new file mode 100644 index 0000000..f30bf41 --- /dev/null +++ b/weixin-miniprogram/pages/residents/code.wxml @@ -0,0 +1,10 @@ + + + {{ userText }} + {{ time }} + + {{ showText }} + 下拉可刷新 + + + \ No newline at end of file diff --git a/weixin-miniprogram/pages/residents/code.wxss b/weixin-miniprogram/pages/residents/code.wxss new file mode 100644 index 0000000..29d2ac1 --- /dev/null +++ b/weixin-miniprogram/pages/residents/code.wxss @@ -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; +} diff --git a/weixin-miniprogram/pages/residents/report.js b/weixin-miniprogram/pages/residents/report.js new file mode 100644 index 0000000..2c59051 --- /dev/null +++ b/weixin-miniprogram/pages/residents/report.js @@ -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" + }) + } +}) diff --git a/weixin-miniprogram/pages/residents/report.json b/weixin-miniprogram/pages/residents/report.json new file mode 100644 index 0000000..b47f39b --- /dev/null +++ b/weixin-miniprogram/pages/residents/report.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "体温上报" +} \ No newline at end of file diff --git a/weixin-miniprogram/pages/residents/report.wxml b/weixin-miniprogram/pages/residents/report.wxml new file mode 100644 index 0000000..63c43a4 --- /dev/null +++ b/weixin-miniprogram/pages/residents/report.wxml @@ -0,0 +1,59 @@ + + + + + + 姓名 + + + + + + + + + 填报时间 + + + + + + + + + 地址 + + + + + + + + + 今日体温 + + + + 正常 + 异常(≥37.3°) + + + + + + + * 本人承诺以上所填报的内容全部真实,并愿意承担相应责任。 + + + + + + + + + + + {{ filledMsg }} + + + \ No newline at end of file diff --git a/weixin-miniprogram/pages/residents/report.wxss b/weixin-miniprogram/pages/residents/report.wxss new file mode 100644 index 0000000..82bee9e --- /dev/null +++ b/weixin-miniprogram/pages/residents/report.wxss @@ -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; +} diff --git a/weixin-miniprogram/pages/residents/reportHistory.js b/weixin-miniprogram/pages/residents/reportHistory.js new file mode 100644 index 0000000..0d803c9 --- /dev/null +++ b/weixin-miniprogram/pages/residents/reportHistory.js @@ -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() { + + } +}) diff --git a/weixin-miniprogram/pages/residents/reportHistory.json b/weixin-miniprogram/pages/residents/reportHistory.json new file mode 100644 index 0000000..69c52cb --- /dev/null +++ b/weixin-miniprogram/pages/residents/reportHistory.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "体温上报 - 历史记录" +} \ No newline at end of file diff --git a/weixin-miniprogram/pages/residents/reportHistory.wxml b/weixin-miniprogram/pages/residents/reportHistory.wxml new file mode 100644 index 0000000..064f650 --- /dev/null +++ b/weixin-miniprogram/pages/residents/reportHistory.wxml @@ -0,0 +1,21 @@ + + + + 姓名:{{ displayName }} + + + + + + + {{ item.time }} + + + + {{ item.address }} + + + {{ item.temperature == 1 ? "异常" : "正常" }} + + + \ No newline at end of file diff --git a/weixin-miniprogram/pages/residents/reportHistory.wxss b/weixin-miniprogram/pages/residents/reportHistory.wxss new file mode 100644 index 0000000..ac45398 --- /dev/null +++ b/weixin-miniprogram/pages/residents/reportHistory.wxss @@ -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; +} diff --git a/weixin-miniprogram/pages/scan/entrance.js b/weixin-miniprogram/pages/scan/entrance.js new file mode 100644 index 0000000..74fc986 --- /dev/null +++ b/weixin-miniprogram/pages/scan/entrance.js @@ -0,0 +1,66 @@ +// pages/scan/entrance.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + } +}) \ No newline at end of file diff --git a/weixin-miniprogram/pages/scan/entrance.json b/weixin-miniprogram/pages/scan/entrance.json new file mode 100644 index 0000000..99da1f6 --- /dev/null +++ b/weixin-miniprogram/pages/scan/entrance.json @@ -0,0 +1,4 @@ +{ + "usingComponents": {}, + "navigationBarTitleText": "进入社区" +} \ No newline at end of file diff --git a/weixin-miniprogram/pages/scan/entrance.wxml b/weixin-miniprogram/pages/scan/entrance.wxml new file mode 100644 index 0000000..e68bd82 --- /dev/null +++ b/weixin-miniprogram/pages/scan/entrance.wxml @@ -0,0 +1,4 @@ + + + 您将要进入社区 + \ No newline at end of file diff --git a/weixin-miniprogram/pages/scan/entrance.wxss b/weixin-miniprogram/pages/scan/entrance.wxss new file mode 100644 index 0000000..55cba94 --- /dev/null +++ b/weixin-miniprogram/pages/scan/entrance.wxss @@ -0,0 +1 @@ +/* pages/scan/entrance.wxss */ \ No newline at end of file diff --git a/weixin-miniprogram/project.config.json b/weixin-miniprogram/project.config.json new file mode 100644 index 0000000..870fdaf --- /dev/null +++ b/weixin-miniprogram/project.config.json @@ -0,0 +1,51 @@ +{ + "description": "项目配置文件", + "packOptions": { + "ignore": [], + "include": [] + }, + "setting": { + "bundle": false, + "userConfirmedBundleSwitch": false, + "urlCheck": true, + "scopeDataCheck": false, + "coverView": true, + "es6": true, + "postcss": true, + "compileHotReLoad": false, + "lazyloadPlaceholderEnable": false, + "preloadBackgroundData": false, + "minified": true, + "autoAudits": false, + "newFeature": false, + "uglifyFileName": false, + "uploadWithSourceMap": true, + "useIsolateContext": true, + "nodeModules": false, + "enhance": true, + "useMultiFrameRuntime": true, + "useApiHook": true, + "useApiHostProcess": true, + "showShadowRootInWxmlPanel": true, + "packNpmManually": false, + "enableEngineNative": false, + "packNpmRelationList": [], + "minifyWXSS": true, + "showES6CompileOption": false, + "minifyWXML": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + } + }, + "compileType": "miniprogram", + "libVersion": "2.19.4", + "appid": "wx332e2e578f09873a", + "projectname": "miniprogram-92", + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 2 + } +} \ No newline at end of file diff --git a/weixin-miniprogram/project.private.config.json b/weixin-miniprogram/project.private.config.json new file mode 100644 index 0000000..683c479 --- /dev/null +++ b/weixin-miniprogram/project.private.config.json @@ -0,0 +1,8 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "weixin-miniprogram", + "setting": { + "compileHotReLoad": false, + "urlCheck": false + } +} \ No newline at end of file diff --git a/weixin-miniprogram/sitemap.json b/weixin-miniprogram/sitemap.json new file mode 100644 index 0000000..ca02add --- /dev/null +++ b/weixin-miniprogram/sitemap.json @@ -0,0 +1,7 @@ +{ + "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", + "rules": [{ + "action": "allow", + "page": "*" + }] +} \ No newline at end of file diff --git a/weixin-miniprogram/utils/const.js b/weixin-miniprogram/utils/const.js new file mode 100644 index 0000000..b093d86 --- /dev/null +++ b/weixin-miniprogram/utils/const.js @@ -0,0 +1,12 @@ +module.exports = { + user: { + role: { + ADMIN: 0, + STAFF: 1, + RESIDENTS_OWNER: 2, + RESIDENTS_MEMBER: 3, + RESIDENTS_TENENT: 4, + VISITOR: 5 + } + } +} diff --git a/weixin-miniprogram/utils/getUserGroupByRole.js b/weixin-miniprogram/utils/getUserGroupByRole.js new file mode 100644 index 0000000..cd39b00 --- /dev/null +++ b/weixin-miniprogram/utils/getUserGroupByRole.js @@ -0,0 +1,29 @@ +const ENUM = require('./const.js'); + +function getUserGroupByRole(userRole) { + const role = ENUM.user.role; + userRole = Number(userRole); + let userGroupDict = { + 'visitor': [ + role.VISITOR, + ].includes(userRole), + 'user': [ + role.RESIDENTS_OWNER, + role.RESIDENTS_MEMBER, + role.RESIDENTS_TENENT, + ].includes(userRole), + 'admin': [ + role.ADMIN, + role.STAFF, + ].includes(userRole) + } + console.log("userGroupDict", userGroupDict, userRole, role) + for (let userGroup of Object.keys(userGroupDict)) { + if (userGroupDict[userGroup]) { + return userGroup; + } + } + return 'unknown'; +} + +module.exports = getUserGroupByRole; diff --git a/weixin-miniprogram/utils/menuList.js b/weixin-miniprogram/utils/menuList.js new file mode 100644 index 0000000..f07019c --- /dev/null +++ b/weixin-miniprogram/utils/menuList.js @@ -0,0 +1,104 @@ +const switchTab = "switchTab"; +const navigateTo = "navigateTo"; +let id = 0; + +let menuItemDict = { + 'login': { + for: ['unknown'], + title: "登录", + image: "code.png", + switchFunc: switchTab, + url: '/pages/index/login', + }, + 'code': { + for: ['visitor', 'user'], + title: "进出码", + image: "code.png", + switchFunc: switchTab, + url: '/pages/residents/code' + }, + 'report': { + for: ['user'], + title: "体温上报", + image: "report.png", + switchFunc: switchTab, + url: '/pages/residents/report' + }, + 'apply-record': { + for: ['visitor', 'user'], + title: "申请记录", + image: "apply.png", + switchFunc: switchTab, + url: '' + }, + 'apply-approval': { + for: ['admin'], + title: "申请审批", + image: "apply.png", // ApplyReplay + switchFunc: switchTab, + url: '' + }, + 'visitor-apply': { + for: ['admin'], + title: "访客审批", + image: "visitor.png", + switchFunc: switchTab, + url: '' + }, + 'abnormal': { + for: ['admin'], + title: "异常人员", + image: "danger.png", + switchFunc: switchTab, + url: '' + }, + 'feedback-submit': { + for: ['visitor', 'user'], + title: "提交反馈", + image: "fk.png", + switchFunc: switchTab, + url: '' + }, + 'feedback-list': { + for: ['visitor', 'user'], + title: "反馈查看", + image: "feedback.png", + switchFunc: switchTab, + url: '' + }, + 'feedback-reply': { + for: ['admin'], + title: "反馈回复", + image: "feedback.png", + switchFunc: switchTab, + url: '' + }, + 'update-password': { + for: ['user', 'admin'], + title: "密码修改", + image: "updPwd.png", + switchFunc: switchTab, + url: '' + }, + 'assign': { + for: ['admin'], + title: "分配账号", + image: "count.png", + switchFunc: switchTab, + url: '' + }, + 'unfinish': { + for: ['admin'], + title: "今日未填", // RedList + image: "_report.png", + switchFunc: switchTab, + url: '' + } +} +let keys = Object.keys(menuItemDict); +for (let key of keys) { + menuItemDict[key].id = id++; + menuItemDict[key].addDot = false; +} + +module.exports = menuItemDict diff --git a/weixin-miniprogram/utils/qrcode/index.js b/weixin-miniprogram/utils/qrcode/index.js new file mode 100644 index 0000000..2978bd2 --- /dev/null +++ b/weixin-miniprogram/utils/qrcode/index.js @@ -0,0 +1,128 @@ +// import extend from 'extend' +import { + QRCode, + QRErrorCorrectLevel +} from './qrcode' + +// support Chinese +function utf16to8(str) { + var out, i, len, c + out = '' + len = str.length + for (i = 0; i < len; i++) { + c = str.charCodeAt(i) + if ((c >= 0x0001) && (c <= 0x007F)) { + out += str.charAt(i) + } else if (c > 0x07FF) { + out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F)) + out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F)) + out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)) + } else { + out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F)) + out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F)) + } + } + return out +} + +function drawQrcode(Taro, opt) { + let defaultOpt = { + canvasId: 'myQrcode', + canvas: null, + text: '爱一个人就要勇敢说出来', + width: 260, + padding: 20, + paddingColor: null, // 默认与background一致 + typeNumber: -1, + correctLevel: QRErrorCorrectLevel.H, + background: '#ffffff', + foreground: '#000000', + image: { + imageResource: '', + width: 80, + height: 80, + round: true + } + } + let options = defaultOpt + for (let key in opt) { + options[key] = opt[key] + } + + if (!options.canvasId && !options.canvas) { + console.warn('please set canvasId or canvas!') + return + } + + if (!options.paddingColor) options.paddingColor = options.background + + // createCanvas + // create the qrcode itself + var qrcode = new QRCode(options.typeNumber, options.correctLevel) + qrcode.addData(utf16to8(options.text)) + qrcode.make() + + const dpr = Taro.getSystemInfoSync().pixelRatio + var canvas = options.canvas + const ctx = canvas.getContext('2d') + canvas.width = options.width * dpr + canvas.height = options.width * dpr + const width = canvas.width + console.log(`canvas, ctx, width, dpr, qrcode, options`, canvas, ctx, width, dpr, qrcode, options) + + // 填充背景色 + ctx.fillStyle = options.paddingColor + // ctx.clearRect(0, 0, width + options.padding * 2, width + options.padding * 2) // 绘制前清空画布 + ctx.fillRect(0, 0, width + options.padding * 2, width + options.padding * 2); + + var tileW = (width - options.padding * 2) / qrcode.getModuleCount() + var tileH = (width - options.padding * 2) / qrcode.getModuleCount() + + // 绘制二维码 + for (var row = 0; row < qrcode.getModuleCount(); row++) { + for (var col = 0; col < qrcode.getModuleCount(); col++) { + ctx.fillStyle = qrcode.isDark(row, col) ? options.foreground : options.background + var w = (Math.ceil((col + 1) * tileW) - Math.floor(col * tileW)) + var h = (Math.ceil((row + 1) * tileW) - Math.floor(row * tileW)) + ctx.fillRect(Math.round(col * tileW) + options.padding, Math.round(row * tileH) + options.padding, w, h); + } + } + + // 绘制中心图标 + if (options.image.imageResource) { + const imgW = options.image.width * dpr + const imgH = options.image.height * dpr + const dx = (width - imgW) / 2 + const dy = (width - imgH) / 2 + if (options.image.round) { + // Logo边框 + const imgW2 = options.image.width * dpr + 30 + const dx2 = (width - imgW2) / 2 + const r2 = imgW2 / 2 + const cx2 = dx2 + r2; + ctx.beginPath(); + ctx.arc(cx2, cx2, r2, 0, 2 * Math.PI); + ctx.fillStyle = '#ffffff' + ctx.fill(); + ctx.restore(); + + // 画Logo + const r = imgW / 2 + const cx = dx + r; + const cy = dy + r; + ctx.beginPath(); + ctx.arc(cx, cy, r, 0, 2 * Math.PI); + ctx.clip(); + + ctx.drawImage(options.image.imageResource, dx, dy, imgW, imgW); + ctx.restore(); + } else { + ctx.drawImage(options.image.imageResource, dx, dy, imgW, imgH) + ctx.restore(); + } + } + + return ctx +} + +export default drawQrcode diff --git a/weixin-miniprogram/utils/qrcode/qrcode.js b/weixin-miniprogram/utils/qrcode/qrcode.js new file mode 100644 index 0000000..3289c78 --- /dev/null +++ b/weixin-miniprogram/utils/qrcode/qrcode.js @@ -0,0 +1,1242 @@ +//--------------------------------------------------------------------- +// QRCode for JavaScript +// +// Copyright (c) 2009 Kazuhiko Arase +// +// URL: http://www.d-project.com/ +// +// Licensed under the MIT license: +// http://www.opensource.org/licenses/mit-license.php +// +// The word "QR Code" is registered trademark of +// DENSO WAVE INCORPORATED +// http://www.denso-wave.com/qrcode/faqpatent-e.html +// +//--------------------------------------------------------------------- + +//--------------------------------------------------------------------- +// QR8bitByte +//--------------------------------------------------------------------- + +function QR8bitByte(data) { + this.mode = QRMode.MODE_8BIT_BYTE; + this.data = data; +} + +QR8bitByte.prototype = { + + getLength : function(buffer) { + return this.data.length; + }, + + write : function(buffer) { + for (var i = 0; i < this.data.length; i++) { + // not JIS ... + buffer.put(this.data.charCodeAt(i), 8); + } + } +}; + +//--------------------------------------------------------------------- +// QRCode +//--------------------------------------------------------------------- + +function QRCode(typeNumber, errorCorrectLevel) { + this.typeNumber = typeNumber; + this.errorCorrectLevel = errorCorrectLevel; + this.modules = null; + this.moduleCount = 0; + this.dataCache = null; + this.dataList = new Array(); +} + +QRCode.prototype = { + + addData : function(data) { + var newData = new QR8bitByte(data); + this.dataList.push(newData); + this.dataCache = null; + }, + + isDark : function(row, col) { + if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) { + throw new Error(row + "," + col); + } + return this.modules[row][col]; + }, + + getModuleCount : function() { + return this.moduleCount; + }, + + make : function() { + // Calculate automatically typeNumber if provided is < 1 + if (this.typeNumber < 1 ){ + var typeNumber = 1; + for (typeNumber = 1; typeNumber < 40; typeNumber++) { + var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, this.errorCorrectLevel); + + var buffer = new QRBitBuffer(); + var totalDataCount = 0; + for (var i = 0; i < rsBlocks.length; i++) { + totalDataCount += rsBlocks[i].dataCount; + } + + for (var i = 0; i < this.dataList.length; i++) { + var data = this.dataList[i]; + buffer.put(data.mode, 4); + buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber) ); + data.write(buffer); + } + if (buffer.getLengthInBits() <= totalDataCount * 8) + break; + } + this.typeNumber = typeNumber; + } + this.makeImpl(false, this.getBestMaskPattern() ); + }, + + makeImpl : function(test, maskPattern) { + + this.moduleCount = this.typeNumber * 4 + 17; + this.modules = new Array(this.moduleCount); + + for (var row = 0; row < this.moduleCount; row++) { + + this.modules[row] = new Array(this.moduleCount); + + for (var col = 0; col < this.moduleCount; col++) { + this.modules[row][col] = null;//(col + row) % 3; + } + } + + this.setupPositionProbePattern(0, 0); + this.setupPositionProbePattern(this.moduleCount - 7, 0); + this.setupPositionProbePattern(0, this.moduleCount - 7); + this.setupPositionAdjustPattern(); + this.setupTimingPattern(); + this.setupTypeInfo(test, maskPattern); + + if (this.typeNumber >= 7) { + this.setupTypeNumber(test); + } + + if (this.dataCache == null) { + this.dataCache = QRCode.createData(this.typeNumber, this.errorCorrectLevel, this.dataList); + } + + this.mapData(this.dataCache, maskPattern); + }, + + setupPositionProbePattern : function(row, col) { + + for (var r = -1; r <= 7; r++) { + + if (row + r <= -1 || this.moduleCount <= row + r) continue; + + for (var c = -1; c <= 7; c++) { + + if (col + c <= -1 || this.moduleCount <= col + c) continue; + + if ( (0 <= r && r <= 6 && (c == 0 || c == 6) ) + || (0 <= c && c <= 6 && (r == 0 || r == 6) ) + || (2 <= r && r <= 4 && 2 <= c && c <= 4) ) { + this.modules[row + r][col + c] = true; + } else { + this.modules[row + r][col + c] = false; + } + } + } + }, + + getBestMaskPattern : function() { + + var minLostPoint = 0; + var pattern = 0; + + for (var i = 0; i < 8; i++) { + + this.makeImpl(true, i); + + var lostPoint = QRUtil.getLostPoint(this); + + if (i == 0 || minLostPoint > lostPoint) { + minLostPoint = lostPoint; + pattern = i; + } + } + + return pattern; + }, + + createMovieClip : function(target_mc, instance_name, depth) { + + var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth); + var cs = 1; + + this.make(); + + for (var row = 0; row < this.modules.length; row++) { + + var y = row * cs; + + for (var col = 0; col < this.modules[row].length; col++) { + + var x = col * cs; + var dark = this.modules[row][col]; + + if (dark) { + qr_mc.beginFill(0, 100); + qr_mc.moveTo(x, y); + qr_mc.lineTo(x + cs, y); + qr_mc.lineTo(x + cs, y + cs); + qr_mc.lineTo(x, y + cs); + qr_mc.endFill(); + } + } + } + + return qr_mc; + }, + + setupTimingPattern : function() { + + for (var r = 8; r < this.moduleCount - 8; r++) { + if (this.modules[r][6] != null) { + continue; + } + this.modules[r][6] = (r % 2 == 0); + } + + for (var c = 8; c < this.moduleCount - 8; c++) { + if (this.modules[6][c] != null) { + continue; + } + this.modules[6][c] = (c % 2 == 0); + } + }, + + setupPositionAdjustPattern : function() { + + var pos = QRUtil.getPatternPosition(this.typeNumber); + + for (var i = 0; i < pos.length; i++) { + + for (var j = 0; j < pos.length; j++) { + + var row = pos[i]; + var col = pos[j]; + + if (this.modules[row][col] != null) { + continue; + } + + for (var r = -2; r <= 2; r++) { + + for (var c = -2; c <= 2; c++) { + + if (r == -2 || r == 2 || c == -2 || c == 2 + || (r == 0 && c == 0) ) { + this.modules[row + r][col + c] = true; + } else { + this.modules[row + r][col + c] = false; + } + } + } + } + } + }, + + setupTypeNumber : function(test) { + + var bits = QRUtil.getBCHTypeNumber(this.typeNumber); + + for (var i = 0; i < 18; i++) { + var mod = (!test && ( (bits >> i) & 1) == 1); + this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod; + } + + for (var i = 0; i < 18; i++) { + var mod = (!test && ( (bits >> i) & 1) == 1); + this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod; + } + }, + + setupTypeInfo : function(test, maskPattern) { + + var data = (this.errorCorrectLevel << 3) | maskPattern; + var bits = QRUtil.getBCHTypeInfo(data); + + // vertical + for (var i = 0; i < 15; i++) { + + var mod = (!test && ( (bits >> i) & 1) == 1); + + if (i < 6) { + this.modules[i][8] = mod; + } else if (i < 8) { + this.modules[i + 1][8] = mod; + } else { + this.modules[this.moduleCount - 15 + i][8] = mod; + } + } + + // horizontal + for (var i = 0; i < 15; i++) { + + var mod = (!test && ( (bits >> i) & 1) == 1); + + if (i < 8) { + this.modules[8][this.moduleCount - i - 1] = mod; + } else if (i < 9) { + this.modules[8][15 - i - 1 + 1] = mod; + } else { + this.modules[8][15 - i - 1] = mod; + } + } + + // fixed module + this.modules[this.moduleCount - 8][8] = (!test); + + }, + + mapData : function(data, maskPattern) { + + var inc = -1; + var row = this.moduleCount - 1; + var bitIndex = 7; + var byteIndex = 0; + + for (var col = this.moduleCount - 1; col > 0; col -= 2) { + + if (col == 6) col--; + + while (true) { + + for (var c = 0; c < 2; c++) { + + if (this.modules[row][col - c] == null) { + + var dark = false; + + if (byteIndex < data.length) { + dark = ( ( (data[byteIndex] >>> bitIndex) & 1) == 1); + } + + var mask = QRUtil.getMask(maskPattern, row, col - c); + + if (mask) { + dark = !dark; + } + + this.modules[row][col - c] = dark; + bitIndex--; + + if (bitIndex == -1) { + byteIndex++; + bitIndex = 7; + } + } + } + + row += inc; + + if (row < 0 || this.moduleCount <= row) { + row -= inc; + inc = -inc; + break; + } + } + } + + } + +}; + +QRCode.PAD0 = 0xEC; +QRCode.PAD1 = 0x11; + +QRCode.createData = function(typeNumber, errorCorrectLevel, dataList) { + + var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel); + + var buffer = new QRBitBuffer(); + + for (var i = 0; i < dataList.length; i++) { + var data = dataList[i]; + buffer.put(data.mode, 4); + buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber) ); + data.write(buffer); + } + + // calc num max data. + var totalDataCount = 0; + for (var i = 0; i < rsBlocks.length; i++) { + totalDataCount += rsBlocks[i].dataCount; + } + + if (buffer.getLengthInBits() > totalDataCount * 8) { + throw new Error("code length overflow. (" + + buffer.getLengthInBits() + + ">" + + totalDataCount * 8 + + ")"); + } + + // end code + if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) { + buffer.put(0, 4); + } + + // padding + while (buffer.getLengthInBits() % 8 != 0) { + buffer.putBit(false); + } + + // padding + while (true) { + + if (buffer.getLengthInBits() >= totalDataCount * 8) { + break; + } + buffer.put(QRCode.PAD0, 8); + + if (buffer.getLengthInBits() >= totalDataCount * 8) { + break; + } + buffer.put(QRCode.PAD1, 8); + } + + return QRCode.createBytes(buffer, rsBlocks); +} + +QRCode.createBytes = function(buffer, rsBlocks) { + + var offset = 0; + + var maxDcCount = 0; + var maxEcCount = 0; + + var dcdata = new Array(rsBlocks.length); + var ecdata = new Array(rsBlocks.length); + + for (var r = 0; r < rsBlocks.length; r++) { + + var dcCount = rsBlocks[r].dataCount; + var ecCount = rsBlocks[r].totalCount - dcCount; + + maxDcCount = Math.max(maxDcCount, dcCount); + maxEcCount = Math.max(maxEcCount, ecCount); + + dcdata[r] = new Array(dcCount); + + for (var i = 0; i < dcdata[r].length; i++) { + dcdata[r][i] = 0xff & buffer.buffer[i + offset]; + } + offset += dcCount; + + var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount); + var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1); + + var modPoly = rawPoly.mod(rsPoly); + ecdata[r] = new Array(rsPoly.getLength() - 1); + for (var i = 0; i < ecdata[r].length; i++) { + var modIndex = i + modPoly.getLength() - ecdata[r].length; + ecdata[r][i] = (modIndex >= 0)? modPoly.get(modIndex) : 0; + } + + } + + var totalCodeCount = 0; + for (var i = 0; i < rsBlocks.length; i++) { + totalCodeCount += rsBlocks[i].totalCount; + } + + var data = new Array(totalCodeCount); + var index = 0; + + for (var i = 0; i < maxDcCount; i++) { + for (var r = 0; r < rsBlocks.length; r++) { + if (i < dcdata[r].length) { + data[index++] = dcdata[r][i]; + } + } + } + + for (var i = 0; i < maxEcCount; i++) { + for (var r = 0; r < rsBlocks.length; r++) { + if (i < ecdata[r].length) { + data[index++] = ecdata[r][i]; + } + } + } + + return data; + +} + +//--------------------------------------------------------------------- +// QRMode +//--------------------------------------------------------------------- + +var QRMode = { + MODE_NUMBER : 1 << 0, + MODE_ALPHA_NUM : 1 << 1, + MODE_8BIT_BYTE : 1 << 2, + MODE_KANJI : 1 << 3 +}; + +//--------------------------------------------------------------------- +// QRErrorCorrectLevel +//--------------------------------------------------------------------- + +var QRErrorCorrectLevel = { + L : 1, + M : 0, + Q : 3, + H : 2 +}; + +//--------------------------------------------------------------------- +// QRMaskPattern +//--------------------------------------------------------------------- + +var QRMaskPattern = { + PATTERN000 : 0, + PATTERN001 : 1, + PATTERN010 : 2, + PATTERN011 : 3, + PATTERN100 : 4, + PATTERN101 : 5, + PATTERN110 : 6, + PATTERN111 : 7 +}; + +//--------------------------------------------------------------------- +// QRUtil +//--------------------------------------------------------------------- + +var QRUtil = { + + PATTERN_POSITION_TABLE : [ + [], + [6, 18], + [6, 22], + [6, 26], + [6, 30], + [6, 34], + [6, 22, 38], + [6, 24, 42], + [6, 26, 46], + [6, 28, 50], + [6, 30, 54], + [6, 32, 58], + [6, 34, 62], + [6, 26, 46, 66], + [6, 26, 48, 70], + [6, 26, 50, 74], + [6, 30, 54, 78], + [6, 30, 56, 82], + [6, 30, 58, 86], + [6, 34, 62, 90], + [6, 28, 50, 72, 94], + [6, 26, 50, 74, 98], + [6, 30, 54, 78, 102], + [6, 28, 54, 80, 106], + [6, 32, 58, 84, 110], + [6, 30, 58, 86, 114], + [6, 34, 62, 90, 118], + [6, 26, 50, 74, 98, 122], + [6, 30, 54, 78, 102, 126], + [6, 26, 52, 78, 104, 130], + [6, 30, 56, 82, 108, 134], + [6, 34, 60, 86, 112, 138], + [6, 30, 58, 86, 114, 142], + [6, 34, 62, 90, 118, 146], + [6, 30, 54, 78, 102, 126, 150], + [6, 24, 50, 76, 102, 128, 154], + [6, 28, 54, 80, 106, 132, 158], + [6, 32, 58, 84, 110, 136, 162], + [6, 26, 54, 82, 110, 138, 166], + [6, 30, 58, 86, 114, 142, 170] + ], + + G15 : (1 << 10) | (1 << 8) | (1 << 5) | (1 << 4) | (1 << 2) | (1 << 1) | (1 << 0), + G18 : (1 << 12) | (1 << 11) | (1 << 10) | (1 << 9) | (1 << 8) | (1 << 5) | (1 << 2) | (1 << 0), + G15_MASK : (1 << 14) | (1 << 12) | (1 << 10) | (1 << 4) | (1 << 1), + + getBCHTypeInfo : function(data) { + var d = data << 10; + while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) { + d ^= (QRUtil.G15 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) ) ); + } + return ( (data << 10) | d) ^ QRUtil.G15_MASK; + }, + + getBCHTypeNumber : function(data) { + var d = data << 12; + while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) { + d ^= (QRUtil.G18 << (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) ) ); + } + return (data << 12) | d; + }, + + getBCHDigit : function(data) { + + var digit = 0; + + while (data != 0) { + digit++; + data >>>= 1; + } + + return digit; + }, + + getPatternPosition : function(typeNumber) { + return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1]; + }, + + getMask : function(maskPattern, i, j) { + + switch (maskPattern) { + + case QRMaskPattern.PATTERN000 : return (i + j) % 2 == 0; + case QRMaskPattern.PATTERN001 : return i % 2 == 0; + case QRMaskPattern.PATTERN010 : return j % 3 == 0; + case QRMaskPattern.PATTERN011 : return (i + j) % 3 == 0; + case QRMaskPattern.PATTERN100 : return (Math.floor(i / 2) + Math.floor(j / 3) ) % 2 == 0; + case QRMaskPattern.PATTERN101 : return (i * j) % 2 + (i * j) % 3 == 0; + case QRMaskPattern.PATTERN110 : return ( (i * j) % 2 + (i * j) % 3) % 2 == 0; + case QRMaskPattern.PATTERN111 : return ( (i * j) % 3 + (i + j) % 2) % 2 == 0; + + default : + throw new Error("bad maskPattern:" + maskPattern); + } + }, + + getErrorCorrectPolynomial : function(errorCorrectLength) { + + var a = new QRPolynomial([1], 0); + + for (var i = 0; i < errorCorrectLength; i++) { + a = a.multiply(new QRPolynomial([1, QRMath.gexp(i)], 0) ); + } + + return a; + }, + + getLengthInBits : function(mode, type) { + + if (1 <= type && type < 10) { + + // 1 - 9 + + switch(mode) { + case QRMode.MODE_NUMBER : return 10; + case QRMode.MODE_ALPHA_NUM : return 9; + case QRMode.MODE_8BIT_BYTE : return 8; + case QRMode.MODE_KANJI : return 8; + default : + throw new Error("mode:" + mode); + } + + } else if (type < 27) { + + // 10 - 26 + + switch(mode) { + case QRMode.MODE_NUMBER : return 12; + case QRMode.MODE_ALPHA_NUM : return 11; + case QRMode.MODE_8BIT_BYTE : return 16; + case QRMode.MODE_KANJI : return 10; + default : + throw new Error("mode:" + mode); + } + + } else if (type < 41) { + + // 27 - 40 + + switch(mode) { + case QRMode.MODE_NUMBER : return 14; + case QRMode.MODE_ALPHA_NUM : return 13; + case QRMode.MODE_8BIT_BYTE : return 16; + case QRMode.MODE_KANJI : return 12; + default : + throw new Error("mode:" + mode); + } + + } else { + throw new Error("type:" + type); + } + }, + + getLostPoint : function(qrCode) { + + var moduleCount = qrCode.getModuleCount(); + + var lostPoint = 0; + + // LEVEL1 + + for (var row = 0; row < moduleCount; row++) { + + for (var col = 0; col < moduleCount; col++) { + + var sameCount = 0; + var dark = qrCode.isDark(row, col); + + for (var r = -1; r <= 1; r++) { + + if (row + r < 0 || moduleCount <= row + r) { + continue; + } + + for (var c = -1; c <= 1; c++) { + + if (col + c < 0 || moduleCount <= col + c) { + continue; + } + + if (r == 0 && c == 0) { + continue; + } + + if (dark == qrCode.isDark(row + r, col + c) ) { + sameCount++; + } + } + } + + if (sameCount > 5) { + lostPoint += (3 + sameCount - 5); + } + } + } + + // LEVEL2 + + for (var row = 0; row < moduleCount - 1; row++) { + for (var col = 0; col < moduleCount - 1; col++) { + var count = 0; + if (qrCode.isDark(row, col ) ) count++; + if (qrCode.isDark(row + 1, col ) ) count++; + if (qrCode.isDark(row, col + 1) ) count++; + if (qrCode.isDark(row + 1, col + 1) ) count++; + if (count == 0 || count == 4) { + lostPoint += 3; + } + } + } + + // LEVEL3 + + for (var row = 0; row < moduleCount; row++) { + for (var col = 0; col < moduleCount - 6; col++) { + if (qrCode.isDark(row, col) + && !qrCode.isDark(row, col + 1) + && qrCode.isDark(row, col + 2) + && qrCode.isDark(row, col + 3) + && qrCode.isDark(row, col + 4) + && !qrCode.isDark(row, col + 5) + && qrCode.isDark(row, col + 6) ) { + lostPoint += 40; + } + } + } + + for (var col = 0; col < moduleCount; col++) { + for (var row = 0; row < moduleCount - 6; row++) { + if (qrCode.isDark(row, col) + && !qrCode.isDark(row + 1, col) + && qrCode.isDark(row + 2, col) + && qrCode.isDark(row + 3, col) + && qrCode.isDark(row + 4, col) + && !qrCode.isDark(row + 5, col) + && qrCode.isDark(row + 6, col) ) { + lostPoint += 40; + } + } + } + + // LEVEL4 + + var darkCount = 0; + + for (var col = 0; col < moduleCount; col++) { + for (var row = 0; row < moduleCount; row++) { + if (qrCode.isDark(row, col) ) { + darkCount++; + } + } + } + + var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5; + lostPoint += ratio * 10; + + return lostPoint; + } + +}; + + +//--------------------------------------------------------------------- +// QRMath +//--------------------------------------------------------------------- + +var QRMath = { + + glog : function(n) { + + if (n < 1) { + throw new Error("glog(" + n + ")"); + } + + return QRMath.LOG_TABLE[n]; + }, + + gexp : function(n) { + + while (n < 0) { + n += 255; + } + + while (n >= 256) { + n -= 255; + } + + return QRMath.EXP_TABLE[n]; + }, + + EXP_TABLE : new Array(256), + + LOG_TABLE : new Array(256) + +}; + +for (var i = 0; i < 8; i++) { + QRMath.EXP_TABLE[i] = 1 << i; +} +for (var i = 8; i < 256; i++) { + QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] + ^ QRMath.EXP_TABLE[i - 5] + ^ QRMath.EXP_TABLE[i - 6] + ^ QRMath.EXP_TABLE[i - 8]; +} +for (var i = 0; i < 255; i++) { + QRMath.LOG_TABLE[QRMath.EXP_TABLE[i] ] = i; +} + +//--------------------------------------------------------------------- +// QRPolynomial +//--------------------------------------------------------------------- + +function QRPolynomial(num, shift) { + + if (num.length == undefined) { + throw new Error(num.length + "/" + shift); + } + + var offset = 0; + + while (offset < num.length && num[offset] == 0) { + offset++; + } + + this.num = new Array(num.length - offset + shift); + for (var i = 0; i < num.length - offset; i++) { + this.num[i] = num[i + offset]; + } +} + +QRPolynomial.prototype = { + + get : function(index) { + return this.num[index]; + }, + + getLength : function() { + return this.num.length; + }, + + multiply : function(e) { + + var num = new Array(this.getLength() + e.getLength() - 1); + + for (var i = 0; i < this.getLength(); i++) { + for (var j = 0; j < e.getLength(); j++) { + num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i) ) + QRMath.glog(e.get(j) ) ); + } + } + + return new QRPolynomial(num, 0); + }, + + mod : function(e) { + + if (this.getLength() - e.getLength() < 0) { + return this; + } + + var ratio = QRMath.glog(this.get(0) ) - QRMath.glog(e.get(0) ); + + var num = new Array(this.getLength() ); + + for (var i = 0; i < this.getLength(); i++) { + num[i] = this.get(i); + } + + for (var i = 0; i < e.getLength(); i++) { + num[i] ^= QRMath.gexp(QRMath.glog(e.get(i) ) + ratio); + } + + // recursive call + return new QRPolynomial(num, 0).mod(e); + } +}; + +//--------------------------------------------------------------------- +// QRRSBlock +//--------------------------------------------------------------------- + +function QRRSBlock(totalCount, dataCount) { + this.totalCount = totalCount; + this.dataCount = dataCount; +} + +QRRSBlock.RS_BLOCK_TABLE = [ + + // L + // M + // Q + // H + + // 1 + [1, 26, 19], + [1, 26, 16], + [1, 26, 13], + [1, 26, 9], + + // 2 + [1, 44, 34], + [1, 44, 28], + [1, 44, 22], + [1, 44, 16], + + // 3 + [1, 70, 55], + [1, 70, 44], + [2, 35, 17], + [2, 35, 13], + + // 4 + [1, 100, 80], + [2, 50, 32], + [2, 50, 24], + [4, 25, 9], + + // 5 + [1, 134, 108], + [2, 67, 43], + [2, 33, 15, 2, 34, 16], + [2, 33, 11, 2, 34, 12], + + // 6 + [2, 86, 68], + [4, 43, 27], + [4, 43, 19], + [4, 43, 15], + + // 7 + [2, 98, 78], + [4, 49, 31], + [2, 32, 14, 4, 33, 15], + [4, 39, 13, 1, 40, 14], + + // 8 + [2, 121, 97], + [2, 60, 38, 2, 61, 39], + [4, 40, 18, 2, 41, 19], + [4, 40, 14, 2, 41, 15], + + // 9 + [2, 146, 116], + [3, 58, 36, 2, 59, 37], + [4, 36, 16, 4, 37, 17], + [4, 36, 12, 4, 37, 13], + + // 10 + [2, 86, 68, 2, 87, 69], + [4, 69, 43, 1, 70, 44], + [6, 43, 19, 2, 44, 20], + [6, 43, 15, 2, 44, 16], + + // 11 + [4, 101, 81], + [1, 80, 50, 4, 81, 51], + [4, 50, 22, 4, 51, 23], + [3, 36, 12, 8, 37, 13], + + // 12 + [2, 116, 92, 2, 117, 93], + [6, 58, 36, 2, 59, 37], + [4, 46, 20, 6, 47, 21], + [7, 42, 14, 4, 43, 15], + + // 13 + [4, 133, 107], + [8, 59, 37, 1, 60, 38], + [8, 44, 20, 4, 45, 21], + [12, 33, 11, 4, 34, 12], + + // 14 + [3, 145, 115, 1, 146, 116], + [4, 64, 40, 5, 65, 41], + [11, 36, 16, 5, 37, 17], + [11, 36, 12, 5, 37, 13], + + // 15 + [5, 109, 87, 1, 110, 88], + [5, 65, 41, 5, 66, 42], + [5, 54, 24, 7, 55, 25], + [11, 36, 12], + + // 16 + [5, 122, 98, 1, 123, 99], + [7, 73, 45, 3, 74, 46], + [15, 43, 19, 2, 44, 20], + [3, 45, 15, 13, 46, 16], + + // 17 + [1, 135, 107, 5, 136, 108], + [10, 74, 46, 1, 75, 47], + [1, 50, 22, 15, 51, 23], + [2, 42, 14, 17, 43, 15], + + // 18 + [5, 150, 120, 1, 151, 121], + [9, 69, 43, 4, 70, 44], + [17, 50, 22, 1, 51, 23], + [2, 42, 14, 19, 43, 15], + + // 19 + [3, 141, 113, 4, 142, 114], + [3, 70, 44, 11, 71, 45], + [17, 47, 21, 4, 48, 22], + [9, 39, 13, 16, 40, 14], + + // 20 + [3, 135, 107, 5, 136, 108], + [3, 67, 41, 13, 68, 42], + [15, 54, 24, 5, 55, 25], + [15, 43, 15, 10, 44, 16], + + // 21 + [4, 144, 116, 4, 145, 117], + [17, 68, 42], + [17, 50, 22, 6, 51, 23], + [19, 46, 16, 6, 47, 17], + + // 22 + [2, 139, 111, 7, 140, 112], + [17, 74, 46], + [7, 54, 24, 16, 55, 25], + [34, 37, 13], + + // 23 + [4, 151, 121, 5, 152, 122], + [4, 75, 47, 14, 76, 48], + [11, 54, 24, 14, 55, 25], + [16, 45, 15, 14, 46, 16], + + // 24 + [6, 147, 117, 4, 148, 118], + [6, 73, 45, 14, 74, 46], + [11, 54, 24, 16, 55, 25], + [30, 46, 16, 2, 47, 17], + + // 25 + [8, 132, 106, 4, 133, 107], + [8, 75, 47, 13, 76, 48], + [7, 54, 24, 22, 55, 25], + [22, 45, 15, 13, 46, 16], + + // 26 + [10, 142, 114, 2, 143, 115], + [19, 74, 46, 4, 75, 47], + [28, 50, 22, 6, 51, 23], + [33, 46, 16, 4, 47, 17], + + // 27 + [8, 152, 122, 4, 153, 123], + [22, 73, 45, 3, 74, 46], + [8, 53, 23, 26, 54, 24], + [12, 45, 15, 28, 46, 16], + + // 28 + [3, 147, 117, 10, 148, 118], + [3, 73, 45, 23, 74, 46], + [4, 54, 24, 31, 55, 25], + [11, 45, 15, 31, 46, 16], + + // 29 + [7, 146, 116, 7, 147, 117], + [21, 73, 45, 7, 74, 46], + [1, 53, 23, 37, 54, 24], + [19, 45, 15, 26, 46, 16], + + // 30 + [5, 145, 115, 10, 146, 116], + [19, 75, 47, 10, 76, 48], + [15, 54, 24, 25, 55, 25], + [23, 45, 15, 25, 46, 16], + + // 31 + [13, 145, 115, 3, 146, 116], + [2, 74, 46, 29, 75, 47], + [42, 54, 24, 1, 55, 25], + [23, 45, 15, 28, 46, 16], + + // 32 + [17, 145, 115], + [10, 74, 46, 23, 75, 47], + [10, 54, 24, 35, 55, 25], + [19, 45, 15, 35, 46, 16], + + // 33 + [17, 145, 115, 1, 146, 116], + [14, 74, 46, 21, 75, 47], + [29, 54, 24, 19, 55, 25], + [11, 45, 15, 46, 46, 16], + + // 34 + [13, 145, 115, 6, 146, 116], + [14, 74, 46, 23, 75, 47], + [44, 54, 24, 7, 55, 25], + [59, 46, 16, 1, 47, 17], + + // 35 + [12, 151, 121, 7, 152, 122], + [12, 75, 47, 26, 76, 48], + [39, 54, 24, 14, 55, 25], + [22, 45, 15, 41, 46, 16], + + // 36 + [6, 151, 121, 14, 152, 122], + [6, 75, 47, 34, 76, 48], + [46, 54, 24, 10, 55, 25], + [2, 45, 15, 64, 46, 16], + + // 37 + [17, 152, 122, 4, 153, 123], + [29, 74, 46, 14, 75, 47], + [49, 54, 24, 10, 55, 25], + [24, 45, 15, 46, 46, 16], + + // 38 + [4, 152, 122, 18, 153, 123], + [13, 74, 46, 32, 75, 47], + [48, 54, 24, 14, 55, 25], + [42, 45, 15, 32, 46, 16], + + // 39 + [20, 147, 117, 4, 148, 118], + [40, 75, 47, 7, 76, 48], + [43, 54, 24, 22, 55, 25], + [10, 45, 15, 67, 46, 16], + + // 40 + [19, 148, 118, 6, 149, 119], + [18, 75, 47, 31, 76, 48], + [34, 54, 24, 34, 55, 25], + [20, 45, 15, 61, 46, 16] +]; + +QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) { + + var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel); + + if (rsBlock == undefined) { + throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel); + } + + var length = rsBlock.length / 3; + + var list = new Array(); + + for (var i = 0; i < length; i++) { + + var count = rsBlock[i * 3 + 0]; + var totalCount = rsBlock[i * 3 + 1]; + var dataCount = rsBlock[i * 3 + 2]; + + for (var j = 0; j < count; j++) { + list.push(new QRRSBlock(totalCount, dataCount) ); + } + } + + return list; +} + +QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) { + + switch(errorCorrectLevel) { + case QRErrorCorrectLevel.L : + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0]; + case QRErrorCorrectLevel.M : + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1]; + case QRErrorCorrectLevel.Q : + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2]; + case QRErrorCorrectLevel.H : + return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3]; + default : + return undefined; + } +} + +//--------------------------------------------------------------------- +// QRBitBuffer +//--------------------------------------------------------------------- + +function QRBitBuffer() { + this.buffer = new Array(); + this.length = 0; +} + +QRBitBuffer.prototype = { + + get : function(index) { + var bufIndex = Math.floor(index / 8); + return ( (this.buffer[bufIndex] >>> (7 - index % 8) ) & 1) == 1; + }, + + put : function(num, length) { + for (var i = 0; i < length; i++) { + this.putBit( ( (num >>> (length - i - 1) ) & 1) == 1); + } + }, + + getLengthInBits : function() { + return this.length; + }, + + putBit : function(bit) { + + var bufIndex = Math.floor(this.length / 8); + if (this.buffer.length <= bufIndex) { + this.buffer.push(0); + } + + if (bit) { + this.buffer[bufIndex] |= (0x80 >>> (this.length % 8) ); + } + + this.length++; + } +}; + +export { + QRCode, + QRErrorCorrectLevel +} diff --git a/weixin-miniprogram/utils/qrcode/refer.txt b/weixin-miniprogram/utils/qrcode/refer.txt new file mode 100644 index 0000000..9616276 --- /dev/null +++ b/weixin-miniprogram/utils/qrcode/refer.txt @@ -0,0 +1 @@ +https://github.com/DoctorWei/weapp-qrcode-canvas-2d diff --git a/weixin-miniprogram/utils/scanQRCode.js b/weixin-miniprogram/utils/scanQRCode.js new file mode 100644 index 0000000..ff8a63f --- /dev/null +++ b/weixin-miniprogram/utils/scanQRCode.js @@ -0,0 +1,25 @@ +function scanQRCode(Taro) { + // 只允许从相机扫码 + Taro.scanCode({ + onlyFromCamera: true, + success(res) { + console.log(res) + if (res.scanType == "WX_CODE" && res.path) { + let searchParams = res.path.split('?'); + if (searchParams.length > 1 && searchParams[1].startsWith('scene=guard')) { + Taro.navigateTo({ + url: "/pages/scan/entrance" + }) + return + } + } + Taro.showToast({ + title: "您扫描的不是门禁码", + icon: 'error', + duration: 2000 + }) + } + }) +} + +module.exports = scanQRCode; diff --git a/weixin-miniprogram/utils/spark-md5.min.js b/weixin-miniprogram/utils/spark-md5.min.js new file mode 100644 index 0000000..2ef527d --- /dev/null +++ b/weixin-miniprogram/utils/spark-md5.min.js @@ -0,0 +1 @@ +(function(factory){if(typeof exports==="object"){module.exports=factory()}else if(typeof define==="function"&&define.amd){define(factory)}else{var glob;try{glob=window}catch(e){glob=self}glob.SparkMD5=factory()}})(function(undefined){"use strict";var add32=function(a,b){return a+b&4294967295},hex_chr=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function cmn(q,a,b,x,s,t){a=add32(add32(a,q),add32(x,t));return add32(a<>>32-s,b)}function md5cycle(x,k){var a=x[0],b=x[1],c=x[2],d=x[3];a+=(b&c|~b&d)+k[0]-680876936|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[1]-389564586|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[2]+606105819|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[3]-1044525330|0;b=(b<<22|b>>>10)+c|0;a+=(b&c|~b&d)+k[4]-176418897|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[5]+1200080426|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[6]-1473231341|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[7]-45705983|0;b=(b<<22|b>>>10)+c|0;a+=(b&c|~b&d)+k[8]+1770035416|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[9]-1958414417|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[10]-42063|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[11]-1990404162|0;b=(b<<22|b>>>10)+c|0;a+=(b&c|~b&d)+k[12]+1804603682|0;a=(a<<7|a>>>25)+b|0;d+=(a&b|~a&c)+k[13]-40341101|0;d=(d<<12|d>>>20)+a|0;c+=(d&a|~d&b)+k[14]-1502002290|0;c=(c<<17|c>>>15)+d|0;b+=(c&d|~c&a)+k[15]+1236535329|0;b=(b<<22|b>>>10)+c|0;a+=(b&d|c&~d)+k[1]-165796510|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[6]-1069501632|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[11]+643717713|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[0]-373897302|0;b=(b<<20|b>>>12)+c|0;a+=(b&d|c&~d)+k[5]-701558691|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[10]+38016083|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[15]-660478335|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[4]-405537848|0;b=(b<<20|b>>>12)+c|0;a+=(b&d|c&~d)+k[9]+568446438|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[14]-1019803690|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[3]-187363961|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[8]+1163531501|0;b=(b<<20|b>>>12)+c|0;a+=(b&d|c&~d)+k[13]-1444681467|0;a=(a<<5|a>>>27)+b|0;d+=(a&c|b&~c)+k[2]-51403784|0;d=(d<<9|d>>>23)+a|0;c+=(d&b|a&~b)+k[7]+1735328473|0;c=(c<<14|c>>>18)+d|0;b+=(c&a|d&~a)+k[12]-1926607734|0;b=(b<<20|b>>>12)+c|0;a+=(b^c^d)+k[5]-378558|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[8]-2022574463|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[11]+1839030562|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[14]-35309556|0;b=(b<<23|b>>>9)+c|0;a+=(b^c^d)+k[1]-1530992060|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[4]+1272893353|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[7]-155497632|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[10]-1094730640|0;b=(b<<23|b>>>9)+c|0;a+=(b^c^d)+k[13]+681279174|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[0]-358537222|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[3]-722521979|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[6]+76029189|0;b=(b<<23|b>>>9)+c|0;a+=(b^c^d)+k[9]-640364487|0;a=(a<<4|a>>>28)+b|0;d+=(a^b^c)+k[12]-421815835|0;d=(d<<11|d>>>21)+a|0;c+=(d^a^b)+k[15]+530742520|0;c=(c<<16|c>>>16)+d|0;b+=(c^d^a)+k[2]-995338651|0;b=(b<<23|b>>>9)+c|0;a+=(c^(b|~d))+k[0]-198630844|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[7]+1126891415|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[14]-1416354905|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[5]-57434055|0;b=(b<<21|b>>>11)+c|0;a+=(c^(b|~d))+k[12]+1700485571|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[3]-1894986606|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[10]-1051523|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[1]-2054922799|0;b=(b<<21|b>>>11)+c|0;a+=(c^(b|~d))+k[8]+1873313359|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[15]-30611744|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[6]-1560198380|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[13]+1309151649|0;b=(b<<21|b>>>11)+c|0;a+=(c^(b|~d))+k[4]-145523070|0;a=(a<<6|a>>>26)+b|0;d+=(b^(a|~c))+k[11]-1120210379|0;d=(d<<10|d>>>22)+a|0;c+=(a^(d|~b))+k[2]+718787259|0;c=(c<<15|c>>>17)+d|0;b+=(d^(c|~a))+k[9]-343485551|0;b=(b<<21|b>>>11)+c|0;x[0]=a+x[0]|0;x[1]=b+x[1]|0;x[2]=c+x[2]|0;x[3]=d+x[3]|0}function md5blk(s){var md5blks=[],i;for(i=0;i<64;i+=4){md5blks[i>>2]=s.charCodeAt(i)+(s.charCodeAt(i+1)<<8)+(s.charCodeAt(i+2)<<16)+(s.charCodeAt(i+3)<<24)}return md5blks}function md5blk_array(a){var md5blks=[],i;for(i=0;i<64;i+=4){md5blks[i>>2]=a[i]+(a[i+1]<<8)+(a[i+2]<<16)+(a[i+3]<<24)}return md5blks}function md51(s){var n=s.length,state=[1732584193,-271733879,-1732584194,271733878],i,length,tail,tmp,lo,hi;for(i=64;i<=n;i+=64){md5cycle(state,md5blk(s.substring(i-64,i)))}s=s.substring(i-64);length=s.length;tail=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(i=0;i>2]|=s.charCodeAt(i)<<(i%4<<3)}tail[i>>2]|=128<<(i%4<<3);if(i>55){md5cycle(state,tail);for(i=0;i<16;i+=1){tail[i]=0}}tmp=n*8;tmp=tmp.toString(16).match(/(.*?)(.{0,8})$/);lo=parseInt(tmp[2],16);hi=parseInt(tmp[1],16)||0;tail[14]=lo;tail[15]=hi;md5cycle(state,tail);return state}function md51_array(a){var n=a.length,state=[1732584193,-271733879,-1732584194,271733878],i,length,tail,tmp,lo,hi;for(i=64;i<=n;i+=64){md5cycle(state,md5blk_array(a.subarray(i-64,i)))}a=i-64>2]|=a[i]<<(i%4<<3)}tail[i>>2]|=128<<(i%4<<3);if(i>55){md5cycle(state,tail);for(i=0;i<16;i+=1){tail[i]=0}}tmp=n*8;tmp=tmp.toString(16).match(/(.*?)(.{0,8})$/);lo=parseInt(tmp[2],16);hi=parseInt(tmp[1],16)||0;tail[14]=lo;tail[15]=hi;md5cycle(state,tail);return state}function rhex(n){var s="",j;for(j=0;j<4;j+=1){s+=hex_chr[n>>j*8+4&15]+hex_chr[n>>j*8&15]}return s}function hex(x){var i;for(i=0;i>16)+(y>>16)+(lsw>>16);return msw<<16|lsw&65535}}if(typeof ArrayBuffer!=="undefined"&&!ArrayBuffer.prototype.slice){(function(){function clamp(val,length){val=val|0||0;if(val<0){return Math.max(val+length,0)}return Math.min(val,length)}ArrayBuffer.prototype.slice=function(from,to){var length=this.byteLength,begin=clamp(from,length),end=length,num,target,targetArray,sourceArray;if(to!==undefined){end=clamp(to,length)}if(begin>end){return new ArrayBuffer(0)}num=end-begin;target=new ArrayBuffer(num);targetArray=new Uint8Array(target);sourceArray=new Uint8Array(this,begin,num);targetArray.set(sourceArray);return target}})()}function toUtf8(str){if(/[\u0080-\uFFFF]/.test(str)){str=unescape(encodeURIComponent(str))}return str}function utf8Str2ArrayBuffer(str,returnUInt8Array){var length=str.length,buff=new ArrayBuffer(length),arr=new Uint8Array(buff),i;for(i=0;i>2]|=buff.charCodeAt(i)<<(i%4<<3)}this._finish(tail,length);ret=hex(this._hash);if(raw){ret=hexToBinaryString(ret)}this.reset();return ret};SparkMD5.prototype.reset=function(){this._buff="";this._length=0;this._hash=[1732584193,-271733879,-1732584194,271733878];return this};SparkMD5.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}};SparkMD5.prototype.setState=function(state){this._buff=state.buff;this._length=state.length;this._hash=state.hash;return this};SparkMD5.prototype.destroy=function(){delete this._hash;delete this._buff;delete this._length};SparkMD5.prototype._finish=function(tail,length){var i=length,tmp,lo,hi;tail[i>>2]|=128<<(i%4<<3);if(i>55){md5cycle(this._hash,tail);for(i=0;i<16;i+=1){tail[i]=0}}tmp=this._length*8;tmp=tmp.toString(16).match(/(.*?)(.{0,8})$/);lo=parseInt(tmp[2],16);hi=parseInt(tmp[1],16)||0;tail[14]=lo;tail[15]=hi;md5cycle(this._hash,tail)};SparkMD5.hash=function(str,raw){return SparkMD5.hashBinary(toUtf8(str),raw)};SparkMD5.hashBinary=function(content,raw){var hash=md51(content),ret=hex(hash);return raw?hexToBinaryString(ret):ret};SparkMD5.ArrayBuffer=function(){this.reset()};SparkMD5.ArrayBuffer.prototype.append=function(arr){var buff=concatenateArrayBuffers(this._buff.buffer,arr,true),length=buff.length,i;this._length+=arr.byteLength;for(i=64;i<=length;i+=64){md5cycle(this._hash,md5blk_array(buff.subarray(i-64,i)))}this._buff=i-64>2]|=buff[i]<<(i%4<<3)}this._finish(tail,length);ret=hex(this._hash);if(raw){ret=hexToBinaryString(ret)}this.reset();return ret};SparkMD5.ArrayBuffer.prototype.reset=function(){this._buff=new Uint8Array(0);this._length=0;this._hash=[1732584193,-271733879,-1732584194,271733878];return this};SparkMD5.ArrayBuffer.prototype.getState=function(){var state=SparkMD5.prototype.getState.call(this);state.buff=arrayBuffer2Utf8Str(state.buff);return state};SparkMD5.ArrayBuffer.prototype.setState=function(state){state.buff=utf8Str2ArrayBuffer(state.buff,true);return SparkMD5.prototype.setState.call(this,state)};SparkMD5.ArrayBuffer.prototype.destroy=SparkMD5.prototype.destroy;SparkMD5.ArrayBuffer.prototype._finish=SparkMD5.prototype._finish;SparkMD5.ArrayBuffer.hash=function(arr,raw){var hash=md51_array(new Uint8Array(arr)),ret=hex(hash);return raw?hexToBinaryString(ret):ret};return SparkMD5}); diff --git a/weixin-miniprogram/utils/util.js b/weixin-miniprogram/utils/util.js new file mode 100644 index 0000000..c21fddb --- /dev/null +++ b/weixin-miniprogram/utils/util.js @@ -0,0 +1,27 @@ +const formatTime = date => { + const year = date.getFullYear() + const month = date.getMonth() + 1 + const day = date.getDate() + const hour = date.getHours() + const minute = date.getMinutes() + const second = date.getSeconds() + + return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}` +} + +const formatDate = date => { + const year = date.getFullYear() + const month = date.getMonth() + 1 + const day = date.getDate() + + return [year, month, day].map(formatNumber).join('-') +} + +const formatNumber = n => { + n = n.toString() + return n[1] ? n : `0${n}` +} + +module.exports = { + formatTime +}