<template>
	<view class="my-page">
		<custom-navbar title="个人中心" :showBack="true" borderBottom="none"
			backgroundColor="linear-gradient( 106deg, #FFE1E1 0%, #CCD8F7 100%)"></custom-navbar>

		<!-- 用户信息区域 -->
		<view class="user-info">
			<view class="user-header">
				<view class="avatar-wrap">
					<image class="avatar" v-if="userInfo.head_photo" :src="userInfo.head_photo" mode="aspectFill">
					</image>
				</view>
				<view class="user-detail">
					<view class="name-wrap">
						<text class="name">{{ userInfo.name }}</text>
						<view class="amount-box" @click="navigateTo('/pages/wallet/wallet')">
							<image class="amount-img" src="@/static/images/icons/wallet.png" />
							<text class="amount-lable"> 钱包余额： </text>
							<text class="amount-text"> {{ userInfo.money }}元 </text>
						</view>
					</view>
				</view>
				<view class="edit-profile" @click="goArtisanProfile">
					<text class="edit-text">编辑资料</text>
					<image class="arrow-right" src="/static/images/arrow_right.png" mode="aspectFit"></image>
				</view>
			</view>

			<view class="notify" v-if="unbindReadNum>0">
				<view class="notify-left">
					<image class="notify-left-img" src="@/static/images/icons/notify2.png"></image>
					<text>通知：你有员工解绑申请</text>
				</view>
				<image class="notify-right" @click="goUnbundleList" src="@/static/images/icons/notify1.png"></image>
			</view>

			

			<view class="module box-cont">
				<view class="module-lable"> 交易项目 </view>
				<view class="module-cont">
					<image :src="item.imgUrl" class="module-cont-img" mode="aspectFit" v-for="(item,i) in tradeList"
						:key="item.id" @click="navigateTo(item.pathUrl)"></image>
				</view>
			</view>

			<view class="module box-cont module-order">
				<view class="module-lable"> 交易订单 </view>
				<view class="module-cont">
					<image :src="item.imgUrl" class="module-cont-img" mode="aspectFit" v-for="(item,i) in orderTypeList"
						:key="item.id" @click="navigateTo(item.pathUrl)"></image>

				</view>
			</view>



			<!-- 营销中心 -->
			<view class="module box-cont module-order">
				<view class="module-lable"> 营销中心 </view>
				<view class="module-cont">
					<image :src="item.imgUrl" class="module-cont-img" mode="aspectFit"
						v-for="(item,i) in marketingTypeList" :key="item.id" @click="navigateTo(item.pathUrl)"></image>
				</view>
			</view>
			
			<view class="module box-cont">
				<view class="module-lable"> 员工服务 </view>
				<view class="module-cont">
					<image :src="item.imgUrl" class="module-cont-img" mode="aspectFit" v-for="(item,i) in staffList"
						:key="item.id" @click="navigateTo(item.pathUrl)"></image>
				</view>
			</view>

			<!-- 平台自营项目 -->
			<image class="module-banner" @click="goAgreement" v-if="userInfo.self_state==0" mode="widthFix"
				src="/static/images/home/zyBanner.png"></image>
			<view class="module box-cont module-order" v-else>
				<view class="module-lable"> 平台自营项目 </view>

				<view class="module-cont">
					<image :src="item.imgUrl" class="module-cont-img" mode="aspectFit"
						v-for="(item,i) in selfOperatedList" :key="item.id" @click="navigateTo(item.pathUrl)"></image>
				</view>

			</view>

			<!-- 功能列表 -->
			<view class="function-list">
				<!-- <view class="function-item" @click="navigateTo('/pages/ranking/index')">
          <text class="function-text">排行榜</text>
          <text class="arrow">></text>
        </view> -->
				<!-- <view class="function-item" @click="navigateTo('/pages/shop/groupBuying/list')">
					<text class="function-text">拼团管理</text>
					<image class="right_gray" src="@/static/images/icons/right_gray3.png" />
				</view> -->
				<view class="function-item" @click="navigateTo('/pages/contact/contact')">
					<text class="function-text">客服</text>
					<image class="right_gray" src="@/static/images/icons/right_gray3.png" />
				</view>
				<!-- <view class="function-item" @click="navigateTo('/pages/share/syrandsjshare')">
          <text class="function-text">分享</text>
          <text class="arrow">></text>
        </view> -->
			</view>
		</view>
	</view>
</template>

