<template>
	<view>
		<view class="ceng"></view>
		<view class="update-pop">
			<view class="bind-mobile">
				<image :src="picUrlss+'sim_phone.png'"></image>
				<view class="update-tip">更多服务，请授权登录</view></view>
				<button class="update-btn ddflex" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">一键登录</button>
			</view>
		</view>
	</view>
</template>

<script>
const app = getApp();
const req = require('../../utils/request.js');

export default {
	data() {
		return {
			picUrlss: req.public.picUrls,
		};
	},

	components: {},
	props: {
	},
	watch: {},

	mounted() {
	},

	methods: {
		getPhoneNumber(e) {
			let that = this;
			let sessionKey = '';
			app.globalData.getCheckSessoin(json => {
				sessionKey = json.session_key;
				let _params = {
					sessionKey: sessionKey,
					iv: e.detail.iv,
					encryptedData: e.detail.encryptedData
				};
				if (req.getStorage('pidCode')) {
					_params.parentId = req.getStorage('pidCode');
				}
				if (e.detail.errMsg == 'getPhoneNumber:ok') {
					req.postRequest('/api/weixin/mobile', _params, json => {
						if (json.mobile) {
							var userInfo = req.getStorage('userInfo');
							userInfo.mobile = json.mobile;
							req.setStorage('userInfo', userInfo);
							that.closeUpdate();
							req.removeStorage('isShowUpdateMobile')
						}
					});
				} else {
				}
			});
		},
		closeUpdate() {
			this.$emit('closePop');
		}
	}
};
</script>

<style>
@import './index.css';
</style>
