<template>
	<view class="container mine clearfix">
		<view class="tui-header-box first"
			:style="{ height: isCmcustomClass == 'fiexd' ? CustomBar + 10 + 'px' : CustomBar + 30 + 'px' }"
			:class="isCmcustomClass">
			<view class="header-top" :style="{ paddingTop: top + 'px', lineHeight: CustomBar + 30 + 'px' }"></view>
			<view class="header-sit">
				<text class="iconfont icon-fanhui" @click.stop="this.$api.navigateBack(1)"></text>
				<text class="header-sit-text">款项信息</text>
			</view>
		</view>
		<view class="tui-header-box"
			:style="{ height: CustomBar + 30 + 'px', backgroundImage: 'url(https://static.caimei365.com/app/crm/image/statistic_bg1.png)' }">
		</view>
		<tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading	="true" :loadingType="7"></tui-skeleton>
		<view class="distinguish-section" v-else :style="{ top: CustomBar + 'px', left: 0 + 'px' }">
			<view class="distinguish-section-conten">
				<view class="section-rows">
					<view class="rows-label">收款金额：</view>
					<view class="rows-mains">
						<text>￥{{ receipt.receiptAmount | NumFormat }}</text>
					</view>
				</view>
				<view class="section-rows">
					<view class="rows-label">收款类型：</view>
					<view class="rows-mains">
						<text>{{ receipt.payTypeText }}</text>
					</view>
				</view>
				<view class="section-rows">
					<view class="rows-label">收款时间：</view>
					<view class="rows-mains">
						<text>{{ receipt.receiptDate }}</text>
					</view>
				</view>
				<view class="section-rows">
					<view class="rows-label">手续费：</view>
					<view class="rows-mains">
						<text>￥{{ receipt.handlingFee ? (receipt.handlingFee | NumFormat) : '0.00' }}</text>
					</view>
				</view>
				<view class="section-title">收款短信</view>
				<view class="section-textarea msg">
					<view class="textarea">{{ receipt.smsContent ? receipt.smsContent : '无' }}</view>
				</view>
			</view>
			<view class="distinguish-button">
				<button class="button" open-type="share" :data-receipt="receipt">分享</button>
			</view> 
		</view>
	</view>
</template>
<script>
	import wxLogin from '@/services/wxLogin.js'
	import {
		mapState,
		mapMutations
	} from 'vuex'

	export default {
		data() {
			return {
				receipt:{},
				payDetailsId:0,
				nvabarData: {
					//顶部自定义导航
					showCapsule: 1, // 是否显示左上角图标  1表示显示  0表示不显示,
					showSearch: 0,
					title: '', // 导航栏 中间的标题
					haveBack: false,
					home: false,
					textLeft: this.$store.state.isIphone,
					bgColor: '#D33020',
					textColor: '#ffffff'
				},
				modalButton: [{
						text: '取消',
						type: 'gray',
						plain: true //是否空心
					},
					{
						text: '确认',
						customStyle: {
							color: '#fff',
							bgColor: '#4688fa'
						},
						plain: false
					}
				],
				isCmcustomClass: 'left',
				CustomBar: this.CustomBar, // 顶部导航栏高度
				skeletonShow:true,
				height: 64, //header高度
				top: 0, //标题图标距离顶部距离
				scrollH: 0, //滚动总高度
				opcity: 1,
			}
		},
		computed: {
			...mapState(['hasLogin'])
		},
		onLoad(option) {
			let obj = {}
			// #ifdef MP-WEIXIN
			obj = wx.getMenuButtonBoundingClientRect()
			// #endif
			// #ifdef MP-BAIDU
			obj = swan.getMenuButtonBoundingClientRect()
			// #endif
			// #ifdef MP-ALIPAY
			my.hideAddToDesktopMenu()
			// #endif
			uni.getSystemInfo({
				success: res => {
					this.width = obj.left || res.windowWidth
					this.height = obj.top ? obj.top + obj.height + 8 : res.statusBarHeight + 44
					this.top = obj.top ? obj.top + (obj.height - 32) / 2 : res.statusBarHeight + 6
					this.scrollH = res.windowWidth * 0.6
				}
			})
			this.payDetailsId = option.id
			this.getOrderReceiptDetail(option.id)
		},
		methods: {
			getOrderReceiptDetail(id){
				// 收款详情
				this.OrderService.orderReceiptDetail({ id : id})
					.then(response => {
						this.receipt = response.data
						this.skeletonShow = false
					})
					.catch(err => {
						this.$util.msg(err.msg, 2000)
					})
			},
			formatReceiptType(value) {
				//订单状态文字和颜色
				var HtmlStateText = '',
					stateTextObject = {
						1: '订单',
						2: '非订单',
						3: '返佣',
						4: '订单款或者非订单款',
						5: '供应商退款'
					}
				Object.keys(stateTextObject).forEach(function(key) {
					if (key == value) {
						HtmlStateText = stateTextObject[key]
					}
				})
				return HtmlStateText
			},
		},
		onPageScroll(e) {
			//实时获取到滚动的值
			// if (e.scrollTop > 30) {
			// 	this.isCmcustomClass = 'fiexd'
			// } else {
			// 	this.isCmcustomClass = 'left'
			// }
		},
		onPullDownRefresh() {
			setTimeout(() => {
				this.getOrderReceiptDetail(this.payDetailsId)
				uni.stopPullDownRefresh()
			}, 200)
		},
		onShareAppMessage(res) {
			//分享收款详情
			const receipt = res.target.dataset.receipt
			const receiptTypeText = this.formatReceiptType(receipt.receiptType)
			if (res.from === 'button') {
				// console.log('来自页面内转发按钮')
				return {
					title: `【${receipt.receiptStatusText}(${receiptTypeText})】收款金额${receipt.receiptAmount.toFixed(2)}元,收款时间:${receipt.receiptDate}`,
					path: `/pages/login/login-share?id=${receipt.id}`,
					imageUrl: 'https://static.caimei365.com/app/img/icon/icon-shareCoupon@2x.png'
				}
			}
		},
		onShow() {
			
		}
	}
