<template>
	<loading-state ref="pageView" @request="request">
		<view v-for="(item,index) in data" style="display: flex;flex-direction: column;margin-top: 15px; margin-left: 15px; margin-right: 15px;">
			<view 
				style="display: flex;flex-direction: column;border:  1px solid #e29a68;width: 100%;border-radius: 20rpx;margin-top: 8px;"
				 @click="detail(item.orderSid)">
			
				<view class="use">
					<image style="width: 70rpx;height: 70rpx;position: absolute;right: 40px;"
						src="../../static/card_line.png"></image>
					<image src="../../static/gift.png" style="width: 30px;height: 30px;padding-left: 6px;"></image>
					<view style="flex: 1;display: flex;flex-direction: column;z-index: 1;">
						<view style="font-size: 14px;padding: 2px;padding-left: 5px;padding-top: 7px;">{{item.code}}
						</view>
					</view>
			
					<view 
						style="flex-shrink: 0;padding: 9px;font-size: 13px;z-index: 1;font-weight: 600;">{{item.reserveDate}}
					</view>
				</view>
				<view
					style="display: flex;flex-direction: column; padding: 10px;border-bottom-left-radius: 20rpx;border-bottom-right-radius: 20rpx;background-color: #fdf0ee;">
					
					<view style="width: 100%;display: flex;flex-direction: row;align-items: center;">
						<text>礼包类型：</text>
						<text>{{item.bagName}}</text>
					</view>
					<view  style="width: 100%;display: flex;flex-direction: row;align-items: center;margin-top: 5px;">
						<text>提货门店：</text>
						<text>{{item.store}}</text>
					</view>
					
				</view>
			</view>

		</view>
	</loading-state>
</template>

<script>
	export default {
		data() {
			return {
				page: {
					sid: '',
				},
				data: [

				]
			}
		},
		onLoad(options) {
			this.page.sid = options.sid
			this.request()
		},
		methods: {
			request() {
				let _this = this
				_this.$api.orderByCardSid(this.page.sid).then((resp) => {
					_this.data = resp
					// 成功 2
					_this.$nextTick(() => {
						_this.$refs.pageView.setLoadState(2)
					})
					
					// 无数据
					if(_this.data.length==0){
						_this.$nextTick(() => {
							_this.$refs.pageView.setLoadState(100)
						})
					}
					
				}).catch(e => {
					// 错误 1
					_this.$nextTick(() => {
						_this.$refs.pageView.setLoadState(1)
					})
				})
			},
			detail(sid) {
				uni.navigateTo({
					url: '/pages/card/card_record_detail?sid=' + sid
				})
			},
			
		}
	}
</script>

<style>
.use {
		display: flex;
		flex-direction: row;
		border-top-left-radius: 20rpx;
		border-top-right-radius: 20rpx;
		color: #FFF;
		align-items: center;
		background: linear-gradient(89.8deg, rgba(218, 51, 33, 1) -3.76%, rgba(237, 113, 53, 0) 300.05%);
	}

</style>