<template>
	<view class="page">
		<view style="position: absolute; top: 0; width: 100%;">
			<image :src="$imgUrl('/bg.png')" style="width: 100%; height: 490rpx;border-radius: 0 0 40rpx 40rpx;">
			</image>
		</view>
		<view class="my-top">
			<view class="head" :style="'background-color: rgba(38,197,112,'+(scrollTop/50)+');'">
				<view class="logo-title">
					<image :src="$imgUrl('/logo.png')"></image>
				</view>
				<view class="title">

				</view>
				<view class="setting-mess"></view>
			</view>
		</view>

		<view class="main">
			<view class="user-info" >
				<view class="portrait">
					<image :src="$imgUrl('/img/head.jpg')" v-if="Islogin"></image>
					<image :src="user.avatar?user.avatar:$imgUrl('/img/head.jpg')" v-else></image>
				</view>
				<view class="info">
					<view class="nickname">
						<text v-if="Islogin" @click="gopath('/pages/login/login')">请登录/入驻</text>
						<text v-else>{{user.name}}</text>
					</view>
					<!-- 					<view class="rank">
						<view class="rank-box">
						<image :src="$imgUrl('/vip.png')" ></image>
						<text v-if="Islogin"></text>
						<text v-else >{{shopMsg.shopReturn.returnAdress}}有限公司</text>
						</view>
					</view> -->
				</view>
				<view class="user-right">
					<image :src="$imgUrl('/right1.png')"></image>
				</view>
			</view>
			<!-- 我的服务 -->
			<view class="message-list">
				<view class="titleall-box">
					<view class="titleall-left">
						<view class="titleall-left-line"></view>招商及推广服务
					</view>
				</view>
				<view class="my-service">
					<view class="service-list">
						<!-- <view class="service-list-list">
							<view class="thumb">
								<text v-if="Islogin">0</text>
								<text v-else>{{wenjuanNum}}</text>
							</view>
							<view class="name" @click="questionnaire">
								<text>我的问卷</text>
							</view>
						</view> -->
						<view class="service-list-list">
							<view class="thumb">
								<text v-if="Islogin">0</text>
								<text v-else>{{activityNum}}</text>
							</view>
							<view class="name" @click="myativity">
								<text>我的活动</text>
							</view>
						</view>
						<!-- <view class="service-list-list" @click="apply">
						<view class="thumb">
							<text v-if="Islogin">0</text>
							<text v-else>2</text>
						</view>
						<view class="name">
							<text>我的招商</text>
						</view>
					</view> -->
						<!-- <view class="service-list-list" @click="projectM">
						<view class="thumb">
							 <text v-if="Islogin">0</text>
							<text v-else>{{tuiguang}}</text>
						</view>
						<view class="name">
							<text>我的推广</text>
						</view>
					</view> -->
					</view>
				</view>
			</view>
			<!-- 我的服务 -->
			<!-- <view class="message-list">
			<view class="titleall-box">
				<view class="titleall-left"><view class="titleall-left-line"></view>商城数据</view>
			</view>
			<view class="my-service-two">
				<view class="" v-if="Islogin">
					<view style="padding: 10px;text-align: center;">暂无数据</view>
				</view>
				<view class="service-list-two" v-else>
					<view class="service-list-list-two">
						<view class="thumb">
							{{tongji.money || 0}}
						</view>
						<view class="name">
							<text>今日收入</text>
						</view>
					</view>
					<view class="service-list-list-two">
						<view class="thumb">
							{{tongji.total}}
						</view>
						<view class="name">
							<text>访客数</text>
						</view>
					</view>
					<view class="service-list-list-two">
						<view class="thumb">
						{{tongji.rate || `0%`}}
						</view>
						<view class="name">
							<text>转化率</text>
						</view>
					</view>
				</view>
				
			</view>
			</view> -->
			<view class="message-list">
				<view class="titleall-box">
					<view class="titleall-left">
						<view class="titleall-left-line"></view>我的服务
					</view>
				</view>
				<!-- gopath('/pagesA/leaseAdd/leaseAdd') -->
				<view class="list" @click="isshop()" v-if="!isshopon">
					<view class="icon-data">
						<view class="icon">
							<image :src="$imgUrl('/my-icon2.png')" mode=""></image>
						</view>
						<view class="data">
							<view class="title">
								<text>认证商家</text>
							</view>
						</view>
					</view>
					<view class="more">
						<image :src="$imgUrl('/right2.png')"></image>
					</view>
				</view>
				<!-- <view class="list" @click="shopjcMsg">
					<view class="icon-data">
						<view class="icon">
							<image :src="$imgUrl('/my-icon1.png')" mode=""></image>
						</view>
						<view class="data">
							<view class="title">
								<text>商家基本信息</text>
							</view>
						</view>
					</view>
					<view class="more">
						<image :src="$imgUrl('/right2.png')"></image>
					</view>
				</view> -->
				<view class="list" @click="toPage('/pagesA/myZiyuan/myZiyuan')">
					<view class="icon-data">
						<view class="icon">
							<image :src="$imgUrl('/my-icon2.png')" mode=""></image>
						</view>
						<view class="data">
							<view class="title">
								<text>我的租赁资产</text>
							</view>
						</view>
					</view>
					<view class="more">
						<image :src="$imgUrl('/right2.png')"></image>
					</view>
				</view>
				<view class="list" @click="toPage('/pages/record/record')">
					<view class="icon-data">
						<view class="icon">
							<image :src="$imgUrl('/my-icon2.png')" mode=""></image>
						</view>
						<view class="data">
							<view class="title">
								<text>申请记录</text>
							</view>
						</view>
					</view>
					<view class="more">
						<image :src="$imgUrl('/right2.png')"></image>
					</view>
				</view>
				<view class="list" @click="toPage('/pages/serve/serve')">
					<view class="icon-data">
						<view class="icon">
							<image :src="$imgUrl('/my-icon2.png')" mode=""></image>
						</view>
						<view class="data">
							<view class="title">
								<text>服务记录</text>
							</view>
						</view>
					</view>
					<view class="more">
						<image :src="$imgUrl('/right2.png')"></image>
					</view>
				</view>
				<view class="list" @click="repair">
					<view class="icon-data">
						<view class="icon">
							<image :src="$imgUrl('/my-icon3.png')" mode=""></image>
						</view>
						<view class="data">
							<view class="title">
								<text>报事报修</text>
							</view>
						</view>
					</view>
					<view class="more">
						<image :src="$imgUrl('/right2.png')"></image>
					</view>
				</view>
				<view class="list" @click="complaint">
					<view class="icon-data">
						<view class="icon">
							<image :src="$imgUrl('/my-icon2.png')" mode=""></image>
						</view>
						<view class="data">
							<view class="title">
								<text>投诉建议</text>
							</view>
						</view>
					</view>
					<view class="more">
						<image :src="$imgUrl('/right2.png')"></image>
					</view>
				</view>
			
			</view>
		</view>
		<!-- tabbar -->
		<tabbar :tabBarShow="3"></tabbar>
	</view>
