抖音c端
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

121 satır
2.7 KiB

  1. const config = require("../../config/config");
  2. const Http = require("../../utils/HttpBasics");
  3. // d:\fumaolianke\ttFmC\tt富茂C\components\getPhoen\getPhoen.js
  4. Component({
  5. data: {
  6. phone: "",
  7. auth: "",
  8. time: "获取验证码",
  9. verFlag: true,
  10. currentTime: 61,
  11. setInter: ''
  12. },
  13. properties: {
  14. type: Boolean,
  15. showBox: false
  16. },
  17. methods: {
  18. getCode() {
  19. var that = this;
  20. var currentTime = that.data.currentTime
  21. that.data.setInter = setInterval(function () {
  22. currentTime--;
  23. that.setData({
  24. time: currentTime + '秒'
  25. })
  26. if (currentTime <= 0) {
  27. clearInterval(that.data.setInter)
  28. that.setData({
  29. time: '获取验证码',
  30. currentTime: 61,
  31. verFlag: true
  32. })
  33. }
  34. }, 1000)
  35. },
  36. setPhone(e) {
  37. this.setData({
  38. phone: e.detail.value
  39. })
  40. },
  41. setAuth(e) {
  42. this.setData({
  43. auth: e.detail.value
  44. })
  45. },
  46. verify() {
  47. let phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
  48. if (!this.data.verFlag) {
  49. return
  50. }
  51. if (phoneReg.test(this.data.phone)) {
  52. Http.get({
  53. url: config.api.sendValidationCode,
  54. data: {
  55. phone: this.data.phone,
  56. type:6
  57. }
  58. }).then(res => {
  59. console.log(res, "res");
  60. this.setData({
  61. verFlag: false
  62. })
  63. this.getCode()
  64. }).catch(err => {
  65. tt.showToast({
  66. title: err.message ? err.message : err.data, // 内容
  67. icon: "none"
  68. });
  69. })
  70. } else {
  71. tt.showToast({
  72. title: '手机号有误',
  73. icon: "none",
  74. })
  75. }
  76. },
  77. hieBox(){
  78. this.triggerEvent("heiBox" ,false)
  79. },
  80. hiePhoen(){
  81. this.triggerEvent("hiePhoen" ,false)
  82. },
  83. send() {
  84. let phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
  85. if (phoneReg.test(this.data.phone)) {
  86. console.log(this.data.auth);
  87. if(this.data.auth!=""){
  88. Http.get({
  89. url: config.api.validationCode,
  90. data: {
  91. phone: this.data.phone,
  92. code: this.data.auth,
  93. type:6
  94. }
  95. }).then(res => {
  96. this.hiePhoen()
  97. }).catch(err => {
  98. tt.showToast({
  99. title: err.message ? err.message : err.data, // 内容
  100. icon: "none"
  101. });
  102. })
  103. }else{
  104. tt.showToast({
  105. title: '请输入验证码',
  106. icon: "none",
  107. })
  108. }
  109. } else {
  110. tt.showToast({
  111. title: '手机号有误',
  112. icon: "none",
  113. })
  114. }
  115. }
  116. }
  117. })