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

微信小程序 提审时隐藏功能;微信小程序添加微信快捷登录、随便看看(登的user用户)

This commit is contained in:
程序员小墨 2023-04-17 02:36:04 +08:00
parent 62ed92029c
commit 0238251ab0
29 changed files with 1205 additions and 624 deletions

View File

@ -318,6 +318,18 @@ window.wsUrl = 'ws://127.0.0.1:80/access/websocket/1';
##### 配置小程序 APPID 与 APPSECRET
修改 `backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/service/WeChatTokenServiceImpl.java` 文件
```
// 小程序信息
final String APPID = "【⚠此处修改为你的小程序 APPID】";
final String APPSECRET = "【⚠此处修改为你的小程序 APPSECRET】";
```
#### nginx 代理配置(可选)
配置文件在 `nginx-conf` 目录下(不能直接拿来用,需要根据自己的实际情况来改)

View File

@ -25,4 +25,5 @@ public class User implements Serializable {
private String doorplate;
private String permission;
private LocalDateTime permissionTime;
private String wxcode;
}

View File

@ -3,6 +3,9 @@ package com.cxyxiaomo.epp.gateway.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.LinkedList;
@RestController
public class Controller {
@ -10,4 +13,35 @@ public class Controller {
public String error() {
return "[ERROR] 500 Internal Server Error";
}
/**
* 为了通过微信的小程序审核所特别处理的
*
* @return
*/
@RequestMapping("/getConfig")
public HashMap<String, Object> WxMiniProgramAuditSpecialHandle() {
boolean showCode = true;
boolean showShop = true;
LinkedList<String> tabbarItem = new LinkedList<>();
tabbarItem.push("pages/index/index");
if (showCode) tabbarItem.push("pages/residents/code");
tabbarItem.push("pages/residents/report");
if (showShop) tabbarItem.push("pages/shop/shop");
tabbarItem.push("pages/person/person");
LinkedList<String> indexItem = new LinkedList<>();
indexItem.push("/pages/index/login");
if (showCode) indexItem.push("/pages/residents/code");
if (showCode) indexItem.push("scanQRCode");
indexItem.push("/pages/residents/report");
if (showShop) indexItem.push("/pages/shop/shop");
indexItem.push("/pages/person/person");
indexItem.push("/pages/person/updpwd");
HashMap<String, Object> map = new HashMap<>();
map.put("tabbarItem", tabbarItem);
map.put("indexItem", indexItem);
return map;
}
}

View File

@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Objects;
@Controller
@RequestMapping("/access/wechat")
public class WeChatTokenController {
@ -47,4 +49,18 @@ public class WeChatTokenController {
return responseBody.bytes();
}
@GetMapping(value = "/rpc/getOpenIdFromApi")
@ResponseBody
@SneakyThrows
public Res getOpenIdFromApi(@RequestParam(value = "code", required = true) String code) {
if (Objects.isNull(code) || "".equals(code)) {
return Res.error("参数错误");
}
String openId = weChatTokenService.getOpenIdFromApi(code);
if (openId == null) {
return Res.error("微信OpenId接口调用失败请刷新重试");
}
return Res.success(openId);
}
}

View File

@ -97,8 +97,8 @@ public class WeChatTokenServiceImpl implements WeChatTokenService {
params.put("check_path", unlimitedQRCodeParam.getCheckPath());
params.put("env_version", unlimitedQRCodeParam.getEnvVersion());
params.put("width", unlimitedQRCodeParam.getWidth());
params.put("auto_color",unlimitedQRCodeParam.getAutoColor());
params.put("is_hyaline",unlimitedQRCodeParam.getIsHyaline());
params.put("auto_color", unlimitedQRCodeParam.getAutoColor());
params.put("is_hyaline", unlimitedQRCodeParam.getIsHyaline());
String paramsString = JSON.toJSONString(params);
OkHttpClient okHttpClient = new OkHttpClient();
@ -108,11 +108,40 @@ public class WeChatTokenServiceImpl implements WeChatTokenService {
.post(RequestBody.create(paramsString, MediaType.parse("application/json; charset=utf-8")))
.build();
Response response = okHttpClient.newCall(request).execute();
// String result = response.body()response.body().string();
// String result = response.body().string();
// System.out.println("headers: " + response.headers());
// System.out.println("body: " + response.body());
System.out.println("paramsString: " + paramsString);
return response.body();
}
@SneakyThrows
public String getOpenIdFromApi(String code) {
// refer:
// https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/wx.login.html
// https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/user-login/code2Session.html
String url = String.format("https://api.weixin.qq.com/sns/jscode2session?" +
"appid=%s&secret=%s&js_code=%s&grant_type=authorization_code", APPID, APPSECRET, code);
OkHttpClient okHttpClient = new OkHttpClient();
Request request = new Request.Builder()
.url(url)
.get()
.build();
Response response = okHttpClient.newCall(request).execute();
ResponseBody body = response.body();
if (body != null) {
String jsonString = body.string();
// {"session_key":"7DnwgV6kUALcO+j65k5Gcw==","openid":"oFzuC4pvbPzY7vI6vmP6_57iTk-U","unionid":"oZxJH1kLie37EpC4FzslnCcWDEA4"}
JSONObject result = JSONObject.parseObject(jsonString);
String openId = result.getString("openid");
System.out.println("body: " + body + ", result: " + result);
return openId;
} else {
return null;
}
}
}

View File

@ -82,6 +82,16 @@
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- OpenFeign -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
<!-- 分页 -->
<dependency>
<groupId>com.github.pagehelper</groupId>

View File

@ -3,11 +3,13 @@ package com.cxyxiaomo.epp.user;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
// 启动类
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class UserProvider {
public static void main(String[] args) {
SpringApplication.run(UserProvider.class, args);

View File

@ -15,6 +15,7 @@ import com.cxyxiaomo.epp.common.pojo.Role;
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.rpc.WeChatTokenServiceFeign;
import com.cxyxiaomo.epp.user.service.RoleService;
import com.cxyxiaomo.epp.user.service.UserService;
import com.github.pagehelper.PageHelper;
@ -25,10 +26,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.*;
@Controller
@RequestMapping("/user")
@ -40,6 +38,9 @@ public class UserController {
@Resource
private RoleService roleService;
@Resource
private WeChatTokenServiceFeign weChatTokenService;
/**
* 用户登录
*
@ -50,6 +51,12 @@ public class UserController {
@PostMapping("/login")
@ResponseBody
public Res login(@RequestParam("username") String username, @RequestParam("password") String password) {
// 微信小程序 随便看看
if (Objects.equals(username, "#fastLogin#") && Objects.equals(password, "#fastLogin#")) {
username = "user";
password = "user";
}
User user = userService.getUserByUsername(username);
if (user != null) {
String passwordHash = DigestUtils.sha512Hex(password);
@ -65,6 +72,49 @@ public class UserController {
}
}
/**
* 微信小程序用户登录
*
* @param code
* @return
*/
@PostMapping("/wxlogin")
@ResponseBody
public Res wxlogin(@RequestParam("code") String code) {
// 微信小程序 登录页面 随便看看
if (Objects.isNull(code)) {
return Res.error("参数错误");
}
String jsonString = weChatTokenService.getOpenIdFromApi(code);
JSONObject jsonObject = JSONObject.parseObject(jsonString);
String openId = jsonObject.getString("data");
if (Objects.isNull(openId) || "".equals(openId)) {
return Res.error("微信接口异常,请重试");
}
User user = userService.getUserByWxcode(openId);
if (user == null) {
// 创建一个新用户
user = new User();
user.setId(null);
user.setUsername(UUID.randomUUID().toString().replace("-", "").substring(0, 10));
user.setPassword(UUID.randomUUID().toString());
user.setRealname("微信用户" + user.getUsername().substring(0, 5));
user.setRoleId(3);
user.setPermission("1");
user.setWxcode(openId);
userService.addUser(user);
// 添加之后 user.getId() 可以获取到用户id
// System.out.println("userId: " + user.getId());
}
// 完成登录
HashMap<String, Object> map = new HashMap<>();
map.put("userInfo", UserVO.convertFrom(user));
return Res.success(map);
}
/**
* 通过用户ID获取用户信息
*

View File

@ -19,6 +19,8 @@ public interface UserDao {
User getUserByUsername(String username);
User getUserByWxcode(String wxcode);
public List<User> getUserList(UserVO userVO);
public boolean deleteUserById(Integer userId);

View File

@ -0,0 +1,16 @@
package com.cxyxiaomo.epp.user.rpc;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient("microservice-provider-access")
public interface WeChatTokenServiceFeign {
/**
* 返回值参数要对应方法名随意
* OpenFeign 中方法参数前如果没有注解默认添加 @RequestBody 注解最多只能存在一个不带注解的参数
* 普通表单参数必须添加 @Requestparam 注解如果变量名和参数名称对应可以不写name
*/
@GetMapping("/access/wechat/rpc/getOpenIdFromApi")
String getOpenIdFromApi(@RequestParam("code") String code);
}

View File

@ -18,6 +18,10 @@ public class UserService {
return userDao.getUserByUsername(username);
}
public User getUserByWxcode(String wxcode) {
return userDao.getUserByWxcode(wxcode);
}
public User getUserById(Integer id) {
return userDao.getUserById(id);
}

View File

@ -3,11 +3,11 @@
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cxyxiaomo.epp.user.dao.UserDao">
<insert id="addUser" parameterType="com.cxyxiaomo.epp.common.pojo.User">
<insert id="addUser" parameterType="com.cxyxiaomo.epp.common.pojo.User" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
INSERT INTO user (username, `password`, realname, id_number, phone_number, role_id, building_id, doorplate,
permission, permission_time)
permission, permission_time, wx_code)
VALUES (#{username}, #{password}, #{realname}, #{idNumber}, #{phoneNumber}, #{roleId}, #{buildingId},
#{doorplate}, #{permission}, #{permissionTime})
#{doorplate}, #{permission}, #{permissionTime}, #{wxcode})
</insert>
<update id="updateUser" parameterType="com.cxyxiaomo.epp.common.pojo.User">
UPDATE user
@ -42,6 +42,9 @@
<if test="permissionTime != null">
permission_time = #{permissionTime},
</if>
<if test="wxcode != null and wxcode != ''">
wx_code = #{doorplate},
</if>
</set>
WHERE id = #{id}
</update>
@ -55,6 +58,11 @@
from user
where username = #{username}
</select>
<select id="getUserByWxcode" resultType="com.cxyxiaomo.epp.common.pojo.User">
select *
from user
where wx_code = #{wxcode}
</select>
<select id="getUserList" resultType="com.cxyxiaomo.epp.common.pojo.User">
select *
from user

View File

@ -11,7 +11,7 @@
Target Server Version : 80012
File Encoding : 65001
Date: 15/04/2023 18:50:35
Date: 17/04/2023 00:21:11
*/
SET NAMES utf8mb4;
@ -33,6 +33,10 @@ CREATE TABLE `access_log` (
-- ----------------------------
-- Records of access_log
-- ----------------------------
INSERT INTO `access_log` VALUES (1758893687032647686, '2023-04-16 14:55:34', 3, '用户 密码user', 1758638368624873480, 'IN');
INSERT INTO `access_log` VALUES (1758919878770823177, '2023-04-16 16:39:38', 3, '用户 密码user', 1758617522619420679, 'IN');
INSERT INTO `access_log` VALUES (1758919904809062403, '2023-04-16 16:39:44', 3, '用户 密码user', 1758617522619420679, 'IN');
INSERT INTO `access_log` VALUES (1758920178021830662, '2023-04-16 16:40:50', 3, '用户 密码user', 1758617522619420679, 'IN');
-- ----------------------------
-- Table structure for apply1
@ -113,11 +117,16 @@ CREATE TABLE `gate` (
`name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '大门显示名称',
`open` tinyint(1) NOT NULL DEFAULT 1 COMMENT '大门是否开放 1为开放 2为关闭',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '社区大门' ROW_FORMAT = DYNAMIC;
) ENGINE = InnoDB AUTO_INCREMENT = 1758638368624873481 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '社区大门' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of gate
-- ----------------------------
INSERT INTO `gate` VALUES (1758596186765398020, '适天争件产江周名极光', 0);
INSERT INTO `gate` VALUES (1758597371496894468, '动前去议百来别三', 0);
INSERT INTO `gate` VALUES (1758597390077661186, '些然北属称精', 0);
INSERT INTO `gate` VALUES (1758617522619420679, '适天争件产江周名极光适天', 1);
INSERT INTO `gate` VALUES (1758638368624873480, '照入质西理年周门亲北', 1);
-- ----------------------------
-- Table structure for goods
@ -143,7 +152,7 @@ CREATE TABLE `goods` (
INDEX `category_id`(`category_id`) USING BTREE,
INDEX `brand_id`(`brand`) USING BTREE,
INDEX `sort_order`(`sort_order`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 88 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '商品基本信息表' ROW_FORMAT = DYNAMIC;
) ENGINE = InnoDB AUTO_INCREMENT = 90 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '商品基本信息表' ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of goods
@ -235,6 +244,8 @@ INSERT INTO `goods` VALUES (84, '雀巢咖啡', 5, 'Nestle', '[]', '拿铁口味
INSERT INTO `goods` VALUES (85, '伊利纯牛奶', 7, '伊利', '[]', '高端纯牛奶', 1, 100, 'https://cdn-we-retail.ym.tencent.com/tsr/goods/muy-3a.png?imageMogr2/thumbnail/320x320/quality/70/strip/format/jpg', 0, '', 5.00, 4.80, '伊利纯牛奶,高端纯牛奶,口感绵密,适合慢慢品尝。', 0);
INSERT INTO `goods` VALUES (86, '太平梳打饼干', 5, '太平', '[]', '酥脆可口', 1, 100, 'https://cdn-we-retail.ym.tencent.com/tsr/goods/muy-3a.png?imageMogr2/thumbnail/320x320/quality/70/strip/format/jpg', 0, '', 10.00, 8.50, '太平梳打饼干,酥脆可口,咬一口,满口的香脆声。', 0);
INSERT INTO `goods` VALUES (87, '德芙巧克力', 5, 'Dove', '[]', '丝滑绵密', 1, 100, 'https://cdn-we-retail.ym.tencent.com/tsr/goods/muy-3a.png?imageMogr2/thumbnail/320x320/quality/70/strip/format/jpg', 0, '', 30.00, 28.50, '德芙巧克力,丝滑绵密,一口一个,舌尖上的享受。', 0);
INSERT INTO `goods` VALUES (88, '常产过片根直式党子', 6, '运量此受资市标接', NULL, '度党约进手即温任团据解知易主流见养步料题进拉且生般政学全', 0, 27885, '//epp-1302260381.cos.ap-shanghai.myqcloud.com/good/d6641529-e32b-46d9-b883-ec6585848fc9.jpg', NULL, '状气', 48841.00, 6.33, '反则向候间清且工至关八活里证商新作往感件区感其交七在且七成精说分率见领主元开论山适革严素就眼和毛便来热指持调证光同又院群置经论过天位无类给海便标从。', 0);
INSERT INTO `goods` VALUES (89, '3213123', 3, '用众价热员济种这万人', NULL, '带位究在着几起儿头里除团确还支了张千说', 1, 776, '//epp-1302260381.cos.ap-shanghai.myqcloud.com/good/d8af3d35-f9b7-431d-a431-fea79aec3004.jpg', NULL, '或道', 26.00, 37932.00, '做标火消行斯感没情政马青圆战空义每马南见对写时你行常年然而见身上高布动系海此低装往华员强每华风部问系阶都但总广型何议消是导造许要领百无单步格况候离拉历则通又线片角九么出书要经包过儿式细半色设新法天下现至数导社过须布再至走素增备关角社派色。', 0);
-- ----------------------------
-- Table structure for goods_category
@ -245,7 +256,7 @@ CREATE TABLE `goods_category` (
`category_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '商品分类名',
`order` int(11) NULL DEFAULT NULL COMMENT '排序',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of goods_category
@ -257,6 +268,7 @@ INSERT INTO `goods_category` VALUES (4, '防疫物资', 0);
INSERT INTO `goods_category` VALUES (5, '零食', 3);
INSERT INTO `goods_category` VALUES (6, '肉类', 2);
INSERT INTO `goods_category` VALUES (7, '饮料酒水', 4);
INSERT INTO `goods_category` VALUES (8, '测试6', 11);
-- ----------------------------
-- Table structure for notice1
@ -305,6 +317,14 @@ INSERT INTO `order` VALUES (1749496012575215624, 3, '2023-03-21 16:32:33', 'Pend
INSERT INTO `order` VALUES (1750312359831932932, 3, '2023-03-23 22:36:26', 'Cancelled', 87.50, NULL);
INSERT INTO `order` VALUES (1750312445567700999, 3, '2023-03-23 22:36:46', 'Processing', 87.50, NULL);
INSERT INTO `order` VALUES (1750313361633054722, 3, '2023-03-23 22:40:25', 'Processing', 2.50, NULL);
INSERT INTO `order` VALUES (1758148329772027912, 3, '2023-04-14 13:33:47', 'Pending', 2.00, NULL);
INSERT INTO `order` VALUES (1758148627185930246, 3, '2023-04-14 13:34:58', 'Cancelled', 2.00, NULL);
INSERT INTO `order` VALUES (1758148669368045578, 3, '2023-04-14 13:35:08', 'Processing', 3.00, NULL);
INSERT INTO `order` VALUES (1758659566150750208, 3, '2023-04-15 23:25:15', 'Processing', 19.90, NULL);
INSERT INTO `order` VALUES (1758659642495471619, 3, '2023-04-15 23:25:33', 'Processing', 138.00, NULL);
INSERT INTO `order` VALUES (1758659766395211784, 3, '2023-04-15 23:26:03', 'Processing', 59.80, NULL);
INSERT INTO `order` VALUES (1758659860087574537, 3, '2023-04-15 23:26:25', 'Processing', 98.00, NULL);
INSERT INTO `order` VALUES (1758660000932302858, 3, '2023-04-15 23:26:59', 'Processing', 37932.00, NULL);
-- ----------------------------
-- Table structure for order_detail
@ -321,7 +341,7 @@ CREATE TABLE `order_detail` (
INDEX `good_id`(`good_id`) USING BTREE,
CONSTRAINT `order_detail_ibfk_1` FOREIGN KEY (`good_id`) REFERENCES `goods` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT,
CONSTRAINT `order_detail_ibfk_2` FOREIGN KEY (`order_id`) REFERENCES `order` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 49 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;
) ENGINE = InnoDB AUTO_INCREMENT = 54 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of order_detail
@ -339,6 +359,14 @@ INSERT INTO `order_detail` VALUES (42, 1749496012575215624, 16, 3, 5.99);
INSERT INTO `order_detail` VALUES (43, 1750312359831932932, 55, 25, 3.50);
INSERT INTO `order_detail` VALUES (44, 1750312445567700999, 55, 25, 3.50);
INSERT INTO `order_detail` VALUES (45, 1750313361633054722, 56, 1, 2.50);
INSERT INTO `order_detail` VALUES (46, 1758148329772027912, 89, 2, 1.00);
INSERT INTO `order_detail` VALUES (47, 1758148627185930246, 89, 2, 1.00);
INSERT INTO `order_detail` VALUES (48, 1758148669368045578, 89, 3, 1.00);
INSERT INTO `order_detail` VALUES (49, 1758659566150750208, 40, 1, 19.90);
INSERT INTO `order_detail` VALUES (50, 1758659642495471619, 38, 1, 138.00);
INSERT INTO `order_detail` VALUES (51, 1758659766395211784, 46, 2, 29.90);
INSERT INTO `order_detail` VALUES (52, 1758659860087574537, 36, 1, 98.00);
INSERT INTO `order_detail` VALUES (53, 1758660000932302858, 89, 1, 37932.00);
-- ----------------------------
-- Table structure for report
@ -352,7 +380,7 @@ CREATE TABLE `report` (
`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 = 72 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;
) ENGINE = InnoDB AUTO_INCREMENT = 73 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of report
@ -367,6 +395,7 @@ INSERT INTO `report` VALUES (61, 3, '用户 密码user', '2023-03-23 22:24:14',
INSERT INTO `report` VALUES (62, 3, '用户 密码user', '2023-03-13 22:54:12', '0', '湖北省武汉市洪山区文治街102-4号');
INSERT INTO `report` VALUES (70, 3, '用户 密码user', '2023-04-14 00:36:55', '0', '湖北省武汉市洪山区文治街102-4号');
INSERT INTO `report` VALUES (71, 3, '用户 密码user', '2023-04-14 13:36:23', '0', '湖北省武汉市洪山区紫菘花园东路');
INSERT INTO `report` VALUES (72, 3, '用户 密码user', '2023-04-15 23:24:18', '0', '湖北省武汉市洪山区紫菘花园东路');
-- ----------------------------
-- Table structure for role
@ -402,7 +431,7 @@ CREATE TABLE `setting` (
-- ----------------------------
-- Records of setting
-- ----------------------------
INSERT INTO `setting` VALUES ('wechat_access_token', '66_qSxbHTU4lcXa4l8JgZisZm_2gXUmQH_vVSybGHP229Nv9QeacmXuYeQxpZQ-JNnLWI-HpJ9Zlf18B4Lnif5fR1EvGukoLFZmGWADlcobLsY-JlKZX7lXRzk6tAoRWTiACAZEB', '2023-03-24 00:26:42');
INSERT INTO `setting` VALUES ('wechat_access_token', '67_lvC4shtBYYZae7yON61MuTntj9fx8T74kGz1PveEJMVqCbBjPc6K2e-RhKiBEr2eaqJds5fbKhJzz3IF51u5i-sTLsARKfKcK_Rp6qS71Sbc7V5S778QhE4xYaQXCTfABADIZ', '2023-04-17 02:08:29');
-- ----------------------------
-- Table structure for user
@ -420,33 +449,37 @@ CREATE TABLE `user` (
`doorplate` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '门牌号',
`permission` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '进出权限 (0-无 1-继承(普通居民) 2-永久 3-限时)',
`permission_time` datetime NULL DEFAULT NULL COMMENT '进出权限失效时间',
`wx_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '微信登录授权码',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `username`(`username`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 22 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;
UNIQUE INDEX `username`(`username`) USING BTREE,
UNIQUE INDEX `wx_code`(`wx_code`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 23 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = DYNAMIC;
-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES (1, 'root', '99adc231b045331e514a516b4b7680f588e3823213abe901738bc3ad67b2f6fcb3c64efb93d18002588d3ccc1a49efbae1ce20cb43df36b38651f11fa75678e8', '管理员 密码root', '420111111111111112', '18911111111', 1, '28-1', '1101', '0', NULL);
INSERT INTO `user` VALUES (2, 'admin', 'c7ad44cbad762a5da0a452f9e854fdc1e0e7a52a38015f23f3eab1d80b931dd472634dfac71cd34ebc35d16ab7fb8a90c81f975113d6c7538dc69dd8de9077ec', '社区管理员 密码admin', '420111111111111111', '027-22222121', 2, '16-3', '0203', '0', NULL);
INSERT INTO `user` VALUES (3, 'user', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户 密码user', '420111111111111111', '18911111111', 3, '20-2', '0802', '0', NULL);
INSERT INTO `user` VALUES (4, 'user2', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户2 密码user', '420111111111111111', '027-22222121', 3, '20-2', '0802', '0', NULL);
INSERT INTO `user` VALUES (5, 'user3', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户3 密码user', '420111111111111111', '112', 3, '20-2', '0802', '0', NULL);
INSERT INTO `user` VALUES (6, 'user4', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户4 密码user', '420111111111111111', '112', 3, '20-2', '0802', '0', NULL);
INSERT INTO `user` VALUES (7, 'user5', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户5 密码user', '420111111111111111', '112', 3, '20-2', '0802', '0', NULL);
INSERT INTO `user` VALUES (8, 'user6', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户6 密码user', '420111111111111111', '112', 3, '20-2', '0802', '0', NULL);
INSERT INTO `user` VALUES (9, 'user7', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户7 密码user', '420111111111111111', '112', 3, '20-2', '0802', '0', NULL);
INSERT INTO `user` VALUES (10, 'user8', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户8 密码user', '420111111111111111', '112', 3, '20-2', '0802', '0', NULL);
INSERT INTO `user` VALUES (11, 'user9', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户9 密码user', '420111111111111111', '13123321311', 3, '20-2', '0802', '0', NULL);
INSERT INTO `user` VALUES (12, 'user10', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户10 密码user', '420111111111111111', '112', 3, '20-2', '0802', '0', NULL);
INSERT INTO `user` VALUES (13, 'qlrfsuxp', 'b5f2ac77c2b8a58dfbff97ff290406cee696c7b54dcd6ebdaf3fdb9205c531c720289f66f47d90c232ff36f942da5533e40e01f3472863c2d78923488fd81055', '而样分', '929309818756666037', '13480331104', 5, '24-62', '1354', '0', NULL);
INSERT INTO `user` VALUES (15, 'zqnpgccvq', 'c2bf9f49ef2c0da78eedacde07b37322aa063fa045dd6f24b1d449e5eb81d38fceb5ee656ab479f84cae1a56a4f7c6eac93242dd1cf0d0c754ce12e3b653f713', '机得什后叫', '375601190881718', '16792348638', 4, '78-16', '7138', '0', NULL);
INSERT INTO `user` VALUES (16, 'leyp', '00320b98cb7b69671f8298d0bd3340c84d954aabccddfae2f9355f91ed0342e721926ebb62192af6dd56cdc67ca54fcea65679ec6e18e3e8970d50c72bfabd22', '问组使增员了者', '576761656075477737', '13513873254', 6, '21-84', '8164', '0', NULL);
INSERT INTO `user` VALUES (17, 'kbiwiw', 'dd9d455bf8b09f491151c3af1448aca8c6136cd4c902d0b19ba5792c18577add4edf5bdb892238ab785cd8a540a22cea62d21139657f353a41be65a554330846', '感转', '634896418246896', '015-6634216', 2, '73-41', '9435', '0', NULL);
INSERT INTO `user` VALUES (18, 'dgciqwqhj', 'bec427eb1d7767afd214f6524f5aebc07e181d34cc054cbe23c7a87f262fd577dbe5b9e25e7184d192579296af7a933bea3d26017499ad499364cd8996610a69', '层开名法', '417821248186407144', '18865882572', 3, '23-78', '6264', '0', NULL);
INSERT INTO `user` VALUES (19, 'cm', '105056cce8fc85bdbecaed247db90332cf785c8fed9cbcb71dba57187aded6b81d049679a9b56155716c9e47958bc676722985956d0ab2fd040ae0e8cdb7720f', '指及价常件', '124677736597155066', '05961067874', 3, '54-64', '1370', '0', NULL);
INSERT INTO `user` VALUES (20, 'fcslfbk', '975c3a52d5435ae60a6f30f4572e754ab458613d0d6c309783bde047198f7944b75b54a62cfbae58594f30573717882aca9bebcccb3ade84fdd5a7d2dd9a0c0f', '集命问已土美石日', '464715523910577877', '0785-3674834', 4, '63-94', '2420', '0', NULL);
INSERT INTO `user` VALUES (21, 'vrk', 'f7e3fa3af542e7dd3960069eebb22b5e76adb57e5cf1df0ef0da5cea79e3e8f1a8414b612ebc6f4f08e64bddce070c7e6e55a8f4c098f90145b476acdd3f2808', '称红', '441911654591292', '17474066066', 2, '22-23', '7866', '0', NULL);
INSERT INTO `user` VALUES (1, 'root', '99adc231b045331e514a516b4b7680f588e3823213abe901738bc3ad67b2f6fcb3c64efb93d18002588d3ccc1a49efbae1ce20cb43df36b38651f11fa75678e8', '管理员 密码root', '420111111111111112', '18911111111', 1, '28-1', '1101', '1', NULL, NULL);
INSERT INTO `user` VALUES (2, 'admin', 'c7ad44cbad762a5da0a452f9e854fdc1e0e7a52a38015f23f3eab1d80b931dd472634dfac71cd34ebc35d16ab7fb8a90c81f975113d6c7538dc69dd8de9077ec', '社区管理员 密码admin', '420111111111111111', '027-22222121', 2, '16-3', '0203', '1', NULL, NULL);
INSERT INTO `user` VALUES (3, 'user', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户 密码user', '420111111111111111', '18911111111', 3, '20-2', '0802', '1', NULL, NULL);
INSERT INTO `user` VALUES (4, 'user2', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户2 密码user', '420111111111111111', '027-22222121', 3, '20-2', '0802', '1', NULL, NULL);
INSERT INTO `user` VALUES (5, 'user3', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户3 密码user', '420111111111111111', '112', 3, '20-2', '0802', '1', NULL, NULL);
INSERT INTO `user` VALUES (6, 'user4', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户4 密码user', '420111111111111111', '112', 3, '20-2', '0802', '1', NULL, NULL);
INSERT INTO `user` VALUES (7, 'user5', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户5 密码user', '420111111111111111', '112', 3, '20-2', '0802', '1', NULL, NULL);
INSERT INTO `user` VALUES (8, 'user6', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户6 密码user', '420111111111111111', '112', 3, '20-2', '0802', '1', NULL, NULL);
INSERT INTO `user` VALUES (9, 'user7', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户7 密码user', '420111111111111111', '112', 3, '20-2', '0802', '1', NULL, NULL);
INSERT INTO `user` VALUES (10, 'user8', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户8 密码user', '420111111111111111', '112', 3, '20-2', '0802', '1', NULL, NULL);
INSERT INTO `user` VALUES (11, 'user9', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户9 密码user', '420111111111111111', '13123321311', 3, '20-2', '0802', '1', NULL, NULL);
INSERT INTO `user` VALUES (12, 'user10', 'b14361404c078ffd549c03db443c3fede2f3e534d73f78f77301ed97d4a436a9fd9db05ee8b325c0ad36438b43fec8510c204fc1c1edb21d0941c00e9e2c1ce2', '用户10 密码user', '420111111111111111', '112', 3, '20-2', '0802', '1', NULL, NULL);
INSERT INTO `user` VALUES (13, 'qlrfsuxp', 'b5f2ac77c2b8a58dfbff97ff290406cee696c7b54dcd6ebdaf3fdb9205c531c720289f66f47d90c232ff36f942da5533e40e01f3472863c2d78923488fd81055', '而样分', '929309818756666037', '13480331104', 5, '24-62', '1354', '1', NULL, NULL);
INSERT INTO `user` VALUES (15, 'zqnpgccvq', 'c2bf9f49ef2c0da78eedacde07b37322aa063fa045dd6f24b1d449e5eb81d38fceb5ee656ab479f84cae1a56a4f7c6eac93242dd1cf0d0c754ce12e3b653f713', '机得什后叫', '375601190881718', '16792348638', 4, '78-16', '7138', '1', NULL, NULL);
INSERT INTO `user` VALUES (16, 'leyp', '00320b98cb7b69671f8298d0bd3340c84d954aabccddfae2f9355f91ed0342e721926ebb62192af6dd56cdc67ca54fcea65679ec6e18e3e8970d50c72bfabd22', '问组使增员了者', '576761656075477737', '13513873254', 6, '21-84', '8164', '1', NULL, NULL);
INSERT INTO `user` VALUES (17, 'kbiwiw', 'dd9d455bf8b09f491151c3af1448aca8c6136cd4c902d0b19ba5792c18577add4edf5bdb892238ab785cd8a540a22cea62d21139657f353a41be65a554330846', '感转', '634896418246896', '015-6634216', 2, '73-41', '9435', '1', NULL, NULL);
INSERT INTO `user` VALUES (18, 'dgciqwqhj', 'bec427eb1d7767afd214f6524f5aebc07e181d34cc054cbe23c7a87f262fd577dbe5b9e25e7184d192579296af7a933bea3d26017499ad499364cd8996610a69', '层开名法', '417821248186407144', '18865882572', 3, '23-78', '6264', '1', NULL, NULL);
INSERT INTO `user` VALUES (19, 'cm', '105056cce8fc85bdbecaed247db90332cf785c8fed9cbcb71dba57187aded6b81d049679a9b56155716c9e47958bc676722985956d0ab2fd040ae0e8cdb7720f', '指及价常件', '124677736597155066', '05961067874', 3, '54-64', '1370', '1', NULL, NULL);
INSERT INTO `user` VALUES (20, 'fcslfbk', '975c3a52d5435ae60a6f30f4572e754ab458613d0d6c309783bde047198f7944b75b54a62cfbae58594f30573717882aca9bebcccb3ade84fdd5a7d2dd9a0c0f', '集命问已土美石日', '464715523910577877', '0785-3674834', 4, '63-94', '2420', '1', NULL, NULL);
INSERT INTO `user` VALUES (21, 'vrk', 'f7e3fa3af542e7dd3960069eebb22b5e76adb57e5cf1df0ef0da5cea79e3e8f1a8414b612ebc6f4f08e64bddce070c7e6e55a8f4c098f90145b476acdd3f2808', '称红', '441911654591292', '17474066066', 2, '22-23', '7866', '1', NULL, NULL);
INSERT INTO `user` VALUES (23, '1723787d-7', 'de7c6d14-c62d-40da-bd86-54eb136c80a4', '微信用户17237', NULL, NULL, 3, NULL, NULL, '1', NULL, NULL);
INSERT INTO `user` VALUES (29, '3595009cab', 'f5ab242d-ba78-4437-814f-5cf75d99918a', '微信用户35950', NULL, NULL, 3, NULL, NULL, '1', NULL, 'oFzuC4pvbPzY7vI6vmP6_57iTk-U');
-- ----------------------------
-- Table structure for visitor1

View File

@ -460,12 +460,40 @@
"response": []
},
{
"name": "[线上] 小程序端 获取大门详情",
"name": "[微服务] 小程序端 获取大门详情",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://epp.only4.work/guard-client/getGateList",
"raw": "http://localhost:8002/access/gate/miniprogram/detail?id=261758638368624873480",
"protocol": "http",
"host": [
"localhost"
],
"port": "8002",
"path": [
"access",
"gate",
"miniprogram",
"detail"
],
"query": [
{
"key": "id",
"value": "261758638368624873480"
}
]
}
},
"response": []
},
{
"name": "[线上] 小程序端 获取大门详情 Copy",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "https://epp.only4.work/access/gate/miniprogram/detail?id=261758638368624873480",
"protocol": "https",
"host": [
"epp",
@ -473,8 +501,44 @@
"work"
],
"path": [
"guard-client",
"getGateList"
"access",
"gate",
"miniprogram",
"detail"
],
"query": [
{
"key": "id",
"value": "261758638368624873480"
}
]
}
},
"response": []
},
{
"name": "[微服务RPC] 微信小程序登录获取openId",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8002/access/wechat/rpc/getOpenIdFromApi?code=0f1meZZv3MRot03quH3w3Xnp744meZZu",
"protocol": "http",
"host": [
"localhost"
],
"port": "8002",
"path": [
"access",
"wechat",
"rpc",
"getOpenIdFromApi"
],
"query": [
{
"key": "code",
"value": "0f1meZZv3MRot03quH3w3Xnp744meZZu"
}
]
}
},

View File

@ -1,20 +1,27 @@
// 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
}
})
const toggleCustomTabBar = require('./custom-tab-bar/toggleCustomTabBar')
App({
async onLaunch() {
// 获取下拉框信息
toggleCustomTabBar.updateConfig(this.globalData.baseUrl)
// // 展示本地存储能力
// 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, // 是否展示调试内容
// debugMode: true, // 是否展示调试内容
baseUrl: true ? // Api 请求域名 不带最后的 /
"https://epp.only4.work" :
"http://localhost",

View File

@ -19,10 +19,11 @@
"navigationBarTextStyle": "white"
},
"tabBar": {
"custom": false,
"color": "#000000",
"backgroundColor": "#fff",
"selectedColor": "#FF8966",
"custom": true,
"————custom": false,
"————color": "#000000",
"————backgroundColor": "#fff",
"————selectedColor": "#FF8966",
"list": [
{
"pagePath": "pages/index/index",

View File

@ -0,0 +1,55 @@
Component({
data: {
selected: 0,
color: "#000000",
selectedColor: "#FF8966",
list: null, // 在 toggleCustomTabBar.js 中动态设置下面的菜单项
rawList: [
{
"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/shop/shop",
"text": "生活物资",
"iconPath": "image/icon/_shopping.png",
"selectedIconPath": "image/icon/shopping.png"
},
{
"pagePath": "pages/person/person",
"text": "我",
"iconPath": "image/icon/_person.png",
"selectedIconPath": "image/icon/person.png"
}
]
},
onShow() {
console.log("[CustomTabBar] onLoad")
},
attached() {
},
methods: {
switchTab(e) {
const data = e.currentTarget.dataset
const url = '/' + data.path
wx.switchTab({ url })
this.setData({
selected: data.index
})
}
}
})

View File

@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@ -0,0 +1,8 @@
<!--miniprogram/custom-tab-bar/index.wxml-->
<cover-view class="tab-bar">
<cover-view class="tab-bar-border"></cover-view>
<cover-view wx:for="{{list}}" wx:key="index" class="tab-bar-item" data-path="{{item.pagePath}}" data-index="{{index}}" bindtap="switchTab">
<cover-image src="../{{selected === index ? item.selectedIconPath : item.iconPath}}"></cover-image>
<cover-view style="color: {{selected === index ? selectedColor : color}}">{{item.text}}</cover-view>
</cover-view>
</cover-view>

View File

@ -0,0 +1,38 @@
.tab-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 48px;
background: white;
display: flex;
padding-bottom: env(safe-area-inset-bottom);
}
.tab-bar-border {
background-color: rgba(0, 0, 0, 0.33);
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 1px;
transform: scaleY(0.5);
}
.tab-bar-item {
flex: 1;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
}
.tab-bar-item cover-image {
width: 27px;
height: 27px;
}
.tab-bar-item cover-view {
font-size: 10px;
}

View File

@ -0,0 +1,97 @@
var defaultTabbarItem = [
"pages/person/person",
"pages/residents/report",
"pages/index/index"
]
export function toggle(that) {
let pages = getCurrentPages()
let route = pages[pages.length - 1].route
console.log("[CustomTabBar] route", route)
if (!typeof that.getTabBar === 'function' || !that.getTabBar()) {
// wx.showModal({
// title: '版本太旧',
// content: '您的微信版本太旧,无法使用本小程序',
// showCancel: false,
// complete: (res) => {
// wx.exitMiniProgram()
// }
// })
return
}
// 找出要选择哪一项
let tabBar = that.getTabBar()
console.log("[CustomTabBar] tabBar", tabBar)
let data = tabBar.data
console.log("[CustomTabBar] data", data)
let showPagePathList = wx.getStorageSync('tabbarItem') || defaultTabbarItem
console.log("[CustomTabBar] showPagePathList", showPagePathList)
let list = tabBar.data.rawList.filter((page) => showPagePathList.includes(page.pagePath))
console.log("[CustomTabBar] tabBarList", list)
let selected = list ? list.indexOf(list.find(p => p.pagePath == route)) : -1
console.log("[CustomTabBar] selected", selected)
console.log("更新tabbar")
// 选中这一项
tabBar.setData({
selected: selected,
list: list
})
}
export function updateConfig(baseUrl) {
// 请求配置文件(用于审核时隐藏部分功能)
wx.request({
url: baseUrl + '/getConfig',
success(result) {
let data = result.data
if (data.tabbarItem) {
console.log("[CustomTabBar] tabbar数据拉取完毕")
wx.setStorageSync('tabbarItem', data.tabbarItem)
wx.setStorageSync('indexItem', data.indexItem)
const pages = getCurrentPages();
const indexPage = pages[0]
const currentPage = pages[pages.length - 1]
console.log("[CustomTabBar] indexPage", indexPage)
console.log("[CustomTabBar] currentPage", currentPage)
// // 更新tabbar
// toggle(currentPage)
// 刷新首页中包含了触发 toggle 的代码 此处不重复触发
// 刷新首页
indexPage && indexPage.onLoad()
// let tabBar = currentPage.getTabBar()
// tabBar.setData({
// list: tabBar.data.rawList.filter((page) => itemList.includes(page.pagePath))
// })
}
},
fail() {
wx.showModal({
title: '小程序启动失败',
content: '点击确认重试,若多次失败请检查网络连接',
complete: (res) => {
if (res.cancel) {
wx.exitMiniProgram()
}
if (res.confirm) {
wx.reLaunch({
url: 'pages/index/index',
})
}
}
})
}
})
}

View File

@ -1,6 +1,7 @@
// pages/index/index.js
const menuItemDict = require('../../utils/menuList.js')
const getUserGroupByRole = require('../../utils/getUserGroupByRole.js')
const toggleCustomTabBar = require('../../custom-tab-bar/toggleCustomTabBar')
import scanQRCode from '../../utils/scanQRCode'
@ -22,6 +23,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
toggleCustomTabBar.toggle(this)
console.log("index/index onLoad", options)
// console.log("wx.getLaunchOptionsSync()", wx.getLaunchOptionsSync())
@ -39,7 +41,7 @@ Page({
debugText: JSON.stringify(options, null, 4),
userInfo: userInfo,
userGroup: userGroup,
displayUsername: userInfo?.username ?? "请登录",
displayUsername: userInfo ? (`${userInfo.realname} (${userInfo.username})`) : "请登录",
filterMenuItems: this.getFilterMenuItems(menuItemDict, userGroup)
})
console.log("menuItemDict", menuItemDict)
@ -82,6 +84,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
toggleCustomTabBar.toggle(this)
console.log("index/index onShow")
},
@ -122,8 +125,21 @@ Page({
getFilterMenuItems(menuItemDict, userGroup) {
return Object.values(menuItemDict)
let filterMenuItems = Object.values(menuItemDict)
.filter((item) => item.for.indexOf(userGroup) != -1)
// 动态控制显示隐藏
let indexItem = wx.getStorageSync('indexItem') || [
"/pages/index/login",
"/pages/person/person"
]
filterMenuItems = filterMenuItems
.filter((item) => {
let a = indexItem.includes(item.url)
console.log("filterMenuItems -> filter", item.url, indexItem)
return a
})
return filterMenuItems
},

View File

@ -15,11 +15,11 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
if (app.globalData.debugMode) {
this.setData({
debugMode: true,
})
}
// if (app.globalData.debugMode) {
// this.setData({
// debugMode: true,
// })
// }
},
/**
@ -81,12 +81,54 @@ Page({
fastLogin() {
this.setData({
username: "user",
password: "user",
username: "#fastLogin#",
password: "#fastLogin#",
})
this.login()
},
wxLogin() {
var that = this
wx.login({
success(res) {
if (res.code) {
wx.showLoading({
title: '加载中'
})
wx.request({
url: app.globalData.baseUrl + '/user/wxlogin',
method: "POST",
header: {
"Content-Type": "application/x-www-form-urlencoded" //用于post
},
data: {
code: res.code
},
success: function (d) {
wx.hideLoading()
that._loginSuccessCallback(d)
},
fail: function () {
wx.hideLoading()
wx.showToast({
title: "请求失败",
icon: 'error',
duration: 2000
})
}
})
} else {
console.log('登录失败!' + res.errMsg)
wx.showModal({
title: '登录失败',
content: '您点击了取消按钮' + res.errMsg,
showCancel: false
})
}
}
})
},
login() {
console.log("login userInput", this.data.username, this.data.password)
if (!this.data.username || !this.data.password) {
@ -96,6 +138,7 @@ Page({
duration: 2000
})
} else {
var that = this
wx.showLoading({
title: '加载中'
})
@ -111,32 +154,7 @@ Page({
},
success: function (d) {
wx.hideLoading()
let result = d.data;
if (result.success) {
// 登录成功
if (![3, 4, 5, 6].includes(result.data.userInfo.roleId)) {
wx.showModal({
title: '你不是社区居民',
content: '管理员请前往网页版登录',
showCancel: false,
complete: (res) => {
//
}
})
return
}
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
})
}
that._loginSuccessCallback(d)
},
fail: function () {
wx.hideLoading()
@ -148,5 +166,34 @@ Page({
}
})
}
},
_loginSuccessCallback(d) {
let result = d.data;
if (result.success) {
// 登录成功
if (![3, 4, 5, 6].includes(result.data.userInfo.roleId)) {
wx.showModal({
title: '你不是社区居民',
content: '管理员请前往网页版登录',
showCancel: false,
complete: (res) => {
//
}
})
return
}
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
})
}
}
})

View File

@ -12,9 +12,11 @@
</view>
<view class="loginBtnView">
<!--按钮-->
<button wx:if="{{debugMode}}" class="loginBtn" type="warn" bindtap="fastLogin">DEBUG快速登录user</button>
<button class="loginBtn" type="primary" bindtap="login">登录</button>
<button class="loginBtn" type="secondary" bindtap="visitor">访客申请</button>
<!-- <button wx:if="{{debugMode}}" class="loginBtn" type="warn" bindtap="fastLogin">DEBUG快速登录user</button> -->
<button class="loginBtn" type="primary" bindtap="login">密码登录</button>
<!-- <button class="loginBtn" type="secondary" bindtap="visitor">访客申请</button> -->
<button class="loginBtn" type="primary" bindtap="wxLogin">微信登录/注册</button>
<button class="loginBtn" type="secondary" bindtap="fastLogin">随便看看</button>
</view>
</view>
</view>

View File

@ -1,5 +1,7 @@
// pages/person/person.js
const toggleCustomTabBar = require('../../custom-tab-bar/toggleCustomTabBar')
const {
user
} = require("../../utils/const")
@ -16,7 +18,8 @@ Page({
avatarUrl: defaultAvatarUrl,
nickName: "请登录",
displayUserId: "",
menuList: [
menuList: [],
menuListRaw: [
{
id: "myOrder",
title: "我的订单",
@ -26,14 +29,14 @@ Page({
color: 'red',
title: "退出登录",
}
]
],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
toggleCustomTabBar.toggle(this)
},
/**
@ -47,6 +50,20 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
toggleCustomTabBar.toggle(this)
// 是否隐藏 我的订单
let arr = wx.getStorageSync("indexItem")
if (!arr || !arr.includes("/pages/shop/shop")) {
this.setData({
menuList: this.data.menuListRaw.filter(i => i.id != 'myOrder')
})
} else {
this.setData({
menuList: this.data.menuListRaw
})
}
let userInfo = wx.getStorageSync("userInfo")
if (!userInfo) {
console.log("用户未登录")
@ -109,7 +126,6 @@ Page({
console.log("e", userInfo)
this.setData({
avatarUrl: userInfo.avatarUrl,
})
},

View File

@ -4,6 +4,7 @@ import utils from '../../utils/util'
// import drawQrcode from '../../utils/qrcode/index'
import drawQrcode from '../../utils/lib/weapp.qrcode.esm.js'
import scanQRCode from '../../utils/scanQRCode'
const toggleCustomTabBar = require('../../custom-tab-bar/toggleCustomTabBar')
const app = getApp();
@ -25,7 +26,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
toggleCustomTabBar.toggle(this)
},
/**
@ -39,6 +40,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
toggleCustomTabBar.toggle(this)
console.log('onShow')
// setTimeout(this.refershData, 100)
this.refershData()

View File

@ -1,6 +1,8 @@
// pages/residents/report.js
import utils from '../../utils/util'
const toggleCustomTabBar = require('../../custom-tab-bar/toggleCustomTabBar')
const app = getApp();
Page({
@ -32,6 +34,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
toggleCustomTabBar.toggle(this)
console.log("residents/report onLoad")
},
@ -46,6 +49,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
toggleCustomTabBar.toggle(this)
console.log("residents/report onShow")
if (this.data.isSkipOnShowFunc) {
this.setData({

View File

@ -1,5 +1,7 @@
// pages/shop/shop.js
const toggleCustomTabBar = require('../../custom-tab-bar/toggleCustomTabBar')
const goodService = require("../../services/good")
Page({
@ -62,6 +64,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
toggleCustomTabBar.toggle(this)
this.loadPageData();
},
@ -76,7 +79,7 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow() {
toggleCustomTabBar.toggle(this)
},
/**

View File

@ -39,55 +39,55 @@ let menuItemDict = {
switchFunc: switchTab,
url: '/pages/shop/shop'
},
'apply-record': {
for: ['visitor'],
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'],
title: "提交反馈",
image: "fk.png",
switchFunc: switchTab,
url: ''
},
'feedback-list': {
for: ['visitor'],
title: "反馈查看",
image: "feedback.png",
switchFunc: switchTab,
url: ''
},
'feedback-reply': {
for: ['admin'],
title: "反馈回复",
image: "feedback.png",
switchFunc: switchTab,
url: ''
},
// 'apply-record': {
// for: ['visitor'],
// 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'],
// title: "提交反馈",
// image: "fk.png",
// switchFunc: switchTab,
// url: ''
// },
// 'feedback-list': {
// for: ['visitor'],
// title: "反馈查看",
// image: "feedback.png",
// switchFunc: switchTab,
// url: ''
// },
// 'feedback-reply': {
// for: ['admin'],
// title: "反馈回复",
// image: "feedback.png",
// switchFunc: switchTab,
// url: ''
// },
'person': {
for: ['admin', 'user'],
title: "个人中心",
@ -100,22 +100,22 @@ let menuItemDict = {
title: "密码修改",
image: "updPwd.png",
switchFunc: switchTab,
url: ''
url: '/pages/person/updpwd'
},
'assign': {
for: ['admin'],
title: "分配账号",
image: "count.png",
switchFunc: switchTab,
url: ''
},
'unfinish': {
for: ['admin'],
title: "今日未填", // RedList
image: "_report.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) {