小程序上传头像

xml

	<!--pages/more/info/info.wxml-->
<view class="container">
    <view class="info-cont">
        <view class="infoMain">
            <view class="info-items" bindtap="setPhotoInfo">
                <text>头像</text>
                <view class="infotext">
                    <image wx:if="{{imgUrl!=null}}" class="userinfo-avatar" src="{{imgUrl}}" background-size="cover"></image>
                    <image wx:else class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image>
                    <image class="menu-item-arrow" src="/images/right.png"></image>
                </view>
            </view>
            <view class="info-items" bindtap="setName">
                <text>名字</text>
                <view class="infotext">
                   <text class="info-motto">{{infoname}}</text>
                    <image class="menu-item-arrow" src="/images/right.png"></image>
                </view>
            </view>
            <view class="info-items">
                <text>性别</text>
                <view class="infotext">
                   <picker bindchange="bindPickerChange" value="{{index}}" range="{{array}}" class="info-motto">
                        <view class="picker">
                       {{array[index]}}
                        </view>
                    </picker>
                    <image class="menu-item-arrow" src="/images/right.png"></image>
                </view>
            </view>
            <view class="info-items">
                <text>手机号</text>
                <view class="infotext">
                   <text class="info-motto">13812345678</text>
                </view>
            </view>
            <view class="info-items" bindtap="getregion">
                <text>地区</text>
                <view class="infotext">
                   <text class="info-motto">{{address}}</text>
                    <image class="menu-item-arrow" src="/images/right.png"></image>
                </view>
            </view>
        </view>
        <button type="warn"  bindtap="warn" class="buttonExit" > 退出 </button>
    </view>
</view>

wxss

/* pages/more/info/info.wxss */
.info-cont{
    border-top:solid 1px #f0f0f0;
    padding-top: 30rpx;
    display: flex;
    flex-direction: column;
	width: 100%;
}
.infoMain{
    border-bottom:solid 1px #f0f0f0;
    display: flex;
    background-color: #fff;
    flex-direction: column;
    margin-bottom: 30rpx;
}
.info-items{
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding:20rpx 40rpx;
    border-top:solid 1px #f0f0f0;

}
.infotext{
    display: flex;
    align-items: center;
}
.userinfo-avatar {
  width: 128rpx;
  height: 128rpx;
  margin: 0 20rpx;
  border-radius: 50%;
}
.info-motto{
     margin: 0 20rpx;
     color:#888;
}
.buttonExit{
    margin:0 40rpx;
}
.menu-item-arrow{
	width: 15rpx;
	height: 20rpx;
}

js

//logs.js
const util = require('../../utils/util.js')
Page({
  data: {
    warnSize:'default',
	imgUrl:null,
	infoname:'姓名',
	address:'China',
	array:['男','女'],
	index:1,
  },
  setPhotoInfo:function(){
	  var that=this;
	  wx.chooseImage({
		  count:1,
		  sizeType:['original','compressed'],
		  sourceType:['album','camera'],
		  success:function(res){
			  var tempFilePaths=res.tempFilePaths
			  that.setData({
				  imgUrl:tempFilePaths
			  })
		  }
	  })
  },

  onLoad: function () {
      var that = this;
     
      //获取用户信息
      wx.getUserInfo({
          success: function (res) {
   
              console.log(res);
              that.data.userInfo = res.userInfo;
   
              that.setData({
                  userInfo: that.data.userInfo
              })
          }
      })

}
})

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值