<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 class="verified" v-if="userInfo.qualifications && userInfo.qualifications.length != 0">
				  <image src="/static/images/sign-red.png" class="sign-icon" mode="aspectFit"></image>
				  <text class="verified-text">已认证</text>
				</view>
				<view class="verified-no" v-else>
				  <image src="/static/images/sign-grew.png" class="sign-icon" mode="aspectFit"></image>
				  <text class="verified-text no">未认证</text>
				</view>
			</view> -->
					</view>
				</view>
				<view class="edit-profile" @click="goArtisanProfile">
					<text class="edit-text">编辑资料</text>
					<image src="@/static/images/icons/right_gray.png" />
				</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 tradeList"
						:key="item.id" @click="navigateTo(item.pathUrl)"></image>
					<!-- <view class="module-item" v-for="(item,i) in tradeList" :key="item.id"
						@click="navigateTo(item.pathUrl)">
						<view class="module-left">
							<text class="module-tit">{{item.title}}</text>
							<text class="module-des">{{item.des}}</text>
						</view>
						<image :src="item.imgUrl" mode="aspectFit" class="module-icon"></image>
					</view> -->
				</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>

			<!-- 平台自营项目 -->
			<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/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: {},
				state: [3, 4, 5, 6, 7],
				orderCount: 0,
				servicesCount: 0,
				marketingTypeList: [{
					id: 0,
					imgUrl: '/static/images/tab/promotion_order.png',
					pathUrl: '/pages/promotion/promotion'
				}, ],
				selfOperatedList: [{
					id: 0,
					imgUrl: '/static/images/tab/SelfOperatedServe.png',
					pathUrl: '/pages/selfOperated/list'
				}, {
					id: 1,
					imgUrl: '/static/images/tab/SelfOperatedOrder.png',
					pathUrl: '/pages/syr/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/time_gl.png",
						pathUrl: "/pages/syr/manHour/list",
					},
					{
						id: 3,
						title: "购买工位",
						des: "可购买商家的工位",
						imgUrl: "/static/images/tab/buy_station.png",
						pathUrl: "/pages/syr/workstation/buyWorkstation",
					},
				],
				orderTypeList: [{
						id: 0,
						title: "用户订单",
						des: "卖给用户的服务订单",
						imgUrl: "/static/images/tab/user_order.png",
						pathUrl: "/pages/syr/userorders",
					},
					{
						id: 1,
						title: "商户订单",
						des: "卖给商家的服务订单",
						imgUrl: "/static/images/tab/shop_order.png",
						pathUrl: "/pages/syr/shoporders",
					},
					{
						id: 2,
						title: "工时订单",
						des: "我售卖的工时订单",
						imgUrl: "/static/images/tab/job_time_order.png",
						pathUrl: "/pages/syr/manHour/saleList",
					},
					{
						id: 3,
						title: "工位订单",
						des: "我买的商家工位订单",
						imgUrl: "/static/images/tab/job_position_order.png",
						pathUrl: "/pages/syr/workstation/buyList",
					},
				],
			};
		},
		async created() {
			const {
				data
			} = await request.post("/user/getuser", {
				type: 2
			});
			this.userInfo = data;
			// this.getServicesList();
		},
		methods: {
			goArtisanProfile() {
				// uni.showToast({
				// 	title: '该功能正在开发中，敬请期待',
				// 	icon: 'none'
				// })
				uni.navigateTo({
					url: "/pages/artisan/profile",

				});
			},
			goAgreement() {
				uni.navigateTo({
					url: "/pages/selfOperated/agreement?title=平台自营项目介绍&type=18",
				});
			},
			// 已上架服务数量
			// getServicesList() {
			// 	let url = null;
			// 	if(getApp().globalData.artisanType == 0) {
			// 		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;
	}

	.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;

		image {
			width: 12rpx;
			height: 24rpx;
		}
	}

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

	.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: 0 24rpx;
		box-shadow: 0 0 12rpx 0 rgba(0, 0, 0, 0.05);
	}

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

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

	.function-text {
		font-size: 28rpx;
		color: #232220;
		font-weight: 500;
	}

	/* 交易项目 */
	.module {
		margin: 0;
		border-radius: 24rpx;
		padding: 24rpx;
		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;
	}

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

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

	.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;
	}

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

	/* #endif */

	/* #ifdef MP-WEIXIN */

	/* #endif */

	.right_gray {
		width: 14rpx;
		height: 26rpx;
	}
</style>