diff --git a/TODOs.md b/TODOs.md
index 58e683f..520d7be 100644
--- a/TODOs.md
+++ b/TODOs.md
@@ -10,14 +10,28 @@ http://106.75.217.14:8488/nacos/index.html
nacos
socan
+
+
# 启动本地 Nacos
+
E:
cd E:\nacos\bin
startup.cmd -m standalone
+
+
# 内网穿透
+
cd E:\Project\毕业设计\epp\intranet-penetration\bin
rathole.exe ../conf/client.toml
+
+
+
+# 微信小程序后台设置 小程序最低基础库 2.21.3
+
+https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/userProfile.html
+
+
-----
Nacos CPU 跑满问题 我提的 GitHub issue
diff --git a/weixin-miniprogram/app.json b/weixin-miniprogram/app.json
index 37db4bb..6c6b59e 100644
--- a/weixin-miniprogram/app.json
+++ b/weixin-miniprogram/app.json
@@ -1,14 +1,13 @@
{
"pages": [
"pages/index/index",
- "pages/index2/index",
- "pages/logs/logs",
+ "pages/index/login",
"pages/residents/code",
"pages/residents/report",
- "pages/index/login",
+ "pages/residents/reportHistory",
+ "pages/shop/shop",
"pages/scan/entrance",
- "pages/person/person",
- "pages/residents/reportHistory"
+ "pages/person/person"
],
"window": {
"backgroundTextStyle": "dark",
@@ -40,6 +39,12 @@
"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": "我",
diff --git a/weixin-miniprogram/app.wxss b/weixin-miniprogram/app.wxss
index 75f4fde..13fc154 100644
--- a/weixin-miniprogram/app.wxss
+++ b/weixin-miniprogram/app.wxss
@@ -1 +1,16 @@
/**app.wxss**/
+/* 右上角小红点 */
+.add-dot {
+ position: relative;
+}
+
+.add-dot::after {
+ content: " ";
+ position: absolute;
+ right: -8rpx;
+ top: -3rpx;
+ width: 12rpx;
+ height: 12rpx;
+ background-color: red;
+ border-radius: 50%;
+}
diff --git a/weixin-miniprogram/image/icon/_shopping.png b/weixin-miniprogram/image/icon/_shopping.png
new file mode 100644
index 0000000..efdbbe9
Binary files /dev/null and b/weixin-miniprogram/image/icon/_shopping.png differ
diff --git a/weixin-miniprogram/image/icon/shopping.png b/weixin-miniprogram/image/icon/shopping.png
new file mode 100644
index 0000000..a01e64a
Binary files /dev/null and b/weixin-miniprogram/image/icon/shopping.png differ
diff --git a/weixin-miniprogram/image/icon/shopping.svg b/weixin-miniprogram/image/icon/shopping.svg
new file mode 100644
index 0000000..c401818
--- /dev/null
+++ b/weixin-miniprogram/image/icon/shopping.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/weixin-miniprogram/image/user-center-bg-v1.png b/weixin-miniprogram/image/user-center-bg-v1.png
new file mode 100644
index 0000000..fec4199
Binary files /dev/null and b/weixin-miniprogram/image/user-center-bg-v1.png differ
diff --git a/weixin-miniprogram/pages/index/index.js b/weixin-miniprogram/pages/index/index.js
index 31f3826..64d671d 100644
--- a/weixin-miniprogram/pages/index/index.js
+++ b/weixin-miniprogram/pages/index/index.js
@@ -11,6 +11,9 @@ Page({
*/
data: {
debugText: "调试",
+ displayUsername: "",
+ userGroup: "unknown",
+ filterMenuItems: [],
},
/**
@@ -19,15 +22,9 @@ Page({
onLoad(options) {
console.log("index/index onLoad", options)
// console.log("wx.getLaunchOptionsSync()", wx.getLaunchOptionsSync())
- this.setData({
- debugText: JSON.stringify(options, null, 4),
- })
-
- console.log("menuItemDict", menuItemDict)
- this.userInfo = wx.getStorageSync("userInfo")
- this.displayUsername = this.userInfo?.username ?? "请登录"
- if (!this.userInfo) {
+ let userInfo = wx.getStorageSync("userInfo")
+ if (!userInfo) {
console.log("用户未登录")
wx.redirectTo({
url: '/pages/index/login'
@@ -35,13 +32,19 @@ Page({
return
} else {
// 用户已登录
- this.userGroup = getUserGroupByRole(this.userInfo.role)
- this.debugObject = {
- userGroup: this.userGroup
- }
+ let userGroup = getUserGroupByRole(userInfo.role)
+ this.setData({
+ debugText: JSON.stringify(options, null, 4),
+ userInfo: userInfo,
+ userGroup: userGroup,
+ displayUsername: userInfo?.username ?? "请登录",
+ filterMenuItems: this.getFilterMenuItems(menuItemDict, userGroup)
+ })
+ console.log("menuItemDict", menuItemDict)
+ console.log("filterMenuItems", this.data.filterMenuItems)
//判断用户是否是通过扫小程序码进来的
- if (options.scene) {
+ if (options && options.scene) {
// 扫门禁的小程序码
if (options.scene.split('%')[0] == "guard") {
options.scene = null
@@ -52,14 +55,16 @@ Page({
}
}
- // // 开发模式下自动跳转到指定页面,节省开发时间
- // console.log("app.globalData", app.globalData)
- // if (app.globalData.debugMode) {
- // wx.switchTab({
- // url: '/pages/residents/report'
- // })
- // return
- // }
+ // 开发模式下自动跳转到指定页面,节省开发时间
+ console.log("app.globalData", app.globalData)
+ if (app.globalData.debugMode) {
+ wx.switchTab({
+ // url: '/pages/residents/report'
+ // url: '/pages/person/person'
+ url: '/pages/shop/shop'
+ })
+ return
+ }
}
},
@@ -110,5 +115,62 @@ Page({
*/
onShareAppMessage() {
console.log("index/index onShareAppMessage")
+ },
+
+
+ getFilterMenuItems(menuItemDict, userGroup) {
+ return Object.values(menuItemDict)
+ .filter((item) => item.for.indexOf(userGroup) != -1)
+ },
+
+
+ switchTo(event) {
+ let dataset = event.target.dataset
+ console.log("dataset", dataset)
+ switch (dataset.switchfunc) {
+ case 'switchTab':
+ wx.switchTab({
+ url: dataset.pageurl
+ })
+ break;
+ case 'navigateTo':
+ wx.navigateTo({
+ url: dataset.pageurl
+ })
+ break;
+ case 'redirectTo':
+ wx.redirectTo({
+ url: dataset.pageurl
+ })
+ break;
+ default:
+ console.log("切换页面失败", dataset)
+ break;
+ }
+ },
+
+ goCode() {
+ wx.switchTab({
+ url: '/pages/residents/code'
+ })
+ },
+
+ toggleDot(event, ownerInstance, iconName = 'code', status = undefined) {
+ console.log("menuItemDict[iconName]", menuItemDict[iconName])
+ console.log("this.data.userGroup", this.data.userGroup)
+ if (typeof (status) === 'undefined') {
+ menuItemDict[iconName].addDot = !menuItemDict[iconName].addDot;
+ } else {
+ menuItemDict[iconName].addDot = !!status;
+ }
+ this.setData({
+ filterMenuItems: this.getFilterMenuItems(menuItemDict, this.data.userGroup)
+ })
+ },
+
+ magicButton() {
+ wx.navigateTo({
+ url: "/pages/scan/entrance"
+ })
}
})
diff --git a/weixin-miniprogram/pages/index/index.wxml b/weixin-miniprogram/pages/index/index.wxml
index b59f5fa..2744f7b 100644
--- a/weixin-miniprogram/pages/index/index.wxml
+++ b/weixin-miniprogram/pages/index/index.wxml
@@ -1,21 +1,20 @@
-
+
欢迎你,{{ displayUsername }}!
- 调试信息:{{ debugText }}