index.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. import { sendPhoneCode, usePhoneBound, resumeBase, groupApply } from '../../services/index.js'
  2. import { showToast } from '../../utils/tips.js'
  3. import { argusToTimestamp } from '../../utils/util.js'
  4. import $wuxCountDown from '../../utils/coutdown.js'
  5. var app = getApp()
  6. Page({
  7. data: {
  8. sex: ["男", "女"],
  9. sex_index: 0,
  10. sid: app.globalData.sid,
  11. iphone: "",
  12. yzm: '',
  13. age:'',
  14. realName:'',
  15. clearTimer:false,
  16. },
  17. onLoad: function (options) {
  18. },
  19. // 姓名输入
  20. bindNameChange(e){
  21. this.setData({
  22. realName : e.detail.detail.value
  23. })
  24. },
  25. // 年龄输入
  26. bindAgeChange(e) {
  27. this.setData({
  28. age : e.detail.detail.value
  29. })
  30. },
  31. // 性别输入
  32. bindSexChange(e) {
  33. this.setData({
  34. sex_index: e.detail.value
  35. })
  36. },
  37. // 手机号输入
  38. bindPhoneInput(e) {
  39. this.setData({
  40. iphone : e.detail.detail.value
  41. })
  42. },
  43. // 验证码号输入
  44. bindCodeInput(e) {
  45. this.setData({
  46. yzm : e.detail.detail.value
  47. })
  48. },
  49. //倒计时
  50. vcode() {
  51. if (this.djs && this.djs.interval) return !1
  52. this.djs = new $wuxCountDown({
  53. date: +(new Date) + 60000,
  54. onEnd() {
  55. this.setData({
  56. djs: '重新获取验证码',
  57. })
  58. },
  59. render(date) {
  60. const sec = this.leadingZeros(date.sec, 2) + ' 秒 '
  61. date.sec !== 0 && this.setData({
  62. djs: '重新发送(' + sec + ')',
  63. })
  64. },
  65. })
  66. },
  67. // 验证码发送
  68. sendCode(e) {
  69. if (this.data.iphone.length != 11) {
  70. showToast('请输入11位手机号码!')
  71. return
  72. }
  73. if (this.data.djs && this.data.djs !== '重新获取验证码') {
  74. return false
  75. }
  76. this.vcode()
  77. sendPhoneCode({
  78. phoneNo: this.data.iphone
  79. }).then(data => {
  80. })
  81. },
  82. // 信息提交
  83. handleClick(e){
  84. if (this.data.iphone.length != 11) {
  85. showToast('请输入11位手机号码!')
  86. return
  87. }
  88. if (!this.data.realName) {
  89. showToast('请输入姓名!')
  90. return
  91. }
  92. if (!this.data.age) {
  93. showToast('请输入年龄!')
  94. return
  95. }
  96. var ageTime = argusToTimestamp([this.data.age])/1000
  97. var gender = this.data.sex_index==0?1:2
  98. if(!this.data.sid){ // 不是用户先注册用户
  99. usePhoneBound({
  100. phoneNo:this.data.iphone,
  101. msgCode:this.data.yzm
  102. }).then(data=>{
  103. app.globalData.sid = data.data.sid
  104. app.globalData.shareToken = data.data.shareToken
  105. this.createUserResume(this.data.iphone, this.data.realName, ageTime, gender)
  106. }).catch(data=>{
  107. showToast(data.message)
  108. })
  109. }else{
  110. this.createUserResume(this.data.iphone, this.data.realName, ageTime, gender)
  111. }
  112. },
  113. // 简历创建
  114. createUserResume(phoneNo,realName,ageTime,gender){
  115. resumeBase({
  116. resBornTime: ageTime,
  117. resGender: gender,
  118. resName: realName ,
  119. resPhone: phoneNo,
  120. }).then(data=>{
  121. this.goGroupApply(this.options.hpPositionGroupId)
  122. }).catch(err=>{
  123. if(err.errorCode == 2){
  124. this.goGroupApply()
  125. }
  126. })
  127. },
  128. // 参与拼团
  129. goGroupApply(){
  130. groupApply(this.options.hpPositionGroupId).then(data=>{
  131. wx.navigateTo({
  132. url: '../pt-detail/index?hpPositionGroupId=' + this.options.hpPositionGroupId,
  133. })
  134. })
  135. },
  136. onError(err) {
  137. app.aldstat.sendEvent('报错',{
  138. 'err': err
  139. });
  140. },
  141. })