<template>
	<view class="flex flex-column" style="width:100vw;height: 100vh;">
		<i-loading v-if="loading"></i-loading>
		<view class="bg-white px-3 pb-3 mx-2 rounded-lg mt-2">
			<view class="pt-3 font30">
				<view class="text-muted">点赞内容</view>
				<view class="mt-2">{{info.content}}</view>
			</view>
			<view class="flex align-center justify-between pt-3 font30">
				<view class="text-muted">点赞时间</view>
				<view>{{info.create_at}}</view>
			</view>
			<view class="pt-3 font30" v-if="info.imgs_arr.length > 0">
				<view class="text-muted">图片</view>
				<view class="mt-2">
					<image v-for="(item, index) in info.imgs_arr" :key="index" :src="item" mode="aspectFill" class="rounded-lg" style="width: 100px;height: 100px;margin-right: 10px;" />
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { TaCache } from '../../common/cache';
	import { TaAjax } from '@/common/ajax'
	
	export default {
		onLoad(options) {
			const userInfo = TaCache.get('auth.user');
			if (!userInfo) {
				this.login = false
			} else {
				this.login = true
			}
			this.id = options.id
			if (!this.id) {
				uni.showToast({
					title: '缺少参数',
					icon: 'none'
				})
				return uni.navigateBack()
			}
			this.loadInfo()
		},
		data() {
			return {
				id: 0,
				loading: false,
				login: false,
				info: {},
			}
		},
		methods: {
			loadInfo() {
				this.loading = true
				TaAjax.get((this.login ? '/cms/api.auth.Thumb/info?id=' : '/cms/api.Thumb/info?id=') + this.id).then(res => {
					console.log(res)
					this.info = res.data
				}).catch(err => {
					uni.showToast({
						title: err.info,
						icon: 'error',
					})
					uni.navigateBack()
				}).finally(() => {
					this.loading = false
				})
			}
		}
	}
</script>

<style>

</style>
