<template>
	<view>
		<scroll-list ref="list" :option="option" @load="load" @refresh="refresh" @loadSuccess="loadSuccess"
			@scrolltolower="scrolltolower">
			<view v-for="(item, index) in list" :key="index" @click="handleTest(item)">
				<view class="infoBody">
					<view>
						<view style="border-bottom: 1px #b8b8b8 solid;">
							<uni-row class="demo-uni-row">
								<uni-col :span="12">
									<view class="demo-uni-col dark"
										style="font-size: 36rpx;margin: -20rpx 0 0 0;font-weight: bold;letter-spacing:5rpx;">
										{{item.userName}}
									</view>
								</uni-col>
								<uni-col :span="12">
									<view class="demo-uni-col light" style="padding-bottom: 20rpx;">
										{{item.phone}}
									</view>
								</uni-col>
							</uni-row>
						</view>
						<uni-row class="demo-uni-row">
							<uni-col>
								<view class="demo-uni-col light" style="padding: 8rpx;color: #959595;">
									<view v-if="item.provinces ">
										{{item.provinces}}
									</view>
									<view v-if="item.detailedAddress">
										{{ item.detailedAddress}}
									</view>
								</view>
							</uni-col>
						</uni-row>
						<uni-row class="demo-uni-row">
							<uni-col :span="13">
								<view class="demo-uni-col light" style="color: #727272;">

								</view>
							</uni-col>
							<uni-col :span="11">
								<view class="demo-uni-col light" style="color: #727272;">

								</view>
							</uni-col>
						</uni-row>
					</view>
				</view>
			</view>
		</scroll-list>
		<view>
			<view class="content" @click="plusAdd">
				<!-- @touchstart="handleStart" @touchmove="handleMove" @touchend="handleEnd" -->
				<view :style="{'transform':'translate3d('+0+'px,'+-80+'px,0)'}" class="touch">
					<view style="font-size: 45rpx;">
						+
					</view>
				</view>
			</view>
		</view>
	</view>
</template>
<style lang="scss">

	.touch {
		position: fixed;
		right: 40rpx;
		bottom: 60rpx;
		width: 95rpx;
		height: 95rpx;
		/* 知识点
		line-height是行高，针对的对象是文字，height针对的是容器，
		也就是高度，当height和line-height值相同时会居中，
		当line-height值小于height时文字向上移动，反之向下移动。
		 */
		line-height: 95rpx;
		/* 文字垂直居中 */
		text-align: center;
		/* 水平居中 */
		background-color: rgba(0, 0, 0, 0.6);
		border-radius: 50%;
		color: #fff;
		font-size: 60rpx;
		/* 去除标签点击事件高亮效果 */
		-webkit-tap-highlight-color: transparent;
		/* 使用transform: translate3d 处理性能高 GUP */
	}

	.page-wrap {}

	.infoBody {
		background-color: #ffffff;
		padding: 40rpx;
		border-radius: 20rpx;
		margin: 20rpx;
		box-shadow: 0px 2px 10px #cccccc;
	}

	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}
</style>
<script>
	export default {
		data() {
			return {
				option: {
					page: 1,
					size: 5,
					auto: true
				},
				userName: uni.getStorageSync("userInfo").nickName,
				page: 1,
				list: [],
				total: 0,
				clickType: 0
			}
		},
		onLoad() {},
		onShow() {
			this.refresh({
				page: 1,
				size: 5
			})
		},
		methods: {
			plusAdd() {
				uni.navigateTo({
					url: 'addressMgt',
					success() {
						uni.removeStorageSync("addressData")
					}
				})
			},
			handleTest(item) {
				if (uni.getStorageSync("clickType") === 0) {
					uni.setStorageSync("addressData", item)
					this.$goto('addressMgt')
				} else {
					uni.redirectTo({
						url: '../../pages/integral/list',
						success() {
							uni.setStorageSync("addressData", item)
							uni.setStorageSync("clickType", 1)
						}
					})
				}
			},
			async taskList(paging) {
				// 发送请求
				const {
					data: res
				} = await this.$httpRequest({
					url: '/app/uadsList?userCode=' + uni.getStorageSync("userInfo").userName + '&pageNum=' +
						paging.page +
						'&pageSize=' + paging.size,
					method: 'get',
					urlType: 2
				});
				if (res.code === 200) {
					setTimeout(() => {
						if (paging.page === 1) {
							//this.list = res.rows
							this.total = res.total
							this.$refs.list.loadSuccess({
								list: res.rows,
								total: this.total
							});
						} else if (paging.page > 1) {
							for (var i = 0; i < res.rows.length; i++) {
								this.list.push(res.rows[i])
							}
							this.$refs.list.loadSuccess({
								list: this.list,
								total: this.total
							});
						}
					}, 300)
				}
			},
			// 刷新刷剧
			refresh(paging) {
				this.taskList(paging)
			},
			scrolltolower(e) {
				console.log(e)
			},
			load(paging) {
				console.log(2, paging)
				this.taskList(paging)
			},
			loadSuccess(list) {
				console.log(3, list)
				this.list = list
			}
		}
	}
</script>
