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

小程序:首页按钮功能完成;个人中心、生活物资页框架;体温上报定位权限获取失败提示信息;删除部分无用代码;

This commit is contained in:
2023-03-18 17:52:56 +08:00
parent 94a2dbf26d
commit ee7e2e9acb
33 changed files with 712 additions and 181 deletions

View File

@@ -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
}
}
})
})

View File

@@ -1,4 +1,6 @@
{
"usingComponents": {},
"navigationBarTitleText": "我"
"navigationBarTitleText": "个人中心",
"backgroundColor": "#000000",
"navigationStyle": "custom"
}

View File

@@ -1,2 +1,27 @@
<!--pages/person/person.wxml-->
<text>pages/person/person.wxml</text>
<view id="container">
<image class="top-image" src="../../image/user-center-bg-v1.png"></image>
<view class="content-wrapper">
<view class="cell-group user-profile">
<button class="avatar-selector" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
<image class="avatar" src="{{avatarUrl}}"></image>
</button>
<view style="width: 100%;">
<text class="nickname">{{nickName}}</text>
<text style="font-size: 11px; color: grey;">
点击头像使用微信头像;{{displayUserId}}
</text>
</view>
</view>
<view class="cell-group">
<view class="cell" wx:for="{{ menuList }}" wx:for-item="menu" wx:key="id">
<view class="cell-item" id="{{ menu.id }}" bindtap="menuTap" style="{{ menu.color ? 'color:'+menu.color : '' }}">
{{ menu.title }}
</view>
<view class="cell-sept"></view>
</view>
</view>
</view>
</view>

View File

@@ -1 +1,66 @@
/* pages/person/person.wxss */
/* 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;
}