new Vue({ el: '#app', data: { tel: '', yzm: '', pwd: '', text: '获取验证码', s: 60, time: '', url: 'http://feisu.hdlkeji.com', pid: '', order_id: '', iszhuce: false, group_id: '' }, created() { this.pid = this.getQueryVariable("pid") ? this.getQueryVariable("pid") : '' // this.order_id = this.getQueryVariable("order_id") ? this.getQueryVariable("order_id") : '' // this.group_id = this.getQueryVariable("group_id") ? this.getQueryVariable("group_id") : '' // console.log(this.pid, this.order_id); }, methods: { denglv() { if (!/^1[23456789]\d{9}$/.test(this.tel)) { vant.Toast('请输入正确手机号'); return } if (this.yzm == "") { vant.Toast('请输入验证码'); return } vant.Toast.loading({ message: '加载中...', forbidClick: true, }); $.ajax({ url: this.url + '/api/Login/login', type: "post", data: { phone: this.tel, verify_code: this.yzm, type: 2, }, success: (res) => { vant.Toast(res.msg); if (res.code == 1) { window.sessionStorage.token = res.data setTimeout(() => { if (this.group_id) { window.location.href = "./coupon.html?group_id=" + this.group_id } else { window.location.href = "./bargaining.html?order_id=" + this.order_id + "&pid=" + this.pid } }, 800) } } }) }, zhuce() { if (!/^1[23456789]\d{9}$/.test(this.tel)) { vant.Toast('请输入正确手机号'); return } if (this.yzm == "") { vant.Toast('请输入验证码'); return } // if (this.pwd.length > 6 && this.pwd.length < 12) { // vant.Toast('请输入6-12位密码'); // return // } vant.Toast.loading({ message: '加载中...', forbidClick: true, }); $.ajax({ url: this.url + '/api/Login/register', type: "get", data: { phone: this.tel, code: this.yzm, // password: this.pwd, pid: this.pid, // order_id: this.order_id }, success: (res) => { vant.Toast(res.msg); if (res.code == 1) { // window.sessionStorage.token = res.data // if (this.order_id) { // setTimeout(() => { // window.location.href = "./bargaining.html?order_id=" + this.order_id + "&pid=" + this.pid // }, 800) // } else { // setTimeout(() => { // if (this.group_id) { // window.location.href = "./coupon.html?group_id=" + this.group_id // } else { // window.location.href = "https://jyh.gujiafuwu.com/dist/download_member.html" // } // }, 800) // } } } }) }, getyzm() { if (/^1[23456789]\d{9}$/.test(this.tel)) { if (this.s == 60) { this.sendyzm() } } else { vant.Toast('请输入正确手机号'); } }, sendyzm() { vant.Toast.loading({ message: '加载中...', forbidClick: true, }); $.ajax({ url: this.url + '/api/Login/send_sms', type: "post", data: { phone: this.tel }, success: (res) => { vant.Toast(res.msg); if (res.code == 1) { this.time = setInterval(() => { this.s-- this.text = this.s + '秒后重新获取' if (this.s == 0) { this.text = '获取验证码' this.s = 60 clearInterval(this.time) } }, 1000) } } }) }, // 获取url参数 getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } return (false); } } })