<template>
	<view class="user-center" :style="winHeight">
		<view class="top">
			<image class="bg-img" src="@/static/image/usercenter_bg.png" mode="aspectFill"></image>
			<view class="userinfo">
				<image class="avatar" src="@/static/image/avatar@3x.png" mode=""></image>
				<view class="nick-block">
					<text class="nick-block--name">{{userInfo.name || '--'}}</text>
					<text class="nick-block--no">编号：{{userInfo.code*1}}</text>
				</view>
			</view>
			<view class="amount-card">
				<view class="amount-card--order">
					<text class="amount-card--order_num">{{bpPrice.ORDER_PRICE}}</text>
					<text class="amount-card--order_text">订单金额</text>
				</view>
				<i class="divider"></i>
				<view class="amount-card--order amount-card--bill">
					<text class="amount-card--order_num">{{bpPrice.ZHIPIAO_PRICE}}</text>
					<text class="amount-card--order_text">开票金额</text>
				</view>
			</view>
		</view>
		<view class="middle">
			<view class="entry-block" @click="goPage('purchase-plan')">
				<view class="entry-bill">
					<image class="entry-bill-icon" src="@/static/image/usercenter_purchaseplan@3x.png" mode=""></image>
					<!-- <text class="entry-bill-dot">25</text> -->
				</view>
				<text class="entry-bill-text">采购计划</text>
			</view>

			<view class="entry-block" @click="goPage('produce-order')">
				<view class="entry-bill">
					<image class="entry-bill-icon" src="@/static/image/usercenter_produceorder@3x.png" mode=""></image>
				</view>
				<text class="entry-bill-text">生产下单</text>
			</view>

			<view class="entry-block" @click="goPage('ticket-order')">
				<view class="entry-bill">
					<image class="entry-bill-icon entry-bill-icon_billing"
						src="@/static/image/usercenter_ticketorder@3x.png" mode=""></image>
				</view>
				<text class="entry-bill-text">我的开票</text>
			</view>

			<view class="entry-block" @click="goPage('produce-material')">
				<view class="entry-bill">
					<image class="entry-bill-icon entry-bill-icon_billing"
						src="@/static/image/usercenter_producematerial@3x.png" mode="">
					</image>
				</view>
				<text class="entry-bill-text">生产备料</text>
			</view>

			<view class="entry-block" @click="goPage('my-purchase')">
				<view class="entry-bill">
					<image class="entry-bill-icon" src="@/static/image/usercenter_mypurchase@3x.png" mode=""></image>
				</view>
				<text class="entry-bill-text">我的要货</text>
			</view>

			<view class="entry-block" @click="goPage('my-order')">
				<view class="entry-bill">
					<image class="entry-bill-icon" src="@/static/image/uc_company@3x.png" mode=""></image>
				</view>
				<text class="entry-bill-text">我的订单</text>
			</view>

			<view class="entry-block" @click="goPage('billing-invoice')">
				<view class="entry-bill">
					<image class="entry-bill-icon entry-bill-icon_billing"
						src="@/static/image/usercenter_billinginvoice@3x.png" mode="">
					</image>
				</view>
				<text class="entry-bill-text">账票查询</text>
			</view>

		</view>
		<!-- <view class="bottom">
			<view class="cell-list">
				<view class="cell-list-block">
					<image class="icon-address" src="@/static/image/uc_address@3x.png" mode="aspectFit"></image>
					<text class="cell-list-block__title">收货地址</text>
					<image class="icon-arrow" src="@/static/image/arrow_r@3x.png" mode="aspectFit"></image>
				</view>
				<view class="cell-list-block">
					<image class="icon-address" src="@/static/image/uc_setting@3x.png" mode="aspectFit"></image>
					<text class="cell-list-block__title">设置</text>
					<image class="icon-arrow" src="@/static/image/arrow_r@3x.png" mode="aspectFit"></image>
				</view>
			</view> -->
	</view>
	</view>
</template>

