东风启辰小程序端
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

132 lines
2.6KB

  1. // pages/mobileVerification/mobileVerification.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imgUrl: app.globalData.urlStatic,//图片路径
  9. isAgreement: true,//是否同意协议
  10. verificationCode: '获取验证码',//验证码文案
  11. sendCode: true,
  12. mobileText:"",//手机号
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. },
  19. /**
  20. * 生命周期函数--监听页面初次渲染完成
  21. */
  22. onReady: function () {
  23. },
  24. /**
  25. * 生命周期函数--监听页面显示
  26. */
  27. onShow: function () {
  28. },
  29. /**
  30. * 生命周期函数--监听页面隐藏
  31. */
  32. onHide: function () {
  33. },
  34. /**
  35. * 生命周期函数--监听页面卸载
  36. */
  37. onUnload: function () {
  38. },
  39. /**
  40. * 页面相关事件处理函数--监听用户下拉动作
  41. */
  42. onPullDownRefresh: function () {
  43. },
  44. /**
  45. * 页面上拉触底事件的处理函数
  46. */
  47. onReachBottom: function () {
  48. },
  49. /**
  50. * 用户点击右上角分享
  51. */
  52. onShareAppMessage: function () {
  53. return app.sharePack();
  54. },
  55. agreementState: function () {//协议
  56. this.setData({
  57. isAgreement: !this.data.isAgreement
  58. })
  59. },
  60. getCode: function (e) {//获取验证码
  61. if (!app.mobileVerify(this.data.mobileText)) {
  62. if (this.data.mobileText) {
  63. wx.showToast({
  64. title: '请输入正确的电话',
  65. icon: 'none'
  66. })
  67. } else {
  68. wx.showToast({
  69. title: '请输入电话',
  70. icon: 'none'
  71. })
  72. }
  73. return;
  74. }
  75. if (!this.data.sendCode) {
  76. return;
  77. }
  78. this.data.sendCode = false;
  79. app.wxRequest(app.globalData.urlRoot + "captcha/sendCaptcha", { mobile: this.data.mobileText }, res => {
  80. if (res.code == 200) {
  81. this.countDown();
  82. wx.showToast({
  83. title: '验证码获取成功',
  84. icon: "none"
  85. })
  86. this.setData({
  87. verificationCode: 60
  88. })
  89. } else {
  90. this.data.sendCode = true;
  91. wx.showToast({
  92. title: res.msg,
  93. icon: "none"
  94. })
  95. }
  96. }, this)
  97. },
  98. countDown: function () {//倒计时
  99. setTimeout(() => {
  100. this.setData({
  101. verificationCode: this.data.verificationCode - 1
  102. })
  103. if (this.data.verificationCode > 0) {
  104. this.countDown();
  105. } else {
  106. this.setData({
  107. verificationCode: "获取验证码"
  108. })
  109. this.data.sendCode = true;
  110. }
  111. }, 1000);
  112. },
  113. getMoblie:function(e){//获取用户输入的手机号
  114. this.data.mobileText = e.detail.value
  115. }
  116. })