const app = getApp()
const util = require('../../utils/util');
import {
	Base
} from '../../utils/base.js';
const base = new Base()
Page({
	data: {
		tel: '',
		password: '',
		locked: false,
	},
	key_Tel: function (e) {
		this.setData({
			tel: e.detail.value
        })
        console.log(this.data.tel)
	},
	key_password: function (e) {
		this.setData({
			password: e.detail.value
		})
	},
	telBind: function () {
        let reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
		let that = this
		const {
			tel,
			password
        } = this.data
        if (!tel) {
			base.toast('请输入手机号')
			return
        }
        if (!reg.test(tel)) {
            base.toast("手机号码输入有误");
            return;
        }
		if (!password) {
			base.toast('请输入密码')
			return
		}
		if (!this.data.locked) {
			that.setData({
				locked: true
			})
			let params = {
				url: 'user/unbind',
				data: {
					tel: tel,
					password: password
				},
				type: "POST",
				callback: (data) => {
					console.log(data)
				}
			}
			base.newRequest(params)
		}
	},
})