<template>
	<view style="">
		
		<view v-for="(item,index) in list" :key="index" style="">
			<view class="" style="flex-direction: row;margin: 2%;">
				<view class="">
					<image src="../../static/logo.png" style="height: 80rpx;width: 80rpx;border-radius: 5px;"></image>
				</view>
				<view class="" style="margin-left: 5px;width: 100%;">
					<view class="" style="margin-bottom: 10px;">
						<text style="color: #576b96;font-size: 18px;">{{item.nicheng}}</text>
					</view>
					<view class=""><text style="font-size: 18px;">{{item.wenben}}</text></view>
					<view class="" v-if="item.tupian.length<2" style="width: 100%;">
						<image :src="item.tupian[0]" mode="widthFix" @click="previewImage(0,item.tupian)" style="width: 100%;"></image>
					</view>
					<view v-else class=""
						style="flex-direction: row;width: 100%;flex-wrap:wrap;margin-top: 10px;margin-bottom: 3px;">
						<view style="width: 203rpx;height:203rpx;margin-right: 3px;margin-bottom: 3px;"
							v-for="(item2,index2) in item.tupian" :key="index2">
							<image :src="item2" mode="widthFix"
								@click="previewImage(index2,item.tupian)"></image>
						</view>
					</view>
				</view>
			</view>
			<view class="" style="border-top: 1px solid #f5f5f5;"></view>
		</view>
		<view class="" style="height: 2300px;background-color: #576b96;z-index: 999;flex-direction: column;">这里怎么才能显示出来?</view>
		
		
		
		<!-- <text>{{ yuming }}</text>
		<view class="" style="height: 100rpx;"></view>
		<button @click="shanchu()" type="default">删除缓存</button>
		<view class="" style="height: 100rpx;"></view>
		<button @click="jiancha()" type="default">存放</button>
		<view class="" style="height: 100rpx;"></view>
		<button @click="chakan()" type="default">查看</button>
		<view class="" style="height: 100rpx;"></view>
		<button @click="plus" type="default">加加加</button> -->

	</view>
</template>

<script lang="uts">
	import { state, setGlobalNum, quanju } from '@/store/index.uts'
	type Neirong = {
		id : Number,
		tupian : string[],
		wenben : string,
		nicheng : string,
	}
	export default {
		data() {
			return {
				list: [] as Array<Neirong>,
				yuming: '',
				page: 1,
			}
		},
		onLoad() {
			this.fenye(1)
		},
		onPullDownRefresh() {
			this.page = 1;
			this.list = [];
			this.fenye(1)
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			this.page += 1;
			this.fenye(this.page)
		},
		onReady() {
			// this.jiancha()
		},
		methods: {
			fenye(page : number) {
				uni.request({
					url: quanju.yuming + '/zuopin/LimitZuopin',
					method: 'GET',
					data: {
						page: page,
						pagesize: 50,
					},
					success: res => {
						let aa = res.data as UTSJSONObject[]
						if (aa.length == 0) {
							return
						}
						for (var i = 0; i < aa.length; i++) {
							let tupian2 = aa[i].getArray("Tupian") as UTSJSONObject[]
							let shuzu1 = [] as Array<string>
							for (var k = 0; k < tupian2.length; k++) {
								shuzu1.push(quanju.yuming + '/tupian/' + tupian2[k]);
							}
							let nn : Neirong = {
								id: aa[i].getNumber("ID") as number,
								tupian: shuzu1,
								wenben: aa[i].getString("Wenben") as string,
								nicheng: aa[i].getString("Nicheng") as string
							}
							this.list.push(nn)
						}
						// console.log('===this.list==', this.list)
					}
				});
			},
			previewImage(index : number, dizhi : string[]) {
				uni.previewImage({
					urls: dizhi,
					current: index,
				})
			},
			fabClick() {
				uni.navigateTo({
					url: '/pages/fabu/fabu'
				})
			},
			shanchu() {
				uni.removeStorage({
					key: 'yonghu',
					success: () => {
						uni.showModal({
							title: '移除数据成功',
							showCancel: false,
						})
					},
					fail: () => {
						uni.showModal({
							title: '移除数据失败',
							showCancel: false,
						})
					},
				})
			},
			chakan() {
				let yonghu2 = uni.getStorageSync('yonghu');
				if (yonghu2 == '') {
					console.log('==不存在=', yonghu2)
				} else {
					let yy = yonghu2 as UTSJSONObject
					console.log('==kong==2=', yy.getNumber("id"))
					console.log('==kong==2=', yy.getString("nicheng"))
					console.log('==kong==2=', yy.getString("miyue"))
				}
			},
			jiancha() {
				let yonghu = uni.getStorageSync('yonghu');
				if (yonghu != '') {
					return
				}
				uni.request({
					url: quanju.yuming + '/yonghu/CreateYonghu',
					method: 'GET',
					data: {},
					success: res => {
						let rrs = res.data as UTSJSONObject
						let yonghu2 = {
							id: rrs.getNumber("ID"),
							nicheng: rrs.getString("Nicheng"),
							miyue: rrs.getString("Miyue")
						}
						uni.setStorageSync('yonghu', yonghu2);
					}
				});
			},
			plus() {
				console.log('=====', quanju.yuming)
				// setGlobalNum(state.globalNum + 1)
			}
		}
	}
</script>

<style>
</style>