<template>
  <div class="usercombox" :style="{'background-image':'url('+ts.backgroundPicUrl+')'}">
    <div :class="{'defaultbox':ts.style==1,'style2box':ts.style==2,'style3box':ts.style==3}" :style="{'background-color':ts.backgroundColor}">
      <img :src="u.avatarUrl" />
      <div class="text">{{u.nickName}}</div>
    </div>
    <auth v-if="showAuth" @changeuserinfo="reloadUserinfo" @gbAuth="gbAuth"></auth>
  </div>
</template>

<script>
import auth from "../auth/index";
export default {
  props: ["ts"],
  components: {
    auth
  },
  data() {
    return {
      u: {},
      showAuth: false
    };
  },
  created() {
    this.u = uni.getStorageSync("mall_UserInfo");
    if (!this.u) {
      this.u = {
        nickName: "未登录",
        avatarUrl: ""
      };
      this.showAuth = true;
    }
  },
  methods: {
    reloadUserinfo() {
      this.u = uni.getStorageSync("mall_UserInfo");
      this.showAuth=false
    },
	//关闭登录窗口
	gbAuth(){
		this.showAuth=false;
	}
  }
};
</script>

<style>
.usercombox {
  height: 300rpx;
  display: flex;
  align-items: center;
  background-repeat: no-repeat;
  background-size: cover;
}
.usercombox .defaultbox {
  margin: 0 35px;
  display: flex;
  align-items: center;
  background: none !important;
  width: 1rpx;
  flex: 1;
}
.usercombox .defaultbox img {
  width: 38px;
  height: 38px;
  margin-right: 12px;
  background: #ddd;
  border-radius: 100%;
}
.usercombox .defaultbox .text {
  font-size: 12px;
  color: #fff;
  width: 1rpx;
  flex: 1;
}
.usercombox .style2box {
  margin: 0 35px;
  display: flex;
  align-items: center;
  justify-items: center;
  flex-direction: column;
  background: none !important;
  width: 1rpx;
  flex: 1;
}
.usercombox .style2box img {
  width: 38px;
  height: 38px;
  margin-right: 12px;
  background: #ddd;
  border-radius: 100%;
}
.usercombox .style2box .text {
  font-size: 12px;
  color: #fff;
  flex: 1;
  margin-top: 4px;
}
.usercombox .style3box {
  margin: 0 25px;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  width: 1rpx;
  flex: 1;
  border-radius: 10rpx;
}
.usercombox .style3box img {
  width: 38px;
  height: 38px;
  margin-right: 12px;
  background: #ddd;
  border-radius: 100%;
}
.usercombox .style3box .text {
  font-size: 12px;
  color: #333;
  width: 1rpx;
  flex: 1;
}
</style>