<script>
	import {
		mapState
	} from 'vuex'

	import {
		apiGetBpPrice
	} from '@/servers/common.js'

	export default {
		onLoad() {
			this.winHeight = `height:${this.sysinfo.safeArea.height}px`
		},
		data() {
			return {
				winHeight: '',
				bpPrice: {
					ORDER_PRICE: '--',
					ZHIPIAO_PRICE: '--'
				}
			}
		},
		computed: {
			...mapState(['sysinfo', 'userInfo'])
		},
		async created() {
			this.getBpPrice()
		},
		methods: {
			async getBpPrice() {
				const res = await apiGetBpPrice({
					PARTNER: this.userInfo.code
				})
				this.bpPrice = res.DATA
			},
			goPage(page) {
				if (page === 'my-purchase') {
					uni.showToast({
						title: '要货功能开发中...',
						icon: 'none',
						duration: 1500
					});
					return
				}
				uni.navigateTo({
					url: `/pages/${page}/${page}`
				})
			},
			checkApplyOrder() {
				uni.navigateTo({
					url: "/pages/apply-order/apply-order"
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.user-center {
		flex: 1;
		background: #f8f8f8;
		flex-direction: column;
		font-size: 24rpx;
	}

	.top {
		position: relative;
		height: 400rpx;
		overflow: hidden;
	}

	.bg-img {
		position: absolute;
		left: 0;
		top: 0;
		z-index: 2;
		flex: 1;
		width: 750rpx;
		height: 400rpx;
	}

	.userinfo {
		display: flex;
		position: absolute;
		left: 48rpx;
		bottom: 170rpx;
		z-index: 4;
	}

	.avatar {
		width: 120rpx;
		height: 120rpx;
		border-radius: 50%;
	}

	.nick-block {
		flex-direction: column;
		justify-content: center;
		margin-left: 30rpx;
	}

	.nick-block--name {
		font-size: 32rpx;
		color: $text-base-color;
		font-weight: 500;
		margin-bottom: 12rpx;
	}

	.nick-block--no {
		width: 240rpx;
		height: 40rpx;
		line-height: 40rpx;
		font-size: 24rpx;
		background: #fff;
		border-radius: 20rpx;
		color: #555555;
		padding: 0 16rpx;
	}

	.amount-card {
		display: flex;
		align-items: center;
		position: absolute;
		left: 32rpx;
		right: 32rpx;
		bottom: 0;
		z-index: 4;
		height: 130rpx;
		background: linear-gradient(270deg, #2e2c2d, #5b5759);
		border-radius: 24rpx 24rpx 0 0;
	}

	.amount-card--order {
		flex: 1;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.amount-card--order_num {
		font-size: 36rpx;
		font-family: PingFangSC, PingFangSC-Medium;
		font-weight: 500;
		color: #fde5e1;
	}

	.amount-card--order_text {
		color: #fde5e1;
		font-size: 24rpx;
	}

	.divider {
		width: 1px;
		height: 27px;
		opacity: 0.34;
		border: 1px solid #fde5e1;
	}

	.middle {
		display: flex;
		flex-direction: row;
		background-color: #fff;
		padding: 50rpx 48rpx 0;
		flex-wrap: wrap;
	}

	.entry-block {
		width: 160rpx;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		margin-bottom: 48rpx;
	}

	.entry-block-tail {}

	.entry-bill {
		position: relative;
	}

	.entry-bill-icon {
		width: 48rpx;
		height: 48rpx;
		margin-bottom: 20rpx;
	}

	.entry-bill-icon_billing {
		width: 38rpx;
		height: 42rpx;
	}

	.entry-bill-dot {
		position: relative;
		z-index: 2;
		width: 44rpx;
		height: 36rpx;
		line-height: 36rpx;
		text-align: center;
		color: #ffffff;
		background: $wly-primary-color;
		border-radius: 9px;
		font-size: 24rpx;
		margin-left: -20rpx;
		margin-top: -10rpx;
	}

	.entry-bill-text {
		font-size: 28rpx;
		color: $text-base-color;
	}

	.bottom {
		margin-top: 24rpx;
	}

	.cell-list {
		flex-direction: column;
	}

	.cell-list-block {
		width: 750rpx;
		height: 100rpx;
		padding: 0 32rpx;
		margin-bottom: 4rpx;
		background-color: #fff;
		align-items: center;
	}

	.icon-address {
		width: 32rpx;
		height: 32rpx;
		margin-right: 8rpx;
	}

	.cell-list-block__title {
		color: #333;
		font-size: 28rpx;
		flex: 1;
		align-items: center;
	}

	.icon-arrow {
		width: 18rpx;
		height: 32rpx;
	}
</style>
