index.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 { testPhone } from '../../utils/util'
  12. import $wuxCountDown from '../../utils/coutdown.js'
  13. var app = getApp()
  14. Page({
  15. data: {
  16. imgServerUrl: imgServerUrl,
  17. iphone: "",
  18. yzm: '',
  19. phone: '',
  20. url: '',
  21. reset: false
  22. },
  23. onLoad: function (options) {
  24. if (options.phone) {
  25. this.setData({
  26. phone: options.phone,
  27. url: options.url,
  28. auto_send: options.auto_send
  29. })
  30. if (options.title) {
  31. wx.setNavigationBarTitle({
  32. title: options.title,
  33. })
  34. }
  35. }
  36. // console.log(opts.approveState);
  37. // this.setData({
  38. // approveState: opts.approveState
  39. // })
  40. // if (opts.approveState == 0) {
  41. // wx.showModal({
  42. // title: '您还未进行实名认证',
  43. // content: '认证后即可使用查询功能',
  44. // cancelText: '以后再说',
  45. // confirmText: '立即认证',
  46. // success(res) {
  47. // if (res.confirm) {
  48. // wx.redirectTo({
  49. // url: '../identification/index',
  50. // })
  51. // } else if (res.cancel) {
  52. // wx.navigateBack({
  53. // delta: 1
  54. // })
  55. // }
  56. // }
  57. // })
  58. // }
  59. },
  60. //下一步提交
  61. next(e) {
  62. if (this.data.approveState != 3) {
  63. showToast('身份认证成功后才可进行查询!!!')
  64. return
  65. }
  66. if (this.data.iphone.length != 11) {
  67. showToast('请输入11位手机号码!')
  68. return
  69. }
  70. if (this.data.yzm.length != 6) {
  71. showToast('请输入6位验证码!')
  72. return
  73. }
  74. let paramsObj = {
  75. phone: this.data.iphone,
  76. code: this.data.yzm,
  77. user_id: app.globalData.userId,
  78. user_token: app.globalData.userToken,
  79. member_id: app.globalData.memberId
  80. }
  81. Object.assign(paramsObj);
  82. getPayrollId(paramsObj).then(data => {
  83. wx.redirectTo({
  84. url: '../wages/index?idNum=' + data.data.hpMember.idCardNumber + "&realName=" + data.data.hpMember.realName,
  85. })
  86. })
  87. },
  88. // 手机号输入
  89. bindPhoneInput(e) {
  90. this.setData({
  91. iphone: e.detail.value
  92. })
  93. },
  94. // 验证码号输入
  95. bindCodeInput(e) {
  96. this.setData({
  97. yzm: e.detail.value
  98. })
  99. },
  100. //倒计时
  101. vcode() {
  102. if (this.djs && this.djs.interval) return !1
  103. this.djs = new $wuxCountDown({
  104. date: +(new Date) + 60000,
  105. onEnd() {
  106. this.setData({
  107. djs: '获取验证码',
  108. })
  109. },
  110. render(date) {
  111. const sec = this.leadingZeros(date.sec, 2) + ' 秒 '
  112. date.sec !== 0 && this.setData({
  113. djs: '剩余' + sec + '',
  114. })
  115. },
  116. })
  117. },
  118. // 验证码发送
  119. sendCode(e) {
  120. if (this.data.approveState != 3) {
  121. showToast('身份认证成功后才可进行查询!!!')
  122. return
  123. }
  124. if (this.data.iphone.length != 11) {
  125. showToast('请输入11位手机号码!')
  126. return
  127. }
  128. if (this.data.djs && this.data.djs !== '重新获取验证码') {
  129. return false
  130. }
  131. sendPhoneCode({
  132. phone: this.data.iphone
  133. })
  134. this.vcode()
  135. },
  136. send(data) {
  137. sendPhoneCode({
  138. phone: this.data.phone,
  139. ...data.detail
  140. })
  141. },
  142. toList(e) {
  143. if (testPhone(this.data.phone)) {
  144. let paramsObj = {
  145. phone: this.data.phone,
  146. code: e.detail.code,
  147. user_id: app.globalData.userId,
  148. user_token: app.globalData.userToken,
  149. member_id: app.globalData.memberId
  150. }
  151. getPayrollId(paramsObj).then(data => {
  152. wx.setStorage({
  153. key: 'hpMember',
  154. data: data.data.hpMember,
  155. success: res => {
  156. wx.redirectTo({
  157. url: this.data.url,
  158. })
  159. }
  160. })
  161. }).catch(data => {
  162. this.setData({
  163. reset: !this.data.reset
  164. })
  165. })
  166. } else {
  167. wx.showToast({
  168. icon: 'none',
  169. title: '电话号码格式错误',
  170. })
  171. }
  172. }
  173. })