<template>
	<view class="xiaoxi-pages">
		<view class="xiaoxi-header">
			<!-- <u-navbar :isBack="false" :border-bottom="false" :background="{background:'rgba(0,0,0,0)'}" :isFixed="false"> -->
			<u-navbar :fixed="false" bgColor='rgba(0,0,0,0)' placeholder :safeAreaInsetTop="true">
				<view slot="left" class="xiaoxi-tabs u-flex u-row-between" style="margin-left: -11rpx;">
					<view class="tabs-item u-flex-col u-col-center u-flex-1" :class="{'tabs-item1':current == 1}"
						@click="current = 1">
						<text>消息</text>
						<text></text>
					</view>
					<view class="tabs-item u-flex-col u-col-center u-flex-1" :class="{'tabs-item1':current == 2}"
						@click="current = 2">
						<text>通知</text>
						<text></text>
					</view>
				</view>
			</u-navbar>
			<view v-if="current == 1" class="tabs-header u-flex">
				<view class="u-flex tabs-header-item" :class="{'tabs-header-active' : tabs1 == index}"
					v-for="(item,index) in tabs1list" :key="index" @click="changetabs1(index)">
					<text>{{item}}</text>
				</view>
			</view>
			<view v-if="current == 2" class="tabs-header u-flex">
				<view class="u-flex tabs-header-item" :class="{'tabs-header-active' : tabs2 == index}"
					v-for="(item,index) in tabs2list" :key="index" @click="changetabs2(index)">
					<text>{{item}}</text>
				</view>
			</view>
		</view>
		<view class="xiaoxi-list" v-if="current == 1">
			<view class="xiaoxi-item u-flex u-row-between" v-for="(item,index) in 10" :key="index">
				<view class="item-head">
					<u-badge absolute="true" type="error" :value="7" :offset="[0,0]"></u-badge>
					<image src="https://dummyimage.com/96x96" mode=""></image>
				</view>
				<view class="xiaoxi-right u-flex-1">
					<view class="right-top u-flex u-row-between">
						<text>高先生</text>
						<text class="u-line-1">上海彼时人力资源有限公司·猎头…</text>
						<text>04月8日</text>
					</view>
					<view class="right-down u-line-1">
						HI！关于贵公司Java这个职位，我这边有合…
					</view>
				</view>
			</view>
		</view>
		<view class="tongzhi-list" v-if="current == 2">
			<view class="tongzhi-item" v-for="(item,index) in list" :key="index" @click="info2(item)">
				<view v-if="tabs2 == 0">
					<view class="tongzhi-header u-flex u-row-between">
						<view class="tongzhi-title u-flex">
							<text>{{item.title}}</text>
							<text v-if="item.is_view == 0"></text>
						</view>
						<view class="tongzhi-time">
							{{item.createtime}}
						</view>
					</view>
					<view class="tongzhi-tips">
						{{item.content}}
					</view>
					<view class="tongzhi-body">
						<view class="body-title u-flex">
							<text></text>
							<text>{{item.info.job.job_name}}</text>
						</view>
						<view class="body-name u-flex">
							<text></text>
							<text>{{item.info.resume.name}}</text>
						</view>
						<view class="body-address u-flex">
							<text class="text1">{{item.info.job.work_province}}·{{item.info.job.work_city}}</text>
							<text class="text2"></text>
							<text class="text1">{{item.info.job.experience_name}}</text>
							<text class="text2"></text>
							<text class="text1">{{item.info.job.education_name}}</text>
						</view>
					</view>
				</view>
				<view v-if="tabs2 == 1">
					<view class="tongzhi-header u-flex u-row-between">
						<view class="tongzhi-title u-flex">
							<text>{{item.title}}</text>
							<text v-if="item.is_view == 0"></text>
						</view>
						<view class="tongzhi-time">
							{{item.createtime}}
						</view>
					</view>
					<view class="tongzhi-tips">
						{{item.content}}
					</view>
					<view class="xitong-box" v-if="item.info.job_name">
						<view class="xitong-title u-flex">{{item.info.job_name}}</view>
						<view class="xitong-address u-flex">
							<text class="text1">{{item.info.work_city}}</text>
							<text class="text2"></text>
							<text class="text1">{{item.info.experience_name}}</text>
							<text class="text2"></text>
							<text class="text1">{{item.info.education_name}}</text>
						</view>
					</view>
				</view>
				<view v-if="tabs2 == 2">
					<view class="zixun-box">
						<view class="zixun-title">
							{{item.title}} {{item.createtime}}
						</view>
						<image :src="item.info.image" class="zixun-img" mode="aspectFill"></image>
						<view class="zixun-tips">
							{{item.content}}
						</view>
					</view>
				</view>
				<view class="tongzhi-down u-flex u-row-between">
					<text class="text">查看详情</text>
					<u-icon name="arrow-right" color="#0C66C2"></u-icon>
				</view>
			</view>
		</view>
		<view style="height: 70vh;display: flex;align-items: center;justify-content: center;" v-if="list.length == 0">
			<u-empty text="暂无数据" mode="list"></u-empty>
		</view>
	</view>
