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 }} - - - + + + {{ menuItem.title }} - - - + + + 调试信息:{{ debugText }} \ No newline at end of file diff --git a/weixin-miniprogram/pages/index/index.wxss b/weixin-miniprogram/pages/index/index.wxss index 8e9c81f..8e1ab17 100644 --- a/weixin-miniprogram/pages/index/index.wxss +++ b/weixin-miniprogram/pages/index/index.wxss @@ -1 +1,24 @@ -/* pages/index/index.wxss */ \ No newline at end of file +/* pages/index/index.wxss */ +#menu-view { + display: flex; + text-align: center; + flex-wrap: wrap; + padding: 20px 10px; +} + +.welcome-text { + display: block; + padding-left: 30px; + padding-top: 18px; + font-size: 20px; +} + +.menu-item { + width: 25%; + margin: 10px 0; +} + +.item-image { + width: 50px; + height: 50px; +} diff --git a/weixin-miniprogram/pages/index2/index.js b/weixin-miniprogram/pages/index2/index.js deleted file mode 100644 index 0bc1771..0000000 --- a/weixin-miniprogram/pages/index2/index.js +++ /dev/null @@ -1,48 +0,0 @@ -// 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.wxml b/weixin-miniprogram/pages/index2/index.wxml deleted file mode 100644 index f00d294..0000000 --- a/weixin-miniprogram/pages/index2/index.wxml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - 请使用1.4.4及以上版本基础库 - - - - {{userInfo.nickName}} - - - - {{motto}} - - diff --git a/weixin-miniprogram/pages/index2/index.wxss b/weixin-miniprogram/pages/index2/index.wxss deleted file mode 100644 index eb64203..0000000 --- a/weixin-miniprogram/pages/index2/index.wxss +++ /dev/null @@ -1,19 +0,0 @@ -/**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 deleted file mode 100644 index 85f6aac..0000000 --- a/weixin-miniprogram/pages/logs/logs.js +++ /dev/null @@ -1,18 +0,0 @@ -// 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 deleted file mode 100644 index 3ee76c1..0000000 --- a/weixin-miniprogram/pages/logs/logs.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationBarTitleText": "查看启动日志", - "usingComponents": {} -} \ No newline at end of file diff --git a/weixin-miniprogram/pages/logs/logs.wxml b/weixin-miniprogram/pages/logs/logs.wxml deleted file mode 100644 index 0b6b645..0000000 --- a/weixin-miniprogram/pages/logs/logs.wxml +++ /dev/null @@ -1,6 +0,0 @@ - - - - {{index + 1}}. {{log.date}} - - diff --git a/weixin-miniprogram/pages/logs/logs.wxss b/weixin-miniprogram/pages/logs/logs.wxss deleted file mode 100644 index 94d4b88..0000000 --- a/weixin-miniprogram/pages/logs/logs.wxss +++ /dev/null @@ -1,8 +0,0 @@ -.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 index e2a57e9..6934c94 100644 --- a/weixin-miniprogram/pages/person/person.js +++ b/weixin-miniprogram/pages/person/person.js @@ -1,11 +1,26 @@ // pages/person/person.js + +const { + user +} = require("../../utils/const") + +const app = getApp() +const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0' + Page({ /** * 页面的初始数据 */ data: { - + avatarUrl: defaultAvatarUrl, + nickName: "请登录", + displayUserId: "", + menuList: [{ + id: "logout", + color: 'red', + title: "退出登录", + }] }, /** @@ -26,7 +41,20 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - + let userInfo = wx.getStorageSync("userInfo") + if (!userInfo) { + console.log("用户未登录") + wx.redirectTo({ + url: '/pages/index/login' + }) + return + } else { + console.log("userInfo", userInfo) + this.setData({ + nickName: userInfo.realname, + displayUserId: "用户名: " + userInfo.username, + }) + } }, /** @@ -62,5 +90,37 @@ Page({ */ onShareAppMessage() { + }, + + onChooseAvatar(e) { + this.setData({ + avatarUrl: e.detail.avatarUrl, + }) + }, + + onGetUserInfo(e) { + let userInfo = JSON.parse(e.detail.rawData) + console.log("e", userInfo) + this.setData({ + avatarUrl: userInfo.avatarUrl, + + }) + }, + + menuTap: function (event) { + console.log("event.target", event.target) + let menuId = event.target.id + switch (menuId) { + case "logout": + wx.clearStorageSync() + app.globalData.userInfo = null + console.log("userInfo", wx.getStorageSync("userInfo")) + wx.redirectTo({ + url: '/pages/index/login' + }) + break + default: + break + } } -}) \ No newline at end of file +}) diff --git a/weixin-miniprogram/pages/person/person.json b/weixin-miniprogram/pages/person/person.json index a905e86..218d6c5 100644 --- a/weixin-miniprogram/pages/person/person.json +++ b/weixin-miniprogram/pages/person/person.json @@ -1,4 +1,6 @@ { "usingComponents": {}, - "navigationBarTitleText": "我" + "navigationBarTitleText": "个人中心", + "backgroundColor": "#000000", + "navigationStyle": "custom" } \ No newline at end of file diff --git a/weixin-miniprogram/pages/person/person.wxml b/weixin-miniprogram/pages/person/person.wxml index 74f353a..5dbf43e 100644 --- a/weixin-miniprogram/pages/person/person.wxml +++ b/weixin-miniprogram/pages/person/person.wxml @@ -1,2 +1,27 @@ -pages/person/person.wxml + + + + + + + + + + {{ menu.title }} + + + + + + \ No newline at end of file diff --git a/weixin-miniprogram/pages/person/person.wxss b/weixin-miniprogram/pages/person/person.wxss index 08f4ce6..b11ff5c 100644 --- a/weixin-miniprogram/pages/person/person.wxss +++ b/weixin-miniprogram/pages/person/person.wxss @@ -1 +1,66 @@ -/* pages/person/person.wxss */ \ No newline at end of file +/* pages/person/person.wxss */ +#container { + min-height: 100vh; + width: 100%; + background-color: #F5F5F5; + margin: 0; + padding: 0; + /* padding-top: 20px; */ +} + +.top-image { + width: 100vw; + height: 250px; + margin-bottom: -102px; + z-index: -100; + /* position: absolute; */ +} + +.cell-group { + background-color: #FFFFFF; + margin: 0 10px; + padding: 0; + margin-bottom: 20px; + border-radius: 10px; + z-index: 100; + position: relative; +} + +.user-profile { + display: grid; + grid-template-columns: 64px 1fr; + padding: 12px 20px; + place-items: center; + gap: 25px; +} + +.user-profile .avatar-selector { + width: 64px; + height: 64px; + margin: 0; + padding: 0; +} + +.user-profile .avatar { + width: 64px; + height: 64px; +} + +.user-profile .nickname { + font-size: 18px; +} + +.cell-item { + height: 48px; + line-height: 48px; + padding: 0 20px; + font-size: 18px; +} + +.cell-sept { + border-bottom: 1px rgb(170, 170, 170) solid; +} + +.cell:nth-last-child(1) .cell-sept { + display: none; +} diff --git a/weixin-miniprogram/pages/residents/report.js b/weixin-miniprogram/pages/residents/report.js index 2c59051..a6cda99 100644 --- a/weixin-miniprogram/pages/residents/report.js +++ b/weixin-miniprogram/pages/residents/report.js @@ -29,20 +29,21 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad(options) { - + console.log("residents/report onLoad") }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { - + console.log("residents/report onReady") }, /** * 生命周期函数--监听页面显示 */ onShow() { + console.log("residents/report onShow") if (this.data.isSkipOnShowFunc) { this.setData({ isSkipOnShowFunc: false, @@ -50,7 +51,6 @@ Page({ return } - console.log('onShow') let userInfo = wx.getStorageSync("userInfo") console.log("userInfo", userInfo) this.setData({ @@ -121,14 +121,16 @@ Page({ * 生命周期函数--监听页面隐藏 */ onHide() { - + console.log("residents/report onHide") + clearInterval(this.data.timeInterval) }, /** * 生命周期函数--监听页面卸载 */ onUnload() { - + console.log("residents/report onUnload") + clearInterval(this.data.timeInterval) }, /** @@ -157,7 +159,6 @@ Page({ this.setData({ "formData.temperature": e.detail.value }) - }, updateTime() { @@ -171,15 +172,26 @@ Page({ wx.showLoading({ title: '正在获取权限' }) - await new Promise((resolve) => { + await new Promise((resolve, reject) => { wx.getSetting({ success(res) { wx.hideLoading() if (!res.authSetting['scope.userLocation']) { wx.authorize({ - scope: 'scope.userLocationBackground', + scope: 'scope.userLocation', + // scope: 'scope.userLocationBackground', success() { resolve(); + }, + fail(err) { + wx.showModal({ + title: '定位失败', + content: '您已拒绝定位授权,小程序无法获取您的位置,请在微信首页长按删除小程序,重新打开再试', + showCancel: false, + complete: (res) => { + reject(); + } + }) } }) } else { diff --git a/weixin-miniprogram/pages/scan/entrance.wxml b/weixin-miniprogram/pages/scan/entrance.wxml index e68bd82..185a0d5 100644 --- a/weixin-miniprogram/pages/scan/entrance.wxml +++ b/weixin-miniprogram/pages/scan/entrance.wxml @@ -1,4 +1,4 @@ - 您将要进入社区 + 您将要进入社区:未知 \ No newline at end of file diff --git a/weixin-miniprogram/pages/shop/components/good-list-card.js b/weixin-miniprogram/pages/shop/components/good-list-card.js new file mode 100644 index 0000000..fbf26c6 --- /dev/null +++ b/weixin-miniprogram/pages/shop/components/good-list-card.js @@ -0,0 +1,37 @@ +// pages/shop/components/good-list-card.js +Component({ + // refer: https://developers.weixin.qq.com/miniprogram/dev/reference/api/Component.html + + /** + * 组件的属性列表 + */ + properties: { + goodinfo: { + type: Object, + } + }, + + /** + * 组件的初始数据 + */ + data: { + displayGoodsInfo: "", + displayInfo: "", + }, + + observers: { + 'goodinfo': function (goodinfo) { + console.log("observers -> goodinfo", goodinfo) + this.setData({ + displayGoodsInfo: JSON.stringify(this.properties.goodinfo) + }) + } + }, + + /** + * 组件的方法列表 + */ + methods: { + + } +}) diff --git a/weixin-miniprogram/pages/index2/index.json b/weixin-miniprogram/pages/shop/components/good-list-card.json similarity index 54% rename from weixin-miniprogram/pages/index2/index.json rename to weixin-miniprogram/pages/shop/components/good-list-card.json index 8835af0..e8cfaaf 100644 --- a/weixin-miniprogram/pages/index2/index.json +++ b/weixin-miniprogram/pages/shop/components/good-list-card.json @@ -1,3 +1,4 @@ { + "component": true, "usingComponents": {} } \ No newline at end of file diff --git a/weixin-miniprogram/pages/shop/components/good-list-card.wxml b/weixin-miniprogram/pages/shop/components/good-list-card.wxml new file mode 100644 index 0000000..d4f008d --- /dev/null +++ b/weixin-miniprogram/pages/shop/components/good-list-card.wxml @@ -0,0 +1,22 @@ + + + + + + + {{ goodinfo.goodsName }} + + + ¥ + {{ goodinfo.counterPrice }} + + + + + ¥ + {{ goodinfo.retailPrice }} + + + + \ No newline at end of file diff --git a/weixin-miniprogram/pages/shop/components/good-list-card.wxss b/weixin-miniprogram/pages/shop/components/good-list-card.wxss new file mode 100644 index 0000000..970e62b --- /dev/null +++ b/weixin-miniprogram/pages/shop/components/good-list-card.wxss @@ -0,0 +1,82 @@ +/* pages/shop/components/good-list-card.wxss */ +.good-card-container { + /* background-color: violet; */ + overflow: hidden; + display: grid; + height: 200px; + grid-template-rows: auto 58px; +} + +.good-card-image { + background-color: bisque; + background-position: center; + background-repeat: no-repeat; + background-size: cover; + overflow: hidden; + width: 100%; + height: 100%; +} + +.good-card-info { + padding: 4.5px 6px; +} + +/* 自动换行 */ +.line-wrap { + width: 100%; + word-break: break-word; + display: block; +} + +/* 商品标题 */ +.good-title { + font-size: 28rpx; + color: #333; + font-weight: 400; + height: 36rpx; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + overflow: hidden; + word-break: break-word; + line-height: 36rpx; + margin: 4rpx 0; +} + +/* 商品价格 */ +.good-price { + white-space: nowrap; + font-weight: 700; + margin: 0; + display: inline; + position: relative; +} + +.good-price-counter { + color: #fa4126; + font-size: 36rpx; +} + +.good-price-retail { + color: #bbbbbb; + font-size: 24rpx; + margin: 0 0 0 8rpx; +} + +.good-price .good-price-symbol { + font-size: 24rpx; + display: inline; +} + +.good-price .good-price-number { + display: inline; +} + +.good-price .good-price-line { + position: absolute; + top: 50%; + left: 0; + right: 0; + transform: translateY(-50%); + margin: 0; + background-color: currentColor; +} diff --git a/weixin-miniprogram/pages/shop/shop.js b/weixin-miniprogram/pages/shop/shop.js new file mode 100644 index 0000000..a7c0371 --- /dev/null +++ b/weixin-miniprogram/pages/shop/shop.js @@ -0,0 +1,122 @@ +// pages/shop/shop.js +Page({ + + /** + * 页面的初始数据 + */ + data: { + sidebarActiveId: -1, + sidebarList: [ + { + id: -1, + title: "全部分类", + }, + { + id: 1, + title: "1", + }, + { + id: 2, + title: "防疫物资", + }, + { + id: 3, + title: "111", + }, + { + id: 4, + title: "111", + }, + { + id: 5, + title: "111", + }, + ], + + tabbarList: [ + { + id: 1, + goodsName: "温度计", + counterPrice: "10.00", + retailPrice: "12.00", + picUrl: "https://cdn-we-retail.ym.tencent.com/tsr/goods/gh-2b.png?imageMogr2/thumbnail/320x320/quality/70/strip/format/webp", + }, + { + id: 2, + goodsName: "医用口罩", + counterPrice: "100.00", + retailPrice: "12.50", + picUrl: "https://cdn-we-retail.ym.tencent.com/tsr/goods/muy-3a.png?imageMogr2/thumbnail/320x320/quality/70/strip/format/webp", + } + ] + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { + + }, + + + sidebarItemTap(event) { + // 清除原来的选中项,并设置新的选中项 + // console.log("event.target", event.target) + // console.log("event.currentTarget", event.currentTarget) + let dataset = event.currentTarget.dataset + console.log("dataset", dataset) + this.setData({ + sidebarActiveId: dataset.item.id, + }) + return + } +}) \ No newline at end of file diff --git a/weixin-miniprogram/pages/shop/shop.json b/weixin-miniprogram/pages/shop/shop.json new file mode 100644 index 0000000..f17f36b --- /dev/null +++ b/weixin-miniprogram/pages/shop/shop.json @@ -0,0 +1,6 @@ +{ + "usingComponents": { + "listcard":"./components/good-list-card" + }, + "navigationBarTitleText": "生活物资" +} \ No newline at end of file diff --git a/weixin-miniprogram/pages/shop/shop.wxml b/weixin-miniprogram/pages/shop/shop.wxml new file mode 100644 index 0000000..463f095 --- /dev/null +++ b/weixin-miniprogram/pages/shop/shop.wxml @@ -0,0 +1,17 @@ + + + + + + {{ cate.title }} + + + + + + + + + 没有更多啦 + + \ No newline at end of file diff --git a/weixin-miniprogram/pages/shop/shop.wxss b/weixin-miniprogram/pages/shop/shop.wxss new file mode 100644 index 0000000..e8293fb --- /dev/null +++ b/weixin-miniprogram/pages/shop/shop.wxss @@ -0,0 +1,71 @@ +/* pages/shop/shop.wxss */ +.container { + /* background-color: aqua; */ + height: 100vh; + margin: 0; + padding: 0; + + display: grid; + grid-template-columns: 98px 1fr; + overflow-y: hidden; +} + +.sidebar { + background-color: #e7e7e7; + display: grid; + grid-template-rows: repeat(auto-fill, 50px); + grid-auto-flow: row dense; + overflow-y: auto; +} + +.sidebar-item { + background-color: #F5F5F5; + /* border-bottom: 1px solid rgb(121, 121, 121); */ + height: 100%; + display: table; +} + +.sidebar-item:last-child { + border-bottom: none; +} + +.sidebar-item-text { + display: table-cell; + vertical-align: middle; + text-align: center; +} + +.sidebar-item.active { + background-color: white; + font-weight: bold; + color: #FF764E; + border-left: 4px solid #FF764E; +} + +.tabbar { + overflow-y: auto; +} + +.tabbar-group { + display: grid; + grid-template-columns: 1fr 1fr; + grid-template-rows: repeat(auto-fill, 210px); + grid-auto-flow: row dense; + place-items: center; + gap: 3px 10px; + margin: 6px; +} + +.tabbar-item { + width: 100%; + display: inline-block; + overflow: hidden; + border-radius: 6px; + box-shadow: 0 2px 10px 0 rgba(0, 0, 0, .2); +} + +.no-more { + text-align: center; + color:grey; + margin: 20px; +} diff --git a/weixin-miniprogram/project.private.config.json b/weixin-miniprogram/project.private.config.json index 683c479..b547454 100644 --- a/weixin-miniprogram/project.private.config.json +++ b/weixin-miniprogram/project.private.config.json @@ -2,7 +2,8 @@ "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", "projectname": "weixin-miniprogram", "setting": { - "compileHotReLoad": false, + "compileHotReLoad": true, "urlCheck": false - } + }, + "libVersion": "2.21.4" } \ No newline at end of file diff --git a/weixin-miniprogram/utils/menuList.js b/weixin-miniprogram/utils/menuList.js index f07019c..7cd888e 100644 --- a/weixin-miniprogram/utils/menuList.js +++ b/weixin-miniprogram/utils/menuList.js @@ -1,5 +1,6 @@ const switchTab = "switchTab"; const navigateTo = "navigateTo"; +const redirectTo = "redirectTo"; let id = 0; let menuItemDict = { @@ -24,8 +25,15 @@ let menuItemDict = { switchFunc: switchTab, url: '/pages/residents/report' }, + 'shop': { + for: ['user'], + title: "生活物资", + image: "shopping.svg", + switchFunc: switchTab, + url: '/pages/shop/shop' + }, 'apply-record': { - for: ['visitor', 'user'], + for: ['visitor'], title: "申请记录", image: "apply.png", switchFunc: switchTab, @@ -53,14 +61,14 @@ let menuItemDict = { url: '' }, 'feedback-submit': { - for: ['visitor', 'user'], + for: ['visitor'], title: "提交反馈", image: "fk.png", switchFunc: switchTab, url: '' }, 'feedback-list': { - for: ['visitor', 'user'], + for: ['visitor'], title: "反馈查看", image: "feedback.png", switchFunc: switchTab, @@ -73,6 +81,13 @@ let menuItemDict = { switchFunc: switchTab, url: '' }, + 'person': { + for: ['admin', 'user'], + title: "个人中心", + image: "person.png", + switchFunc: switchTab, + url: '/pages/person/person' + }, 'update-password': { for: ['user', 'admin'], title: "密码修改",