</script>

<style lang="scss">
	@import '@/uni.scss';

	page {
		background: #fff;
	}

	.tui-header-box {
		width: 100%;
		background: #ffffff;
		z-index: 999;
		background-image: url(https://static.caimei365.com/app/crm/image/statistic_bg2.png);
		background-size: cover;
		&.fiexd {
			position: fixed;
			top: 0;
			left: 0;
		}
	}
	.header-top {
		width: 100%;
		font-size: 16px;
		font-weight: 500;
		height: 32px;
		display: flex;
		align-items: center;
		justify-content: center;
		position: relative;
		padding: 0 40rpx;
	}

	.header-sit {
		width: 100%;
		box-sizing: border-box;
		height: 80rpx;
		line-height: 80rpx;
		box-sizing: border-box;
		color: #ffffff;

		.header-sit-text {
			text-align: left;
			font-size: $font-size-40;
			font-weight: 600;
			font-family: '正楷';
		}
		.icon-fanhui {
			display: block;
			width: 80rpx;
			height: 80rpx;
			float: left;
			text-align: center;
			line-height: 80rpx;
			font-size: 42rpx;
		}
	}

	.mine {
		width: 100%;
		height: 100%;
		position: relative;
	}

	.distinguish-section {
		width: 100%;
		position: absolute;
		padding: 20rpx 20rpx;
		box-sizing: border-box;
	}

	.distinguish-section-conten {
		width: 100%;
		height: auto;
		position: relative;
		background-color: #ffffff;
		border-radius: 20rpx;
		padding: 20rpx;
		box-shadow: 0 10rpx 14rpx 0 rgba(86, 119, 252, 0.2);
		.section-rows {
			width: 100%;
			height: 80rpx;
			box-sizing: border-box;
			padding: 0 20rpx;
			border-radius: 8rpx;
			background: #f8f8f8;
			margin-bottom: 20rpx;
			line-height: 80rpx;
			display: flex;
			position: relative;

			&.disabled {
				background: #e1e1e1;
			}

			.rows-label {
				flex: 3;

				.iconfont {
					margin-right: 8rpx;

					&.icon-yixuanze {
						color: $color-system;
					}
				}
			}

			.rows-mains {
				flex: 7;
				text-align: left;
				font-size: $font-size-28;
				color: #666666;
				height: 80rpx;
				line-height: 80rpx;
			}

			.icon-xiayibu {
				display: block;
				width: 40rpx;
				height: 80rpx;
				position: absolute;
				right: 0;
				text-align: center;
				font-size: $font-size-32;
			}
		}

		.section-title {
			width: 100%;
			height: 40rpx;
			box-sizing: border-box;
			padding: 0 20rpx;
			text-align: left;
			font-size: $font-size-28;
			color: #333333;
			line-height: 40rpx;
			font-weight: bold;
			margin-bottom: 20rpx;
		}

		.section-textarea {
			width: 100%;
			height: 180rpx;
			box-sizing: border-box;
			padding: 20rpx;
			background: #f7f7f7;
			border-radius: 8rpx;

			&.msg {
				height: 180rpx;
				margin-bottom: 10rpx;
			}

			.textarea {
				width: 100%;
				height: 100%;
				color: #666666;
			}
		}
	}

	.distinguish-button {
		width: 100%;
		height: 80rpx;
		margin-top: 100rpx;
		box-sizing: border-box;
		padding: 0 50rpx;

		.button {
			width: 100%;
			height: 80rpx;
			background: $btn-confirm;
			border-radius: 40rpx;
			text-align: center;
			color: #ffffff;
			line-height: 80rpx;
			font-size: $font-size-28;
		}
	}

	.uni-badge--small {
		-webkit-transform: scale(0.8);
		-ms-transform: scale(0.8);
		transform: scale(0.8);
		-webkit-transform-origin: center center;
		-ms-transform-origin: center center;
		transform-origin: center center;
	}

	.uni-badge {
		font-family: 'Helvetica Neue', Helvetica, sans-serif;
		-webkit-box-sizing: border-box;
		box-sizing: border-box;
		font-size: 12px;
		line-height: 1;
		display: inline-block;
		padding: 3px 6px;
		color: #333;
		border-radius: 100px;
		background-color: #f1f1f1;
	}

	.uni-badge-error {
		color: #fff;
		background-color: #dd524d;
	}
</style>
