<template>
	<view>

		<view class="flex-row justify-center">
			<image class="face" mode="widthFix" :src="userInfo.techFaceUrl || '/static/my/renlian.png'"></image>
		</view>

		<view class="flex-row justify-center">
			<button class="btn" @click="navigateTo('/pages/ShootFace/ShootFace?username='+ userInfo.name)">更新人脸</button>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo:{}
			}
		},
		onLoad(){
		},
		onShow(){
			this.getUserInfo()
		},
		methods: {
			getUserInfo(){
				this.$api.user.getUserInfo().then(res=>{
					this.userInfo = res.data.data
					uni.setStorageSync('userInfo', this.userInfo )
					if (this.userInfo.techFaceId){
						this.getImgUrlByOssId(this.userInfo.techFaceId)
					}
				})
			},

			getImgUrlByOssId(ossId){
				this.$api.service.getImgUrlByOssId({ossId:ossId}).then(res=>{
					this.$set(this.userInfo,'techFaceUrl', res.data.data[0].url.replace(/^http:/, "https:"))
					uni.setStorageSync('userInfo', this.userInfo )
				})
			},

			navigateTo(url){
				uni.navigateTo({
					url:url
				})
			},
		}
	}
</script>


<style lang="scss">
	@import './index.rpx.css';
</style>