</template>

<script>
	import {get_list,view} from "@/units/inquire.js"
	export default {
		data() {
			return {
				current: 2,
				tabs1: 0,
				tabs1list: ['全部', '未读', '沟通中'],
				tabs2: 0,
				tabs2list: ['订单通知', '系统通知', '资讯通知'],
				page: 1,
				total: 0,
				list: []
			}
		},
		onLoad() {
			this.getlist()
		},
		onReachBottom() {
			if (this.total != this.list.length) {
				this.page++
				this.getlist()
			}
		},
		methods: {
			info2(item) {
				view({
					id: item.id
				}).then(res => {
					item.is_view = 1
				})
				if (this.tabs2 == 0) {
					uni.navigateTo({
						url: "/pagesD/order-info?id=" + item.info.id
					})
				}
				if (this.tabs2 == 1) {
					if (item.source_type == 'job') {
						uni.navigateTo({
							url: "/pagesB/zhiwei-info2?id=" + item.info.id
						})
					} else {
						uni.navigateTo({
							url: "/pagesD/vip"
						})
					}
				}
				if (this.tabs2 == 2) {
					uni.navigateTo({
						url: "/pagesD/zixun-info?id=" + item.info.id
					})
				}
			},
			changetabs2(index) {
				this.tabs2 = index
				this.page = 1
				this.total = 0
				this.list = []
				this.getlist()
			},
			changetabs1(index) {
				this.tabs1 = index
				this.page = 1
				this.total = 0
				this.list = []
				this.getlist()
			},
			getlist() {
				if (this.current == 1) {
					
				}
				if (this.current == 2) {
					get_list({
						page: this.page,
						type: {
							0: 'order',
							1: 'system',
							2: 'info'
						} [this.tabs2]
					}).then(res => {
						this.total = res.data.total
						this.list = this.list.concat(res.data.data)
					})
				}
			}
		}
	}
</script>

