Browse Source

完善修改个人信息、上传头像

epass
wangyx 3 months ago
parent
commit
eb709bfcd2
  1. 33
      subpages/mine/editUser/editUser.js
  2. 34
      subpages/mine/editUser/editUser.wxml
  3. 13
      subpages/mine/editUser/editUser.wxss

33
subpages/mine/editUser/editUser.js

@ -59,12 +59,45 @@ Page({
volunOrgList: [], volunOrgList: [],
showVolunOrg: false, showVolunOrg: false,
traceId: "", traceId: "",
remainingDays:10
},
// 上传头像
chooseAvatar() {
wx.chooseMedia({
count: 1, // 最多选择 1 张图片
mediaType: ['image'], // 只选择图片
success: (res) => {
if (res.tempFiles.length > 0) {
const tempFilePath = res.tempFiles[0].tempFilePath;
this.setData({
avatarUrl: tempFilePath
});
// 如果你需要将图片上传到服务器,可以在这里添加上传逻辑
// wx.uploadFile({
// url: 'your_upload_url',
// filePath: tempFilePath,
// name: 'avatar',
// success: (uploadRes) => {
// console.log('上传成功', uploadRes);
// },
// fail: (err) => {
// console.error('上传失败', err);
// }
// });
}
},
fail: (err) => {
console.error('选择图片失败', err);
}
});
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
// this.data.qqMapWX = new QQMapWX({ // this.data.qqMapWX = new QQMapWX({
// key: "CMJBZ-4DECI-JXGGN-5B4WU-QLV2H-B5BEJ", // key: "CMJBZ-4DECI-JXGGN-5B4WU-QLV2H-B5BEJ",
// }); // });

34
subpages/mine/editUser/editUser.wxml

@ -1,8 +1,7 @@
<view class="author "> <view class="author ">
<van-cell is-link center custom-class="cus-avatar"> <van-cell is-link center custom-class="cus-avatar" bind:tap="chooseAvatar">
<view slot="title"> <view slot="title">
<van-image width="55" height="55" round src="https://img.yzcdn.cn/vant/cat.jpeg" /> <van-image width="55" height="55" round src="{{avatarUrl || 'https://img.yzcdn.cn/vant/cat.jpeg'}}" />
</view> </view>
</van-cell> </van-cell>
<!-- <van-uploader style="margin-top: 15rpx;" file-list="{{ fileList }}" bind:delete="deleteImg" bind:after-read="afterRead" max-count="1" /> --> <!-- <van-uploader style="margin-top: 15rpx;" file-list="{{ fileList }}" bind:delete="deleteImg" bind:after-read="afterRead" max-count="1" /> -->
@ -14,26 +13,25 @@
<van-cell-group> <van-cell-group>
<van-field model:value="{{ nickName }}" placeholder="请输入" input-align="right" label="昵称" /> <van-field model:value="{{ nickName }}" placeholder="请输入" input-align="right" label="昵称" />
<!-- <van-divider /> --> <van-field model:value="{{ name }}" input-align="right" label="姓名" placeholder="请输入" />
<van-field model:value="{{ name }}" input-align="right" label="姓名" required placeholder="请输入" /> <van-field model:value="{{ idCard }}" label="身份证" input-align="right" type="idcard" placeholder="实名认证请输入身份证" border="{{ false }}" />
<!-- <van-divider /> --> <van-field model:value="{{ mobile }}" clearable input-align="right" label="手机号" placeholder="请输入" border="{{ false }}">
<van-field model:value="{{ idCard }}" label="身份证" input-align="right" type="idcard" required placeholder="实名认证请输入身份证" border="{{ false }}" />
<!-- <van-divider /> -->
<van-field model:value="{{ mobile }}" center clearable label="手机号" required placeholder="请输入" border="{{ false }}" use-button-slot>
<van-button slot="button" size="small" type="primary" round color="#f53e1f" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">
重新获取
</van-button>
</van-field> </van-field>
<!-- 住房剩余天数 -->
<van-field model:value="{{ housingDays }}" label="住房剩余天数" input-align="right" type="digit" placeholder="请输入" border="{{ false }}" />
</van-cell-group> </van-cell-group>
<!-- 住房剩余天数 -->
<!-- <van-field model:value="{{ housingDays }}" label="住房剩余天数" readonly input-align="right" type="number" placeholder="请输入" border="{{ false }}" :append="天">
</van-field> -->
</view>
<view class="day">
<van-cell title="住房剩余天数" value="{{remainingDays}}天" border="false" custom-class="cus-day">
</van-cell>
</view> </view>
<view style="width: 100%; text-align: center;margin-top: 20rpx;"> <view style=" text-align: center;margin-top: 220rpx;">
<view class="bot-btn"> <view class="bot-btn">
<van-button slot="button" type="primary" round color="#f53e1f" bind:tap="submit"> <van-button slot="button" type="primary" round color="linear-gradient(to right, #0DC6C6 , #46DBD5)" bind:tap="submit">
提交 确定
</van-button> </van-button>
</view> </view>
</view> </view>

13
subpages/mine/editUser/editUser.wxss

@ -64,7 +64,8 @@ page {
} }
.bot-btn .van-button--primary { .bot-btn .van-button--primary {
width: calc(100% - 40rpx); width: calc(100% - 10rpx);
height: 80rpx;
} }
.van-field__label { .van-field__label {
@ -79,7 +80,7 @@ page {
padding: 20rpx 0 !important; padding: 20rpx 0 !important;
} }
.cus-avatar{ .cus-avatar{
padding: 0 20rpx !important; padding: 20rpx 40rpx !important;
} }
.van-cell--required:before { .van-cell--required:before {
left: var(--padding-xs, -7px) !important; left: var(--padding-xs, -7px) !important;
@ -92,4 +93,10 @@ page {
.van-cell__value { .van-cell__value {
font-size: 30rpx; font-size: 30rpx;
} }
.day{
margin: 20rpx;
}
.cus-day{
padding: 20rpx !important;
border-radius: 8rpx;
}
Loading…
Cancel
Save