</template>

<script>
	import tabbar from '../../components/tabbar/tabbar.vue';
	import {
		Encrypt
	} from '../../utils/secret'
	export default {
		components: {
			tabbar,
		},
		data() {
			return {
				Islogin: true,
				scrollTop: 0,
				isHotline: false,
				shopMsg: {},
				pageindex: {
					pageNumber: 1,
					pageSize: 10
				},
				tuiguang: '',
				tongji: {},
				activityNum: 0,
				wenjuanNum: 0,
				user: uni.getStorageSync('user'),
				isshopon: false
			};
		},
		onload() {

		},
		onShow() {
			const isLogin = uni.getStorageSync('token');
			if (isLogin == '') {
				// 如果未登录，跳转到登录页面
				uni.navigateTo({
					url: '/pages/login/login'
				})
			} else {

				this.$http.sendRequest('/cerePlatformMerchant/queryByPage', 'POST',{pageSize:10,pageNumber:0,phone:uni.getStorageSync('user').phone},2).then(res => {
					 if(res.data.code == '20004' || res.data.code == '20003'){
						 uni.navigateTo({
						 	url: '/pages/login/login'
						 })
					 }
					if(res.data.data.content.length>0) {
						let c1 = res.data.data.content[0]
						console.error({...c1})
						if(c1.checkState == '2') {
							this.isshopon = true
							this.Islogin = false
						} 
					}
				})
			}

		},
		onReady() {
			uni.hideTabBar();
		},
		onPageScroll(e) {
			this.scrollTop = e.scrollTop;
		},
		mounted() {
			this.getALL()
		},
		methods: {
			isshop() {
				this.$http.sendRequest('/cerePlatformMerchant/queryByPage', 'POST', {
					pageSize: 10,
					pageNumber: 0,
					phone: uni.getStorageSync('user').phone
				}, 1).then(res => {
					//成功回调
					if (res.data.data.content.length > 0) {
						let c1 = res.data.data.content[0]
						console.error({
							...c1
						})
						if (c1.checkState == '1') {
							uni.showToast({
								icon: 'none',
								title: '正在审核中',
								duration: 3000
							});
						} else if (c1.checkState == '3') {
							uni.showToast({
								icon: 'none',
								title: '审核已被拒绝 请重新提交',
								duration: 3000
							});
							setTimeout(() => {
								uni.navigateTo({
									url: '/pagesA/leaseAdd/leaseAdd'
								})
							}, 3000)
						}
					} else {
						uni.navigateTo({
							url: '/pagesA/leaseAdd/leaseAdd'
						})
					}
				})
			},
			gopath(e) {
				uni.navigateTo({
					url: e
				})
			},
			getALL() {
				this.pageindex.createUser = uni.getStorageSync('user').phone
				this.$http.sendRequest('/cerePromotion/queryByPage', 'POST', this.pageindex, 1).then(res => {
					//成功回调
					this.tuiguang = res.data.data.numberOfElements
				})
				this.$http.sendRequest('/cereActivityApplication/queryByPage', 'POST', this.pageindex, 1).then(res => {
					//成功回调
					this.activityNum = res.data.data.numberOfElements
				})
				this.$http.sendRequest('/cereQuestionnaireTable/queryByPage', 'POST', this.pageindex, 1).then(res => {
					//成功回调
					this.wenjuanNum = res.data.data.numberOfElements
				})


			},
			toPage(url) {
				uni.navigateTo({
					url
				});
			},
			recordService() {
				if (this.Islogin == false) {
					uni.navigateTo({
						url: '/pages/recordService/recordService'
					})
				}

			},
			complaint() {
				console.log('1111',this.Islogin)
				if (this.Islogin == false) {
					uni.navigateTo({
						url: '/pages/complaint/complaint'
					})
				}

			},
			repair() {
				if (this.Islogin == false) {
					uni.navigateTo({
						url: '/pages/repair/repair'
					})
				}

			},
			apply() {
				if (this.Islogin == false) {
					uni.navigateTo({
						url: '/pages/record/record'
					})
				}

			},
			myativity() {
				if (this.Islogin == false) {
					uni.navigateTo({
						url: '/pages/mycreated/mycreated'
					})
				}

			},
			questionnaire() {
				if (this.Islogin == false) {
					uni.navigateTo({
						url: '/pages/questionnaire/questionnaire'
					})
				}

			},
			shopjcMsg() {
				let shop = JSON.stringify(this.shopMsg)
				if (this.Islogin == false) {
					uni.navigateTo({
						url: `/pages/shopjcMsg/shopjcMsg?shopMsg=${shop}`
					})
				}

			},
			projectM() {
				if (this.Islogin == false) {
					uni.navigateTo({
						url: '/pages/projectManagement/projectManagement'
					})
				}

			},
			
			myMsg() {
				const res = uni.getStorageSync('token');
				if (res == '') {
					uni.navigateTo({
						url: '/pages/login/login'
					})
				} else {
					let shop = JSON.stringify(this.shopMsg)
					if (this.Islogin == false) {
						uni.navigateTo({
							url: `/pages/shopjcMsg/shopjcMsg?shopMsg=${shop}`
						})
					}
				}
			}
		}
	}
</script>

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