index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import {
  2. sendPhoneCode,
  3. getPayrollId
  4. } from '../../services/index.js'
  5. import {
  6. showToast
  7. } from '../../utils/tips.js'
  8. import {
  9. imgServerUrl
  10. } from '../../config/config.js'
  11. import $wuxCountDown from '../../utils/coutdown.js'
  12. var app = getApp()
  13. Page({
  14. data: {
  15. imgServerUrl: imgServerUrl,
  16. iphone: "",
  17. yzm: '',
  18. },
  19. onLoad: function(opts) {
  20. console.log(opts.approveState);
  21. this.setData({
  22. approveState: opts.approveState
  23. })
  24. },
  25. //下一步提交
  26. next(e) {
  27. if (this.data.approveState != 3) {
  28. showToast('身份认证成功后才可进行查询!!!')
  29. return
  30. }
  31. if (this.data.iphone.length != 11) {
  32. showToast('请输入11位手机号码!')
  33. return
  34. }
  35. if (this.data.yzm.length != 6) {
  36. showToast('请输入6位验证码!')
  37. return
  38. }
  39. let paramsObj = {
  40. phone: this.data.iphone,
  41. code: this.data.yzm,
  42. user_id: app.globalData.userId,
  43. user_token: app.globalData.userToken
  44. }
  45. Object.assign(paramsObj);
  46. getPayrollId(paramsObj).then(data => {
  47. wx.redirectTo({
  48. url: '../wages/index?idNum=' + data.data.hpUser.idCardNumber + "&realName=" + data.data.hpUser.realName,
  49. })
  50. })
  51. },
  52. // 手机号输入
  53. bindPhoneInput(e) {
  54. this.setData({
  55. iphone: e.detail.detail.value
  56. })
  57. },
  58. // 验证码号输入
  59. bindCodeInput(e) {
  60. this.setData({
  61. yzm: e.detail.detail.value
  62. })
  63. },
  64. //倒计时
  65. vcode() {
  66. if (this.djs && this.djs.interval) return !1
  67. this.djs = new $wuxCountDown({
  68. date: +(new Date) + 60000,
  69. onEnd() {
  70. this.setData({
  71. djs: '重新获取验证码',
  72. })
  73. },
  74. render(date) {
  75. const sec = this.leadingZeros(date.sec, 2) + ' 秒 '
  76. date.sec !== 0 && this.setData({
  77. djs: '重新发送(' + sec + ')',
  78. })
  79. },
  80. })
  81. },
  82. // 验证码发送
  83. sendCode(e) {
  84. if (this.data.approveState != 3) {
  85. showToast('身份认证成功后才可进行查询!!!')
  86. return
  87. }
  88. if (this.data.iphone.length != 11) {
  89. showToast('请输入11位手机号码!')
  90. return
  91. }
  92. if (this.data.djs && this.data.djs !== '重新获取验证码') {
  93. return false
  94. }
  95. sendPhoneCode({
  96. phone: this.data.iphone
  97. }).then(data => {
  98. })
  99. this.vcode()
  100. },
  101. })