Skip to content

Commit

Permalink
用户修改资料 4.18
Browse files Browse the repository at this point in the history
  • Loading branch information
brokensc committed Apr 18, 2024
1 parent bab8887 commit 78833b3
Show file tree
Hide file tree
Showing 13 changed files with 231 additions and 10 deletions.
4 changes: 3 additions & 1 deletion miniprogram-1/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ App({
})
},
globalData: {
userInfo: null
userInfo: null,
userAvatarUrl: null,
userName: null
}
})
4 changes: 3 additions & 1 deletion miniprogram-1/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"pages/py/py",
"pages/jy/jy",
"pages/windowInfo/windowInfo",
"pages/search/lostrecords"
"pages/search/lostrecords",
"pages/user/userChange",
"pages/user/comments"
],
"window": {
"navigationBarTextStyle": "black",
Expand Down
4 changes: 0 additions & 4 deletions miniprogram-1/pages/home/home.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
</view>
<view class="school-info-1">
<text class="school-title-1">大学城校区</text>
<text>总人数:</text>
</view>
</navigator>
<navigator class="dfl" url="/pages/dfl/dfl">
Expand All @@ -15,7 +14,6 @@
</view>
<view class="school-info-2">
<text class="school-title-2">东风路校区</text>
<text>总人数:</text>
</view>
</navigator>
<navigator class="py" url="/pages/py/py">
Expand All @@ -24,7 +22,6 @@
</view>
<view class="school-info-3">
<text class="school-title-3">番禺校区</text>
<text>总人数:</text>
</view>
</navigator>
<navigator class="jy" url="/pages/jy/jy">
Expand All @@ -33,7 +30,6 @@
</view>
<view class="school-info-4">
<text class="school-title-4">揭阳校区</text>
<text>总人数:</text>
</view>
</navigator>
</view>
66 changes: 66 additions & 0 deletions miniprogram-1/pages/user/comments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// pages/user/comments.js
Page({

/**
* 页面的初始数据
*/
data: {

},

/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {

},

/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {

},

/**
* 生命周期函数--监听页面显示
*/
onShow() {

},

/**
* 生命周期函数--监听页面隐藏
*/
onHide() {

},

/**
* 生命周期函数--监听页面卸载
*/
onUnload() {

},

/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {

},

/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {

},

/**
* 用户点击右上角分享
*/
onShareAppMessage() {

}
})
3 changes: 3 additions & 0 deletions miniprogram-1/pages/user/comments.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"usingComponents": {}
}
2 changes: 2 additions & 0 deletions miniprogram-1/pages/user/comments.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<!--pages/user/comments.wxml-->
<text>pages/user/comments.wxml</text>
1 change: 1 addition & 0 deletions miniprogram-1/pages/user/comments.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* pages/user/comments.wxss */
15 changes: 15 additions & 0 deletions miniprogram-1/pages/user/user.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
// pages/user/user.js
const app = getApp();
Page({
/* 页面的初始数据*/
data: {

},

/**监听界面显示 */
onShow() {
if(this.data.nickName != app.globalData.userName){
this.setData({
nickName:app.globalData.userName
})
}
else if(this.data.avatarUrl != app.globalData.userAvatarUrl){
this.setData({
avatarUrl:app.globalData.userAvatarUrl
})
}
},

/* 获取头像 */
closeTank(e){
Expand Down
8 changes: 4 additions & 4 deletions miniprogram-1/pages/user/user.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<!-- 条目 -->
<!-- 登录后状态 -->
<view class="item-login" wx:if="{{avatarUrl}}">
<view class="item">
<navigator class="item" url="/pages/user/userChange?avatarUrl={{avatarUrl}}&nickName={{nickName}}">
<button class="item-name">修改资料</button>
<view class="right-arrow"></view>
</view>
<view class="item">
</navigator>
<navigator url="/pages/user/comments" class="item">
<button class="item-name">我的评论</button>
<view class="right-arrow"></view>
</view>
</navigator>
</view>
<view class="item">
<button class="item-name" open-type="feedback">反馈建议</button>
Expand Down
80 changes: 80 additions & 0 deletions miniprogram-1/pages/user/userChange.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// pages/user/userChange.js
const app = getApp();
Page({

/**
* 页面的初始数据
*/
data: {

},

/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log("接受shoufengqin页面传递过来的参数:",options)
this.setData({
avatarUrl: options.avatarUrl,
nickName: options.nickName
})

},

/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {

},

/**
* 生命周期函数--监听页面显示
*/
onShow() {

},

getName(e) {
this.setData({
nickName: e.detail.value
})
},

chooseImage() {
wx.chooseMedia({
count: 1,
mediaType: ['image'],
sizeType: ['compressed'], //可以指定是原图还是压缩图,这里用压缩
sourceType: ['album', 'camera'], //从相册选择
success: (res) => {
console.log("选择图片成功", res)
this.setData({
avatarUrl: res.tempFiles[0].tempFilePath
})
}
})
},

/** */
submit(){
/* 设置globalData属性,保存用户属性*/
app.globalData.userAvatarUrl = this.data.avatarUrl;
app.globalData.userName = this.data.nickName;

wx.switchTab({
url: '/pages/user/user',
})//移动到user界面
wx.showToast({
title: '成功修改',
icon: 'success',
duration: 2000
})
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {

}
})
4 changes: 4 additions & 0 deletions miniprogram-1/pages/user/userChange.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "修改资料"
}
12 changes: 12 additions & 0 deletions miniprogram-1/pages/user/userChange.wxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!--pages/user/userChange.wxml-->
<view class="item">
<view class="tip">编辑姓名</view>
<input value="{{nickName}}" bindinput="getName" />
</view>
<view class="line"></view>

<view class="item" bindtap="chooseImage">
<view class="tip">点击修改头像</view>
<image src="{{avatarUrl}}" />
</view>
<button class="btn" bindtap="submit">提交修改</button>
38 changes: 38 additions & 0 deletions miniprogram-1/pages/user/userChange.wxss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* pages/user/userChange.wxss */
.item {
display: flex;
align-items: center;
justify-content: space-between;
margin: 15rpx;
border-bottom: 1rpx solid gray;
padding-bottom: 20rpx;
}

.tip {
font-size: 44rpx;
margin: 20rpx;
color: red;
}

.item image {
width: 200rpx;
height: 200rpx;
border-radius: 10rpx;
margin: 10rpx 30rpx;

}

.item input {
flex: 1;
border: 1px solid gray;
border-radius: 20rpx;
padding: 5rpx 15rpx;
}

.btn {
color: white;
margin-top: 70rpx;
background-color: #2E8B57;
width: 600rpx;
border-radius: 50rpx;
}

0 comments on commit 78833b3

Please sign in to comment.