<!-- 更换头像 -->
<view class="updown-image" bindtap='upload'>
<view class="personal-img">
<image src="{{head}}" mode="aspecFill"></image>
</view>
<text class="personal-text" mode="aspecFill" bindtap="headimage">点击更换头像</text>
</view>
.updown-image {
width: 220rpx;
height: 162rpx;
border: 1rpx dashed #969696;
margin: 37rpx auto;
padding: 10rpx;
text-align: center;
margin-bottom: 145rpx;
}
.personal-img {
width: 160rpx;
height: 160rpx;
margin: 0 auto;
}
.personal-img image {
width: 100%;
height: 100%;
border-radius: 50%;
box-shadow: 0px 2rpx 8rpx 0rpx rgba(150, 150, 150, 0.6);
}
.personal-text {
display: inline-block;
font-size: 28rpx;
font-family: PingFang-SC-Regular;
font-weight: bold;
color: rgba(50, 50, 50, 1);
margin-top: 36rpx;
width: 170rpx;
}
Page({
data: {
showModal: false,
head: "https://dj.zjl9.com/static/images/vivi.jpeg",
},
// 点击换手机相册或者电脑本地图片
upload: function () {
var _this = this;
wx.chooseImage({
count: 1, // 默认9
sizeType: ['original', 'compressed'],
// 指定是原图还是压缩图,默认两个都有
sourceType: ['album', 'camera'],
// 指定来源是相册还是相机,默认两个都有
success: function (res) {
// 返回选定照片的本地文件路径tempFilePath可以作为img标签的src属性显示图片
_this.setData({
head: res.tempFilePaths
})
}
})
},