<style lang="less">
.login-box {
  padding-top: 40px;
  .avatar-wrapper {
    padding: 0px;
    width: 160rpx;
    height: 160rpx;
    border-radius: 50%;
    image {
      width: 160rpx;
      width: 160rpx;
      border-radius: 50%;
    }
  }
  .avatar {
    width: 160rpx;
    height: 160rpx;
  }

  .weui-input {
    margin: 0 auto;
    margin-top: 40rpx;
    padding: 0 20rpx;
    width: 548rpx;
    height: 100rpx;
    line-height: 100rpx;
    border-radius: 5px;
    border: 1px solid rgba(61, 203, 204, 1);
  }
  .bind-btn {
    margin-top: 100rpx;
    width: 548rpx;
    height: 100rpx;
    line-height: 100rpx;
    border-radius: 56rpx;
    background: rgba(61, 203, 204, 1);
    border: none;
    font-family: PingFang SC;
    font-size: 32rpx;
    font-weight: 400;
    letter-spacing: 0px;
    text-align: center;
    color: #fff;
  }
  .phone-tip {
    padding-top: 32rpx;
    font-family: PingFang SC;
    font-size: 28rpx;
    font-weight: 400;
    line-height: 44rpx;
    letter-spacing: 0px;
    text-align: center;
    color: rgba(139, 148, 158, 1);
    text-align: center;
  }
  .home-btn {
    margin-top: 240rpx;
    width: 548rpx;
    height: 100rpx;
    line-height: 100rpx;
    border-radius: 56rpx;
    border: 1px solid rgba(61, 203, 204, 1);
  }
}
</style>
<template>
 <div class="login-box">
  <button class="avatar-wrapper"
    open-type="chooseAvatar" 
    bind:chooseavatar="onChooseAvatar">
    <image class="avatar" src="{{avatarUrl}}"/>
  </button> 
  <form bindsubmit="submit">
    <input type="nickname" 
    value="{{nicknameValue}}"
     class="weui-input" 
    placeholder="请输入昵称"/>
  </form>  
  <button class="bind-btn"
  open-type="getPhoneNumber"
  @click="goBindTenant">微信手机号认证</button>

   <!-- bindgetphonenumber="phonenumberAuth" -->
  <div class="phone-tip">确保是入职公司使用的手机号</div>
  <button class="home-btn" @click="goHome">首页</button>
 </div>
</template>

<script>
import wepy from '@wepy/core';
import { mapState } from '@wepy/x';
import store from '@/store';
import { setUserInfoByAuth } from '@/service/user';
let defaultAvatarUrl = '';
wepy.page({
  store,
  config: {
    navigationBarTitleText: 'test'
  },
  data: {
    nicknameValue: '',
    avatarUrl: defaultAvatarUrl,
    msg: '测试数据',
    userInformation: wx.getStorageSync('userInformation')
  },
  onLoad() {
    if (wx.getUserProfile) {
      this.canIUseGetUserProfile = true;
    }
  },
  onShow() {
    // this.checkAuthCamra();
  },
  methods: {
    // 绑定租户
    bindTenant() {},
    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;
        }
      });
    },
    goHome() {
      wx.navigateTo({
        url: '/packagesEnv/pages/home/index'
      });
    },
    // 手机号认证
    phonenumberAuth(e) {},
    goBindTenant() {
      console.log('被点击了');
      wx.navigateTo({
        url: '/pages/bindTenant/index'
      });
    }
  },
  created() {}
});
</script>
<config>
{
navigationBarTitleText: '首页',
}
</config>
