<template>
	<view>
		<u-navbar :autoBack="true" title="会员中心"></u-navbar>
		<u--image src="/static/my/wo_icon_hyzxbj.png" width="750rpx" height="349rpx" :lazy-load="true">
		</u--image>
		<myAvatar :center="show"></myAvatar>
		<view style="height: 56rpx;"></view>
		<myForm ref="nameAndphone"></myForm>
		<view class="commitment">
			{{commitment}}
		</view>
		<u-button type="success" text="升级VIP" color="#0EBB5B" @click="handleSureClick()"></u-button>
		<u-modal :show="showM" closeOnClickOverlay="false" confirmText="确定" @confirm="confirm">
			<rich-text :nodes="content"></rich-text>
		</u-modal>
		<!-- <view style="margin:0 20rpx;">
			<u-overlay :show="!isLoad">
				<login @success="reOnLoad()" @fail="failToLoad()"></login>
			</u-overlay>
		</view> -->
	</view>
</template>

<script>
	import login from 'pages/my/login/login'
	export default {
		components: {
			login
		},
		data() {
			return {
				name: '',
				phone: '',
				showM: false,
				isLoad: true,
				//会员中心的用户名旁边不显示edit图标
				show: false,
				content: `请保持手机畅通<br>
								客服会及时联系您`,
				commitment: '承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置'
			}
		},
		onLoad() {
			if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
				this.isLoad = false
				// uni.navigateTo({
				// 	url: '../../pages/my/login/login'
				// })
				return
			}
			this.isLoad = true
		},
		methods: {
			// 联系客服模态框
			handleSureClick() {
				let name = this.$refs.nameAndphone.model.userInfo.name
				let phone = this.$refs.nameAndphone.model.userInfo.phone
				this.$apiServe.bindComponyAndUpdate({
					uid: 1,
					type: 2,
					companyName: name,
					companyPhone: phone
				}).then(res => {
					console.log('升级VIP', res.data);
					if (res.data.code == 20003) {
						this.showM = true
					} else if (res.data.code == 20005) {
						this.$toast.warn('请完善数据')
					}

				}).finally(_ => {})
			},
			confirm() {
				this.showM = false
				// uni.switchTab({
				// 	url: '/pages/my/my'
				// })
			},
			reOnLoad() {
				if (!uni.getStorageSync('loginToken') || uni.getStorageSync('loginToken').length === 0) {
					this.$toast.warn('登录失败请重试')
					this.isLoad = false
					// uni.navigateTo({
					// 	url: '../../pages/my/login/login'
					// })
					return
				}
				this.isLoad = true
			},
			failToLoad() {
				this.$toast.warn('登录失败请重试')
			}
		}
	}
</script>

<style lang="scss">
	.commitment {
		font-size: 26rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #C8C8C8;
		line-height: 28rpx;
		margin: 40rpx 66rpx;
	}

	.u-button {
		width: 644rpx !important;
		height: 86rpx !important;
		background: #0EBB5B;
		border-radius: 20rpx !important;
	}

	.u-modal__content {
		padding: 43rpx 104rpx !important;
		text-indent: 14rpx;
	}

	.u-modal__button-group__wrapper--hover {
		background: #0EBB5B !important;
	}
</style>
