<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<text class="title">{{title}}{{userInfo.name}}</text>
		</view>
    <up-button type="primary" :plain="true" text="镂空"></up-button>
	</view>
</template>

<script>
  import { useUserStore } from '../../stores/user.js'
  import { mapState, mapActions } from 'pinia'
  import { rgbToHex } from 'uview-plus'
  import { login } from '../../api/user.js'

	export default {
		data() {
			return {
				title: 'Hello'
			}
		},
    computed: {
      // 允许读取this.userInfo
      ...mapState(useUserStore, ['userInfo'])
    },
		async onLoad () {
      this.update()
      const data = await login({ code: '123' })
      console.log(data)
      console.log(rgbToHex('rgb(13, 145, 20)'))
      console.log(111, uni.$u.config.v)
    },
		methods: {
      // 允许调用this.updateUserInfo()
      ...mapActions(useUserStore, ['updateUserInfo']),
      update() {
        this.updateUserInfo({ name: '123' })
        console.log(111, this.userInfo)
      }
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
    margin: 200rpx auto 50rpx;
  }

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
