初始化

This commit is contained in:
2024-12-06 16:18:22 +08:00
commit 884dd70d83
751 changed files with 60883 additions and 0 deletions
@@ -0,0 +1,135 @@
const {
etmsPost
} = require("../../com");
const config = require("../../config");
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
isGetUser: false,
nickName: "",
avatarUrl: "",
canIUseGetUserProfile: false
},
handleGetUserProfile(e) {
wx.getUserProfile({
desc: '用于获取参与活动的学员的头像',
success: (res) => {
console.log(res.userInfo);
this.processGetUserInfo(res.userInfo);
}
})
},
onChooseAvatar(e) {
const {
avatarUrl
} = e.detail;
var etmsData = {
openId: app.globalData.openId,
unionid: app.globalData.unionid,
miniPgmUserId: app.globalData.u
};
let that = this;
wx.uploadFile({
url: config.upLoadMiniProgramAvatar,
filePath: avatarUrl,
name: 'file',
formData: {
"etmsData": JSON.stringify(etmsData)
},
success(res) {
var obj = JSON.parse(res.data)
that.setData({
avatarUrl: obj.resultData
})
}
})
},
getUserInfo(info) {
if (info.detail.userInfo) {
console.log(info.detail.userInfo)
var myuser = info.detail.userInfo;
this.processGetUserInfo(myuser);
}
},
processGetUserInfo(myuser) {
this.setNewData(myuser);
// etmsPost(
// app.globalData,
// "openParent2/WxMiniEditUserInfo", {
// nickName: myuser.nickName,
// avatarUrl: myuser.avatarUrl,
// },
// () => {
// this.setNewData(myuser);
// }
// );
},
setNewData(info) {
this.setData({
nickName: info.nickName
})
this.setData({
avatarUrl: info.avatarUrl
})
this.setData({
isGetUser: true
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// if (wx.getUserProfile) {
// this.setData({
// canIUseGetUserProfile: true
// })
// }
this.setData({
nickName: app.globalData.nickName
})
this.setData({
avatarUrl: app.globalData.avatarUrl
})
this.setData({
isGetUser: app.globalData.isGetUser
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {},
});
@@ -0,0 +1,4 @@
{
"usingComponents": {},
"navigationBarTitleText": "个人中心"
}
@@ -0,0 +1,35 @@
<view>
<view class="my-body">
<view class="my-section">
<view class="my-body-info">
<block wx:if="{{isGetUser === false}}">
<view class="my_getuser_tp">
<text class="page-body-text">未获取</text>
<text class="page-body-text">点击按钮可获取用户头像及昵称</text>
</view>
</block>
<block wx:if="{{isGetUser === true}}">
<view class="my_show_content">
<view class="my_show_yes">
<view class="my_show_yes_left">
<text class="userinfo-nickname">{{nickName}}
</text>
</view>
<view class="my_show_yes_right">
<image wx:if="{{canIUseGetUserProfile}}" bindtap="handleGetUserProfile" class="userinfo-avatar" src="{{avatarUrl}}"></image>
<button class="chooseAvatarButton" wx:else type="primary" plain="true" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
<image open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar" class="userinfo-avatar" src="{{avatarUrl}}"></image>
</button>
</view>
</view>
</view>
</block>
</view>
<view class="btn-area" wx:if="{{isGetUser === false}}">
<button wx:if="{{canIUseGetUserProfile}}" type="primary" bindtap="handleGetUserProfile"> 获取用户信息</button>
<button wx:else type="primary" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">获取用户信息</button>
</view>
</view>
</view>
</view>
@@ -0,0 +1,48 @@
@import "../com/etms.wxss";
.my_user_content {
text-align: right;
margin-top: 20px;
}
.page-body-info {
padding-bottom: 0;
height: 230px;
}
.userinfo-avatar {
overflow: hidden;
width: 158rpx;
height: 158rpx;
margin: 20rpx;
border-radius: 50%;
}
.my_show_content {
width: 100%;
}
.my_show_yes {
height: 150px;
background: -webkit-linear-gradient(right, #FE1F38, #FE402E, #FE5329);
color: white;
font-weight:600;
display: flex;
border-radius: 4px;
margin: 10px;
line-height: 150px;
}
.my_show_yes_left {
width: 50%;
margin-left: 10px;
}
.my_show_yes_right {
width: 50%;
text-align: right;
margin-right: 10px;
}
.chooseAvatarButton{
border: 0px !important;
}