register.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. new Vue({
  2. el: '#app',
  3. data: {
  4. tel: '',
  5. yzm: '',
  6. pwd: '',
  7. text: '获取验证码',
  8. s: 60,
  9. time: '',
  10. url: 'http://feisu.hdlkeji.com',
  11. pid: '',
  12. order_id: '',
  13. iszhuce: false,
  14. group_id: ''
  15. },
  16. created() {
  17. this.pid = this.getQueryVariable("pid") ? this.getQueryVariable("pid") : ''
  18. // this.order_id = this.getQueryVariable("order_id") ? this.getQueryVariable("order_id") : ''
  19. // this.group_id = this.getQueryVariable("group_id") ? this.getQueryVariable("group_id") : ''
  20. // console.log(this.pid, this.order_id);
  21. },
  22. methods: {
  23. denglv() {
  24. if (!/^1[23456789]\d{9}$/.test(this.tel)) {
  25. vant.Toast('请输入正确手机号');
  26. return
  27. }
  28. if (this.yzm == "") {
  29. vant.Toast('请输入验证码');
  30. return
  31. }
  32. vant.Toast.loading({
  33. message: '加载中...',
  34. forbidClick: true,
  35. });
  36. $.ajax({
  37. url: this.url + '/api/Login/login',
  38. type: "post",
  39. data: {
  40. phone: this.tel,
  41. verify_code: this.yzm,
  42. type: 2,
  43. },
  44. success: (res) => {
  45. vant.Toast(res.msg);
  46. if (res.code == 1) {
  47. window.sessionStorage.token = res.data
  48. setTimeout(() => {
  49. if (this.group_id) {
  50. window.location.href = "./coupon.html?group_id=" + this.group_id
  51. } else {
  52. window.location.href = "./bargaining.html?order_id=" + this.order_id + "&pid=" + this.pid
  53. }
  54. }, 800)
  55. }
  56. }
  57. })
  58. },
  59. zhuce() {
  60. if (!/^1[23456789]\d{9}$/.test(this.tel)) {
  61. vant.Toast('请输入正确手机号');
  62. return
  63. }
  64. if (this.yzm == "") {
  65. vant.Toast('请输入验证码');
  66. return
  67. }
  68. // if (this.pwd.length > 6 && this.pwd.length < 12) {
  69. // vant.Toast('请输入6-12位密码');
  70. // return
  71. // }
  72. vant.Toast.loading({
  73. message: '加载中...',
  74. forbidClick: true,
  75. });
  76. $.ajax({
  77. url: this.url + '/api/Login/register',
  78. type: "get",
  79. data: {
  80. phone: this.tel,
  81. code: this.yzm,
  82. // password: this.pwd,
  83. pid: this.pid,
  84. // order_id: this.order_id
  85. },
  86. success: (res) => {
  87. vant.Toast(res.msg);
  88. if (res.code == 1) {
  89. // window.sessionStorage.token = res.data
  90. // if (this.order_id) {
  91. // setTimeout(() => {
  92. // window.location.href = "./bargaining.html?order_id=" + this.order_id + "&pid=" + this.pid
  93. // }, 800)
  94. // } else {
  95. // setTimeout(() => {
  96. // if (this.group_id) {
  97. // window.location.href = "./coupon.html?group_id=" + this.group_id
  98. // } else {
  99. // window.location.href = "https://jyh.gujiafuwu.com/dist/download_member.html"
  100. // }
  101. // }, 800)
  102. // }
  103. }
  104. }
  105. })
  106. },
  107. getyzm() {
  108. if (/^1[23456789]\d{9}$/.test(this.tel)) {
  109. if (this.s == 60) {
  110. this.sendyzm()
  111. }
  112. } else {
  113. vant.Toast('请输入正确手机号');
  114. }
  115. },
  116. sendyzm() {
  117. vant.Toast.loading({
  118. message: '加载中...',
  119. forbidClick: true,
  120. });
  121. $.ajax({
  122. url: this.url + '/api/Login/send_sms',
  123. type: "post",
  124. data: {
  125. phone: this.tel
  126. },
  127. success: (res) => {
  128. vant.Toast(res.msg);
  129. if (res.code == 1) {
  130. this.time = setInterval(() => {
  131. this.s--
  132. this.text = this.s + '秒后重新获取'
  133. if (this.s == 0) {
  134. this.text = '获取验证码'
  135. this.s = 60
  136. clearInterval(this.time)
  137. }
  138. }, 1000)
  139. }
  140. }
  141. })
  142. },
  143. // 获取url参数
  144. getQueryVariable(variable) {
  145. var query = window.location.search.substring(1);
  146. var vars = query.split("&");
  147. for (var i = 0; i < vars.length; i++) {
  148. var pair = vars[i].split("=");
  149. if (pair[0] == variable) {
  150. return pair[1];
  151. }
  152. }
  153. return (false);
  154. }
  155. }
  156. })