微信小程序-更换头像

<!-- 更换头像 -->
  <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
        })
      }
    })
  },

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

屋顶上的小喵

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值