<style lang="less">
.overflow-wrap {
  width: 100%;
  height: 100%;
  .scroll-view {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 2;
  }
}
.avatar-wrapper {
  width: 80px;
  height: 80px;
}
.avatar {
  width: 80px;
  height: 80px;
}
</style>
<template>
 <button class="avatar-wrapper"
    open-type="chooseAvatar" 
    bind:chooseavatar="onChooseAvatar">
    <image class="avatar" src="{{avatarUrl}}"/>
  </button> 
</template>

<script>
import wepy from '@wepy/core';
import eventHub from '@/common/eventHub';
import { mapState } from '@wepy/x';
import store from '@/store';
import testMixin from '@/mixins/test';
import { setUserInfoByAuth } from '@/service/user';
let defaultAvatarUrl =
  'data:image/png;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDABQODxIPDRQSEBIXFRQYHjIhHhwcHj0sLiQySUBMS0dARkVQWnNiUFVtVkVGZIhlbXd7gYKBTmCNl4x9lnN+gXz/2wBDARUXFx4aHjshITt8U0ZTfHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHz/wAARCACEAIQDASIAAhEBAxEB/8QAGgAAAgMBAQAAAAAAAAAAAAAABAUAAgMGAf/EADQQAAICAQMDAwIEBAYDAAAAAAECAAMRBBIhBTFBIlFhE3EyQoGhBhQjUhUkM7HR8GKRwf/EABgBAAMBAQAAAAAAAAAAAAAAAAABAgME/8QAHREBAQEBAQEBAQEBAAAAAAAAAAERAiExEkEDMv/aAAwDAQACEQMRAD8A6au9bBg8GXImD0bTnsZEtK8N2kG0YSh+00JBXK8TIPk4IIEA8IEqV+ZpMdRYKqyx9oBhfatIJz9+Ytt6sg5HIHkRd1PUvcxBbC+2YsdnUqofmTPF5h5d1kLjYnf3MGHWrt34VZfjvFp9Q7Z95mFIY4+4geOl0+vqvAz6T7HvGFDckZ7/APf+ZzGmyxBHc/vHvTy3Hkf7Rb6d482GI7mXlPJlxKZvRLATwS6iMsx7tklsyQDWzKj1jj3mLJn2h0yNI7px8eI7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sGD5ma6ipMKm5j7hSZEYNYeMcRyeJtZW1Mx3cD4HModTZW3fIEPwCIPfUGU8SiE02rcgdTnMvjET6V30epwxP0m/aOQQRkQwMrKxjEwqTc+0DC5xDCARgzG3fXW7UqGcDgHyfaTYqXE1DcYMzpOyp2ifTfxFTrr0066e5b2ONvBA/WPWArpx7DiKHXLdRsZ7i7DAJ7GAbSNjf8AlzGWrU33MADjOT8SjUcA49OZDWX0FYrB99YzjuBNaKzqnNaoxB5BH5YUNK1Ny8HaexAzH+g0tSKHFY3HziOclewPTujsjq1xyq9h5jpKEBziXAlhLzGVtr3EkkkCA08rzPWADAySRhZe89IMkkAG1FalTkTXQMTTgnODgSSRkKlH7SSQBfR07S1dS/ma6QtpByQe+fiHag/0zJJJh0rtqVaRgct3MpXUraZgRwDxJJF/VT4KNa/y+ccrjBjCr8AkklJaSCSSAeySSQD/2Q==';

let baseurl = `http://api.sagacloud.cn
/dp-auxiliary/image-service/common
/file_get?systemId=dataPlatform`;
let updateUrl = `http://api.sagacloud.cn/dp-auxiliary/image-service/common/file_upload?systemId=dataPlatform&secret=9e0891a7a8c8e885`;

wepy.page({
  store,
  config: {
    navigationBarTitleText: 'test'
  },
  data: {
    avatarUrl: defaultAvatarUrl,
    msg: '测试数据',
    userInformation: wx.getStorageSync('userInformation')
  },
  onLoad() {
    if (wx.getUserProfile) {
      this.canIUseGetUserProfile = true;
    }
  },
  onShow() {
    // this.checkAuthCamra();
  },
  methods: {
    onChooseAvatar(e) {
      // console.log('被点击了');
      // console.log('被点击了',e)
      console.log('avatarUrl', e.$wx.detail.avatarUrl);
      console.log(e.$wx);
      this.avatarUrl = e.$wx.detail.avatarUrl;
      let avatarUrl = this.avatarUrl;
      let baseImg = [];
      let key = e.$wx.timeStamp;
      let that = this;
      wx.getFileSystemManager().readFile({
        filePath: avatarUrl,
        encoding: 'base64',
        success: function(res) {
          console.log(res.data);
          that.avatarUrl = 'data:image/png;base64,' + res.data;
        }
      });
    },
    goEnv() {
      wx.navigateTo({
        url:
          '/packagesEnv/pages/officehome/index?spaceId=Sp1101080259b3510e26e7dd4dd9bf9784f06f3feb68'
      });
    },
    goPortrait() {
      wx.navigateTo({
        url: '/packagesEnv/pages/portrait/home'
      });
    }
  },
  created() {}
});
</script>
<config>
{
navigationBarTitleText: '首页',
usingComponents: {
}
}
</config>
