<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>
</template>

<script>
	export default {
		data() {
			return {
				name: '',
				phone: '',
				showM: false,
				//部分产品无权限访问，需升级VIP
				needAsk: '',
				//会员中心的用户名旁边不显示edit图标
				show: false,
				content: `请保持手机畅通<br>
								客服会及时联系您`,
				commitment: '承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置承诺声明预留文字位置'
			}
		},
		onLoad(option) {
			console.log('ask', option.ask);
			if (option.ask == 1) {
				this.needAsk = option.ask
			}
		},
		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
				if (this.needAsk == 1) {
					uni.switchTab({
						url: '/pages/index/index'
					})
				}
			}
		}
	}
</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>