<script>
	import request from "../../utils/request";
	export default {
		data() {
			return {
				userInfo: {},
				orderCount: 0,
				servicesCount: 0,
				selfOperatedList: [{
					id: 0,
					imgUrl: '/static/images/tab/SelfOperatedServe.png',
					pathUrl: '/pages/selfOperated/list'
				}, {
					id: 1,
					imgUrl: '/static/images/tab/SelfOperatedOrder.png',
					pathUrl: "/pages/shop/userorders?serviceType=2"
				}, ],
				tradeList: [{
						id: 0,
						title: "服务管理",
						des: "服务的发布与管理",
						imgUrl: "/static/images/tab/service_gl.png",
						pathUrl: "/pages/artisan/service-list",
					},
					{
						id: 1,
						title: '工位管理',
						des: '工位的发布与管理',
						imgUrl: '/static/images/tab/station_gl.png',
						pathUrl: '/pages/shop/workSpace/list'
					},
					{
						id: 2,
						title: "购买服务",
						des: "可购买手艺人的服务",
						imgUrl: "/static/images/tab/buy_service.png",
						pathUrl: "/pages/shop/buy-service",
					},
					{
						id: 3,
						title: '购买工时',
						des: '可购买手艺人的工时',
						imgUrl: '/static/images/tab/buy_time.png',
						pathUrl: '/pages/shop/manHour/buyManHour'
					},
				],
				orderTypeList: [{
						id: 0,
						title: "用户订单",
						des: "我售卖的服务信息",
						imgUrl: "/static/images/tab/user_order.png",
						pathUrl: "/pages/shop/userorders",
					},
					{
						id: 1,
						title: '工位订单',
						des: '我售卖的工位信息',
						imgUrl: '/static/images/tab/station_order.png',
						pathUrl: '/pages/shop/workSpace/saleList'
					},
					{
						id: 2,
						title: "服务订单",
						des: "我买的手艺人服务",
						imgUrl: "/static/images/tab/shop_service_order.png",
						pathUrl: "/pages/shop/buy-order",
					},
					{
						id: 3,
						title: '工时订单',
						des: '我买的手艺人工时',
						imgUrl: '/static/images/tab/shop_time_order.png',
						pathUrl: '/pages/shop/manHour/saleList'
					},
				],
				marketingTypeList: [{
						id: 0,
						imgUrl: "/static/images/tab/pintuan_order.png",
						pathUrl: "/pages/shop/groupBuying/list",
					},
					{
						id: 1,
						imgUrl: '/static/images/tab/promotion_order.png',
						pathUrl: '/pages/promotion/promotion'
					},
				],
				staffList: [{
						id: 0,
						imgUrl: "/static/images/tab/staff2.png",
						pathUrl: "/pages/shop/staff/manage",
					},
					{
						id: 1,
						imgUrl: '/static/images/tab/staff1.png',
						pathUrl: '/pages/shop/staff/distribution-service'
					},
				],
			};
		},
		props: {
			unbindReadNum: {
				type: [Number,String],
				default:0
			},
		},
		onLoad() {},
		async created() {

			const {
				data
			} = await request.post("/user/getuser", {
				type: 3,
			});
			this.userInfo = data;
			//存储商家地址
			uni.setStorageSync("shopdependency", this.userInfo.dependency);
			// this.getServicesList();
		},
		methods: {
			goUnbundleList() {
				uni.navigateTo({
					url: "/pages/shop/staff/unbundleList",
				});
			},
			goAgreement() {
				uni.navigateTo({
					url: "/pages/selfOperated/agreement?title=平台自营项目介绍&type=18",
				});
			},
			goArtisanProfile() {
				uni.navigateTo({
					url: "/pages/artisan/profile",
				});
			},
			// 已上架服务数量
			getServicesList() {
				let url = null;
				if (getApp().globalData.artisanType == 1) {
					url = "/user/syrserverlist";
				} else if (getApp().globalData.artisanType == 2) {
					url = "/user/sjserverlist";
				}
				request
					.post(url, {
						state: 2,
					})
					.then((res) => {
						if (res.state == 1) {
							this.servicesCount = res.data.length;
						} else {
							uni.showToast({
								title: res.msg,
								icon: "none",
							});
						}
					});
			},
			// 页面跳转
			navigateTo(url) {
				uni.navigateTo({
					url,
				});
			},
		},
	};
</script>

