123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- 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);
- }
- }
- })
|