<style lang="scss" >
	.xiaoxi-pages {
		.tongzhi-list {
			padding: 1rpx 0;

			.tongzhi-item {
				margin: 20rpx auto;
				width: 702rpx;
				background: #FFFFFF;
				border-radius: 20rpx;
				padding: 0 24rpx;

				.xitong-box {
					width: 100%;
					background: rgba(243, 243, 243, 0.5);
					border-radius: 12rpx;
					padding: 24rpx;

					.xitong-address {
						.text1 {
							font-size: 26rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #666666;
						}

						.text2 {
							height: 20rpx;
							border: 2rpx solid #E5E5E5;
							margin: 0 16rpx;
						}
					}

					.xitong-title {
						font-size: 32rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #222222;
						margin-bottom: 20rpx;
					}
				}

				.zixun-box {
					.zixun-tips {
						font-size: 30rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #333333;
						padding: 24rpx 0;
					}

					.zixun-img {
						width: 100%;
						height: 284rpx;
					}

					.zixun-title {
						padding: 24rpx 0 20rpx 0;
						font-size: 24rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #888888;
					}
				}

				.tongzhi-down {
					height: 86rpx;
					border-top: 2rpx solid #F0F0F0;

					.text {
						font-size: 26rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #0C66C2;
					}
				}

				.tongzhi-body {
					background: rgba(243, 243, 243, 0.5);
					border-radius: 12rpx;
					padding: 20rpx;
					margin-bottom: 24rpx;

					.body-address {
						padding: 0 32rpx;

						.text2 {
							height: 20rpx;
							border: 2rpx solid #E5E5E5;
							margin: 0 14rpx;
						}

						.text1 {
							font-size: 26rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #666666;
						}
					}

					.body-name {
						margin-bottom: 20rpx;

						text:first-child {
							width: 12rpx;
							height: 12rpx;
							background: #0C66C2;
							border-radius: 100rpx;
							margin-right: 20rpx;
						}

						text:last-child {
							font-size: 32rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #222222;
						}
					}

					.body-title {
						margin-bottom: 28rpx;

						text:first-child {
							width: 12rpx;
							height: 12rpx;
							background: #131415;
							margin-right: 20rpx;
							border-radius: 100rpx;
						}

						text:last-child {
							font-size: 32rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #222222;
						}
					}
				}

				.tongzhi-tips {
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #666666;
					margin-bottom: 24rpx;
				}

				.tongzhi-header {
					height: 96rpx;

					.tongzhi-time {
						font-size: 24rpx;
						font-family: SFPro-Regular, SFPro;
						font-weight: 400;
						color: #666666;
					}

					.tongzhi-title {
						text:first-child {
							font-size: 32rpx;
							font-family: PingFangSC-Medium, PingFang SC;
							font-weight: 500;
							color: #222222;
							margin-right: 16rpx;
						}

						text:nth-child(2) {
							width: 12rpx;
							height: 12rpx;
							background: #F2413A;
							border-radius: 100rpx;
						}
					}
				}
			}
		}

		.xiaoxi-list {
			width: 702rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			margin: 20rpx auto;

			.xiaoxi-item {
				padding: 24rpx 20rpx;

				.xiaoxi-right {
					min-width: 1rpx;

					.right-down {
						font-size: 26rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #444444;
					}

					.right-top {
						margin-bottom: 18rpx;

						text:first-child {
							font-size: 30rpx;
						}

						text:nth-child(2) {
							font-size: 22rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #888888;
							margin: 0 8rpx;
						}

						text:last-child {
							font-size: 24rpx;
							font-family: SFPro-Regular, SFPro;
							font-weight: 400;
							color: #999999;
						}
					}
				}

				.item-head {
					width: 96rpx;
					height: 96rpx;
					border-radius: 100rpx;
					margin-right: 20rpx;
					position: relative;

					image {
						width: 96rpx;
						height: 96rpx;
						border-radius: 100rpx;
					}
				}
			}
		}

		.xiaoxi-header {
			position: sticky;
			top: 0;
			left: 0;
			width: 750rpx;
			z-index: 99;
			background: linear-gradient(180deg, #EDF6FF 0%, #F8FAFD 100%);

			.tabs-header {
				height: 88rpx;
				padding: 0 8rpx;

				.tabs-header-item {
					margin: 0 24rpx;

					text {
						font-size: 26rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #777777;
					}
				}

				.tabs-header-active {
					text {
						color: #0C66C2;
					}
				}
			}

			.xiaoxi-tabs {
				width: 250rpx;

				.tabs-item {
					text:first-child {
						font-size: 32rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 500;
						color: #777777;
						position: relative;
						z-index: 1;
					}

					text:last-child {
						width: 76rpx;
						height: 12rpx;
						border-radius: 100rpx;
						margin-top: -14rpx;
					}
				}

				.tabs-item1 {
					text:first-child {
						font-size: 36rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 500;
						color: #222222;
					}

					text:last-child {
						background: linear-gradient(270deg, #208EFF 0%, rgba(28, 159, 227, 0) 100%);
					}
				}
			}
		}
	}

	page {
		background-color: #F3F3F3;
	}
</style>
<style scoped>
	::v-deep .u-navbar__content__left{
		left: -11rpx !important;
	}
</style>