<style lang="less">
	page {
		background-color: #fff;
	}


	.notify {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 702rpx;
		box-sizing: border-box;
		padding: 14rpx 24rpx 14rpx 40rpx;
		background: linear-gradient(320deg, #FFFFFF 0%, #FFFFFF 100%);
		border-radius: 19rpx;
		margin-bottom: 20rpx;

		.notify-left {
			font-weight: 400;
			font-size: 28rpx;
			color: #333333;
			line-height: 40rpx;
			text-align: right;
			font-style: normal;
			display: flex;
			align-items: center;

			.notify-left-img {
				width: 42rpx;
				height: 42rpx;
				margin-right: 10rpx;
			}
		}

		.notify-right {
			width: 130rpx;
			height: 54rpx;
		}
	}

	.my-page {
		position: relative;
		margin-bottom: 120rpx;
	}

	.my-page::before {
		content: "";
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		height: 676rpx !important;
		background-image: url("/static/images/background/bj.png");
		background-size: cover;
		background-position: center top;
		background-repeat: no-repeat;
		z-index: 1;
	}

	.user-info {
		padding: 0 24rpx;
		position: relative;
		z-index: 99;
		margin-top: 32rpx;
	}

	.user-header {
		display: flex;
		align-items: center;
		margin-bottom: 48rpx;
	}

	.avatar-wrap {
		width: 110rpx;
		height: 110rpx;
		border-radius: 64rpx;
		overflow: hidden;
		margin-right: 24rpx;
		border: 4rpx solid #fff;
	}

	.avatar {
		width: 100%;
		height: 100%;
	}

	.user-detail {
		flex: 1;
	}

	.name-wrap {
		display: flex;
		flex-flow: column nowrap;
		justify-content: center;
		align-items: flex-start;
	}

	.name {
		font-weight: 500;
		font-size: 34rpx;
		color: #333333;
		line-height: 56rpx;
		text-align: left;
		font-style: normal;
	}

	.verified {
		width: 130rpx;
		height: 44rpx;
		display: flex;
		flex-flow: row nowrap;
		justify-content: center;
		align-items: center;
		border: 1rpx solid #E8101E;
		background-color: #fff1f1;
		border-radius: 22rpx;
		box-sizing: border-box;
	}

	.verified-no {
		width: 130rpx;
		height: 44rpx;
		display: flex;
		flex-flow: row nowrap;
		justify-content: center;
		align-items: center;
		border: 1rpx solid #666666;
		border-radius: 22rpx;
		box-sizing: border-box;
	}

	.verified-text {
		font-size: 24rpx;
		color: #E8101E;
	}

	.verified-text.no {
		color: #666666;
	}

	.sign-icon {
		width: 24rpx;
		height: 24rpx;
		margin-right: 6rpx;
	}

	.edit-profile {
		display: flex;
		align-items: center;
	}

	.edit-text {
		font-size: 28rpx;
		color: #666666;
		margin-right: 16rpx;
	}

	.arrow {
		font-size: 28rpx;
		color: #666666;
	}

	.amount-img {
		width: 30rpx;
		height: 30rpx;
		margin-right: 8rpx;
	}

	.amount-box {
		display: flex;
		flex-flow: row nowrap;
		justify-content: flex-start;
		align-items: center;
		background: rgba(252, 67, 124, 0.1);
		border-radius: 30rpx;
		padding: 10rpx 16rpx;
	}

	.amount-lable {
		font-weight: 500;
		font-size: 26rpx;
		color: #666666;
		line-height: 30rpx;
		text-align: left;
		font-style: normal;
	}

	.amount-text {
		font-weight: 500;
		font-size: 26rpx;
		color: #666666;
		line-height: 30rpx;
		text-align: left;
		font-style: normal;
		color: #E8101E;
	}

	.function-list {
		background: #ffffff;
		border-radius: 20rpx;
		padding: 24rpx;
		box-shadow: 0 0 12rpx 0 rgba(0, 0, 0, 0.05);
		display: flex;
		flex-direction: column;
		gap: 30rpx;
	}

	.function-item {
		display: flex;
		justify-content: space-between;
		align-items: center;
		/* border-bottom: 1rpx solid rgba(0, 0, 0, 0.05); */
	}

	.function-item:last-child {
		border-bottom: none;
	}

	.function-text {
		font-weight: 500;
		font-size: 28rpx;
		color: #232220;
		line-height: 40rpx;
		text-align: left;
		font-style: normal;
	}

	/* 交易项目 */
	.module {
		margin: 0;
		border-radius: 24rpx;
		padding: 24rpx;
		margin-bottom: 24rpx;
	}

	.module-banner {
		width: 702rpx;
		margin-bottom: 24rpx;
	}

	.module-cont {
		display: flex;
		flex-flow: row wrap;
		justify-content: space-between;
		align-items: center;
	}

	.module-cont-img {
		width: 310rpx;
		height: 120rpx;
		margin-top: 23rpx;
	}

	.module-item {
		width: 310rpx;
		height: 120rpx;
		border-radius: 16rpx;
		border: 2rpx solid #f0eeee;
		box-sizing: border-box;
		display: flex;
		flex-flow: row nowrap;
		justify-content: space-between;
		align-items: center;
		padding: 24rpx 22rpx 24rpx 24rpx;
		margin-top: 24rpx;
	}

	.module-order .module-item {
		justify-content: flex-start;
	}

	.right_gray {
		width: 14rpx;
		height: 26rpx;
	}

	.module-lable {
		font-weight: 500;
		font-size: 32rpx;
		color: #333333;
		line-height: 45rpx;
		text-align: left;
		font-style: normal;
	}

	.module-left {
		display: flex;
		flex-flow: column nowrap;
		justify-content: center;
		align-items: flex-start;
	}

	.module-tit {
		font-weight: 500;
		font-size: 28rpx;
		color: #333333;
		line-height: 40rpx;
		text-align: left;
		font-style: normal;
		margin-bottom: 4rpx;
	}

	.module-des {
		font-weight: 500;
		font-size: 20rpx;
		color: #999999;
		line-height: 28rpx;
		text-align: left;
		font-style: normal;
	}

	.module-icon {
		width: 68rpx;
		height: 68rpx;
	}

	.module-order .module-icon {
		margin-right: 28rpx;
	}

	.arrow-right {
		width: 11rpx;
		height: 22rpx;
	}

	/* 平台适配 */
	/* #ifdef H5 */

	/* #endif */

	/* #ifdef MP-WEIXIN */

	/* #endif */
</style>