<template>
	<view class="content">
		<view class="list-item hflex acenter jbetween" v-for="(item,index) in list" :key="index">
			<view class="left">
				<view class="hflex aend left-top">
					<text>{{item.status == 'refused' ? '预约失败' : '预约成功'}}</text>
					<text>{{item.date}}</text>
				</view>
				<view class="left-bottom">恭喜！你已成功的提交了预约拍摄</view>
			</view>
			<view class="right">
				<view class="btn1" v-if="item.status == 'applied'" @click="show_wx = true">添加客服</view>
				<view class="btn1" v-else-if="item.status == 'refused'" @click="toyuyue">重新预约</view>
				<view class="btn2" v-else>已完成</view>
			</view>
		</view>
		<u-popup :show="show_wx" @close="tosubmit" mode="center" :round="10">
			<kefu-wx :wxcode="wxcode" @submit="tosubmit"></kefu-wx>
		</u-popup>
	</view>
</template>

<script>
	import kefuWx from './components/kefu-wx.vue'
	import $api from '@/static/js/api.js'
	export default {
		components: {
			kefuWx
		},
		data() {
			return {
				list: [],
				page: 1,
				last_page: 1,
				wxcode: '',
				show_wx: false,
			}
		},
		onLoad() {
			this.getlist()
			this.getcode()
		},
		onShow() {

		},
		onPullDownRefresh() {

		},
		onReachBottom() {
			if (this.page < this.last_page) {
				this.page++
				this.getlist()
			} else {
				uni.$u.toast('已经到底了')
				return
			}
		},
		methods: {
			getcode() {
				var that = this
				$api.req({
					url: 'config',
					data: {
						module: 'basic'
					}
				}, function(res) {
					that.wxcode = res.data.customer_service_qrcode
				})
			},
			tosubmit() {
				this.show_wx = false

			},
			toyuyue() {
				uni.navigateTo({
					url: '/pageB/yuyue-vip'
				})
			},
			getlist() {
				var _this = this
				$api.req({
					url: 'shoot-appointment',
					method: 'get',
					data: {
						is_page: 1,
						page: _this.page,
						limit: 10
					}
				}, function(res) {
					if (res.code == 10000) {
						_this.list = _this.list.concat(res.data.list)
						_this.last_page = res.data.last_page
						console.log('list=', _this.list);
					}
				})

			}
		}
	}
</script>

<style lang="scss">
	.content {
		padding: 20rpx 28rpx;

		.list-item {
			background: #FFFFFF;
			border-radius: 20rpx;
			margin: 0 0 20rpx;
			padding: 32rpx 20rpx;

			.right {
				.btn1 {
					width: 160rpx;
					height: 64rpx;
					background: #00B0B0;
					border-radius: 40rpx;
					font-size: 26rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					color: #FFFFFF;
					line-height: 64rpx;
					text-align: center;
				}

				.btn2 {
					width: 160rpx;
					height: 64rpx;
					background: #D5D5D5;
					border-radius: 40rpx;
					font-size: 26rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					color: #FFFFFF;
					line-height: 64rpx;
					text-align: center;
				}
			}

			.left {
				.left-top {
					text:first-child {
						font-size: 32rpx;
						font-family: PingFangSC, PingFang SC;
						font-weight: 600;
						color: #333333;
					}

					text:last-child {
						font-size: 24rpx;
						font-family: SFPro, SFPro;
						font-weight: 400;
						color: #444444;
						padding-left: 24rpx;
					}
				}

				.left-bottom {
					padding: 20rpx 0 0;
					font-size: 24rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					color: #999999;
				}
			}
		}
	}
</style>