<template src="./payView.html">

</template>
<script>
	const util = require('@/utils/util.js').default;
	import {
		MessageBox
	} from 'mint-ui';
	import {
		Indicator
	} from 'mint-ui';
	import {
		Toast
	} from 'mint-ui';
	// import lottie from "lottie-web"; //lottie
	// import commonMethod from '@/common/commonMethod.js';
	// import touchHandle from '@/mixins/touchHandle.js';
	// import requestConfig from '@/static/lib/requestConfig';

	export default {
		data: function() {
			return {
				showRedBox:false,	//是否显示红包设置
				count:'',
				money:'',
				message:'',
				selList:[
					{
						index:0,
						text:'10',
					},
					{
						index:1,
						text:'30',
					},
					{
						index:2,
						text:'50',
					},
					{
						index:3,
						text:'100',
					},
					{
						index:4,
						text:'200',
					},
					{
						index:5,
						text:'其他金额',
					}
				]
			}
		},
		props: {

		},
		// mixins: [touchHandle],
		async mounted() {
			// await this.getCityHouseList();		
			console.warn("***payView***")
		},
		// 页面被展示时执行
		onPageShow: function() {

		},
		//页面被隐藏时执行
		onPageHide: function() {
			// console.warn("***detached-hide***")
		},
		methods: {
			showRedBoxSet() {
				this.showRedBox = true;
			},
			hideRedBoxSet() {
				this.showRedBox = false;
			},
			bindCount(e){
				console.log('bindCount：', this.count)
				if (this.count.length > 0) {
					// console.warn("***this.count***",this.count)
					let num = Number(this.count);
					if (this.count.indexOf('.') > -1) {
						Toast({
							message: '只能输入整数！',
						});
						this.count = '';
					}
					else if (isNaN(this.count)) {
						Toast({
							message: '只能输入数字！',
						});
						this.count = '';
					}else if (num <= 0 || num > 10000) {
						Toast({
							message: '红包数量最少1个，最大10000个！',
						});
						this.count = '';
					}
				}
				// this.count = e.data;
			},
			bindMoney(e){
				// console.log('bindMoney：', e,this.money)
				let data = this.money;
				if (data.length > 0) {
					console.warn("***bindMoney***",data)
					let num = Number(this.money);
					if (isNaN(data)) {
						Toast({
							message: '只能输入数字！',
						});
						this.money = '';
					}
				}
			},
			//移动光标到最后
			moveCursorToEnd(e) {
			    // 获取input元素
				this.$nextTick(() => {
					const input = this.$refs.moneyInput;
					// 设置光标位置为文本末尾
					input.selectionStart = input.selectionEnd = input.value.length;
				});
			},
			lostMoneyFocus(e){
				let data = this.money;
				if (data.length > 0) {
					console.warn("***lostMoneyFocus***",data)
					let num = Number(this.money);
					if (num > 200) {
						Toast({
							message: '每个红包金额上限为200元！',
						});
						this.money = '';
					}else if (num < 0.01) {
						Toast({
							message: '单个红包金额不可以低于0.01元！',
						});
						this.money = '';
					}
					if(this.count){
						let count = Number(this.count);
						if(num/count<0.01){
							Toast({
								message: '需要保证每个红包最少0.01元！',
							});
							this.money = '';
						}
					}
				}
			},
			// bindMessage(e){
			// 	console.log('bindMessage：', e)
			// 	// this.message = e.data;
			// },
			scrollToInput() {
			    // 获取输入框元素
			    const input = this.$refs.messageInput;
			    // 滚动页面，将输入框滚动到可见区域
			    input.scrollIntoView({ behavior: "smooth", block: "center", inline: "center" });
			},
			//充值金额选择事件
			selectAction(selItem, index) {
				console.log('充值金额点击动作：', selItem, index)
				if(index<5){
					this.money = Number(selItem.text)
				}else{
					this.$refs.moneyInput.focus();
				}
			},
			catchTouchMove: function(e) {
				return false;
			},
			// hideOrShowActor(type){
			// 	this.$emit('hideOrShowActor',type);//隐藏所有视角
			// },
			//发布全景
			mynavigateFuc(e) {
				if(!this.count){
					Toast({
						message: '请输入红包个数！',
					});
					return false;
				}
				if(!this.money){
					Toast({
						message: '请输入充值金额！',
					});
					return false;
				}
				let param = {
					type: 'CLK', //埋点类型
					clkId: 'clk_2cmina_24010201', //点击ID
					clkName: 'webglvr_rebboxset_clk', //点击前往的页面名称
					clkParams: {
						locusName: "确定红包设置",
					}
				};
				util.trackRequest(param);
				this.$parent.redBoxData.count = this.count;
				this.$parent.redBoxData.money = this.money;
				this.$parent.redBoxData.message = this.message || "恭喜发财，大吉大利";
				this.hideRedBoxSet();
			},
		}
	}
</script>
<style lang="scss" scoped>
	@import "./payView.scss";
	/* @import "@/common/css/common.css"; */
</style>