<template>
	<view>
		<view class="list">
			<view class="item" v-for="(item,index) in list" :key="index">
				<view class="title">{{item.title}}</view>
				<view class="box">
					<view class="left">
						<view class="line">更新类型：{{item.type | set_type}}</view>
						<view class="line">更新内容：{{item.contents}}</view>
						<view class="line">更新时间：{{item.create_date | conversion}}</view>
					</view>
				</view>
				<view class="tip">{{item.version}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		set_appName
	} from '@/common/set_base_url.js'

	export default {
		data() {
			return {
				appName: "",
				list: []
			};
		},
		onLoad() {
			this.appName = set_appName(uni.getStorageSync('mine_code'))

			this.get_list()
		},
		methods: {
			get_list() {
				uni.showLoading({
					mask:true
				})
				uniCloud.callFunction({
					name: "get_version_record",
					data: {
						appName: this.appName
					}
				}).then((res) => {
					uni.hideLoading()
					console.log(res.result.data)

					this.list = res.result.data
				})
			}
		},
		filters: {
			conversion: function(value) {
				return new Date(value).toLocaleString();
			},
			set_type: function(value) {
				if(value == 'wgt'){
					return "资源包更新"
				}else if(value == 'native_app'){
					return "APP版本更新"
				}
			},
		},
	}
</script>

<style lang="scss">
	page {
		background-color: #F2FAF7;

		box-sizing: border-box;
		padding: 20rpx 25rpx;
	}

	.list {
		.item {
			position: relative;
			overflow: hidden;
			background-color: #FFFFFF;
			
			box-sizing: border-box;
			padding: 25rpx;

			border-radius: 15rpx;
			margin-bottom: 30rpx;
			
			.title{
				height: 70rpx;
				line-height: 70rpx;
				font-size: 36rpx;
				font-weight: 700;
			}
			.box{
				margin-top: 10rpx;
				.left {
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					.line{
						margin-top: 10rpx;
						line-height: 40rpx;
						font-size: 28rpx;
						color: #7f7f7f;
					}
				}
			}
			.tip{
				transform: rotate(45deg);
				
				background-color: #04A0E6;
				color: #FFFFFF;
				
				position: absolute;
				top: -14rpx;
				right: -46rpx;
				
				font-size: 24rpx;
				padding: 30rpx 40rpx 10rpx;
				
			}
		}
	}
</style>
