<template>
	<view class="page">
		<view class="bg">
			<image src="/static/bg.jpg"></image>
		</view>
		<view class="back" @click="home"><image src="../../static/left.png"></image></view>
		<pyh-nv ref="nv" :config="nvConfig"></pyh-nv>
		<view class="listBox" :style="{'padding-top':(pageTop+'px')}">
		<view class="content">
			<view class="my-top">
				<view class="user-info">
					<view class="portrait" @click="tzmy">
						<image :src="user.avatar"></image>
					</view>
					<view class="info">
						<view class="nickname">
							<text>{{user.nickName}}</text>
						</view>
						<view class="rank">
							<image src="../../static/id.png"></image>
							<text>{{user.userId}}</text>
						</view>
					</view>
				</view>
			</view>
			<view class="message-list">
				<!-- 司机列表 -->
				<view class="" v-if="sjshow">
					<view class="titleall-box" style="margin-bottom: -20rpx;">
						<view class="titleall-left"><view class="titleall-left-line"></view>服务</view>
					</view>
					<hcxx v-if="sjshow"></hcxx>
				</view>
				<!-- 收敛工列表 -->
				<view class="" v-if="slgshow">
					<view class="titleall-box" style="margin-bottom: -40rpx;">
						<view class="titleall-left"><view class="titleall-left-line"></view>服务</view>
					</view>
					<slgxx v-if="slgshow"></slgxx>
				</view>
				<view class="titleall-box" v-if="!sjshow && !slgshow">
					<view class="titleall-left"><view class="titleall-left-line"></view>我的服务</view>
				</view>
				<view class="list" @click="mydeath" v-if="ptyhshow || ddyshow">
					<view class="icon-data">
						<view class="icon">
							<image src="/static/my-icon4.png" mode=""></image>
						</view>
						<view class="data">
							<view class="title">
								<text>报丧记录</text>
							</view>
						</view>
					</view>
					<view class="more">
						<text class="iconfont icon-more"></text>
					</view>
				</view>
				<view class="list" @click="myreservation" v-if="ptyhshow">
					<view class="icon-data">
						<view class="icon">
							<image src="/static/my-icon5.png" mode=""></image>
						</view>
						<view class="data">
							<view class="title">
								<text>预约记录</text>
							</view>
						</view>
					</view>
					<view class="more">
						<text class="iconfont icon-more"></text>
					</view>
				</view>
				<view class="list" @click="myevaluate" v-if="ptyhshow">
					<view class="icon-data">
						<view class="icon">
							<image src="/static/my-icon6.png" mode=""></image>
						</view>
						<view class="data">
							<view class="title">
								<text>服务评价</text>
							</view>
						</view>
					</view>
					<view class="more">
						<text class="iconfont icon-more"></text>
					</view>
				</view>
			</view>
		</view>
		</view>
		<!-- tabbar -->
		<TabBar :tabBarShow="3" v-if="!sjshow && !slgshow"></TabBar>
	</view>
</template>

<script>
	import TabBar from '../../components/TabBar/TabBar.vue';
	import hcxx from '../hcxx/hcxx.vue'
	// url: '/pages/slgxx/slgxx'
	import slgxx from '../slgxx/slgxx.vue'
	export default {
		components: {
			TabBar,
			hcxx,
			slgxx
		},
		data() {
			return {
				Baseapi:"http://8.130.38.56:2015",
				nvConfig:{
					title:"殡葬公共服务",
					bgColor:"#ffffff",
					color:"#000000",
					fixedAssist:{
						hide:true,
					},
					transparent:{
						initColor:"#000",
					},
					back:{
						hide:true
					},
				},
				user:{
					nickName:"",
					userId:"",
					avatar:""
				},
				sjshow:false,
				slgshow:false,
				ddyshow:false,
				ptyhshow:false,
			};
		},
		onPageScroll(e) {this.$refs.nv.pageScroll(e)},
		computed:{
			pageTop(){return parseInt(88*uni.getSystemInfoSync().windowWidth/750) + uni.getSystemInfoSync().statusBarHeight}
		},
		onShow() {
			this.hquserinfo();
			console.log("角色",uni.getStorageSync('userjs'));
			if(uni.getStorageSync('userjs') == '司机'){
				this.sjshow = true
			}
			if(uni.getStorageSync('userjs') == '收敛工'){
				this.slgshow = true
			}
			if(uni.getStorageSync('userjs') == '调度员'){
				this.ddyshow = true
			}
			if(uni.getStorageSync('userjs') == '普通用户'){
				this.ptyhshow = true
			}
		},
		onLoad() {
			uni.hideTabBar();
			this.hquserinfo();
			// this.user = uni.getStorageSync('USERS_KEY')
			console.log(this.user);
		},
		methods: {
			// 跳转电话报丧
			dhbs(){
				uni.setStorageSync('dh',2)
				uni.navigateTo({
					url:'/pages/funeralreport/funeralreport'
				})
			},
			// 获取用户信息
			hquserinfo(){
				var info = {
					userId:uni.getStorageSync("USERS_KEY").userId,
				}
				this.API.hquserinfo(info).then(res=>{
					console.log("获取用户信息",res);
					this.user.nickName = res.data.nickName;
					this.user.avatar = res.data.avatar
					this.user.userId = res.data.userId
					console.log("信息",this.user);
				})
			},
			hcxx(){
				uni.navigateTo({
					url: '/pages/hcxx/hcxx'
				})
			},
			slgxx(){
				uni.navigateTo({
					url: '/pages/slgxx/slgxx'
				})
			},
			home() {
				uni.navigateTo({
					url: '/pages/home/home'
				})
			},
			onSkipOrder(type){
				if(type === 4){
					uni.navigateTo({
						url: '/pages/myorder/myorder',
					})
					return;
				}
				console.log("type",type);
				uni.navigateTo({
					url: '/pages/myorder/myorder?type=' + type,
				})
			},
			mydeath() {
				uni.navigateTo({
					url: '/pages/mydeath/mydeath'
				})
			},
			myevaluate() {
				uni.navigateTo({
					url: '/pages/myevaluate/myevaluate'
				})
			},
			myreservation() {
				uni.navigateTo({
					url: '/pages/myreservation/myreservation?type=' + 0 
				})
			},
			// 跳转个人信息修改
			tzmy(){
				uni.navigateTo({
					url:'/pages/myinfo/myinfo'
				})
			},
		}
	}
</script>

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