<template>
	<view :style="colorStyle">
		<form @submit="recharge">
			<view class="ChangePassword">
				<view class="list">
					<view class="item">
						<view class="name">
							卡号：
						</view>
						<input class="inputItem" type='number' placeholder='填写卡号' placeholder-class='placeholder'
							v-model="phone"></input>
					</view>
					<view class="item">
						<view class="name">
							卡密：
						</view>
						<input class="inputItem" type='number' placeholder='填写卡密' placeholder-class='placeholder'
							v-model="pwd"></input>
					</view>
				</view>
				<button form-type="submit" class="confirmBnt bg-color">确认激活</button>
			</view>
		</form>
		<!-- #ifdef MP -->
		<!-- <authorize v-if="isShowAuth" @authColse="authColse" @onLoadFun="onLoadFun"></authorize> -->
		<!-- #endif -->
	</view>
</template>

<script>
	import {
		recharge
	} from '@/api/new.js';
	import {
		toLogin
	} from '@/libs/login.js';
	import {
		mapGetters
	} from "vuex";
	import colors from '@/mixins/color.js';
	export default {
		mixins: [colors],
		data() {
			return {
				phone: '',
				pwd: '',
			};
		},
		computed: mapGetters(['isLogin']),
		onLoad(options) {
			if (!this.isLogin) {
				toLogin();
			}
		},
		onShow() {},
		methods: {
			onLoadFun: function() {
				this.isShowAuth = false
			},
			// 授权关闭
			authColse: function(e) {
				this.isShowAuth = e
			},
			recharge: function() {
				let that = this;
				if (!that.phone) return that.$util.Tips({
					title: '请填写卡号！'
				});
				if (!that.pwd) return that.$util.Tips({
					title: '请填写卡密'
				});
				uni.showLoading({
					title: '激活中',
					mask: true
				});
				recharge({
					no: that.phone,
					pwd: that.pwd,
				}).then(res => {
					return that.$util.Tips({
						title: res.msg,
						icon: 'success'
					}, {
						tab: 4,
						url: '/pages/user/user'
					});
				}).catch(error => {
					return that.$util.Tips({
						title: error,
					});
				})
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fff !important;
	}

	.ChangePassword {
		.confirmBnt {
			font-size: 32rpx;
			width: 580rpx;
			height: 90rpx;
			border-radius: 45rpx;
			color: #fff;
			margin: 92rpx auto 0 auto;
			text-align: center;
			line-height: 90rpx;
		}

		.phone {

			font-size: 32rpx;
			font-weight: bold;
			text-align: center;
			margin-top: 55rpx;
		}

		.list {
			width: 580rpx;
			margin: 53rpx auto 0 auto;

			.item {
				width: 100%;
				height: 110rpx;
				border-bottom: 2rpx solid #f0f0f0;
				display: flex;
				justify-content: flex-start;
				.name{
					flex-shrink: 0;
					line-height: 110rpx;
					padding-right: 20rpx;
					font-size: 32rpx;
					font-weight: bold;
				}
				input {
					flex-grow: 1;
					width: 100%;
					height: 100%;
					font-size: 32rpx;
				}

				.placeholder {
					color: #b9b9bc;
				}
			}
		}
	}
</style>