signup.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // miniprogram/signup/signup.js
  2. const app = getApp();
  3. const utils = require("../../utils/http");
  4. Component({
  5. /**
  6. * 组件的属性列表
  7. */
  8. properties: {
  9. dialog: {
  10. type: Boolean,
  11. value: false
  12. },
  13. phone: {
  14. type: Number | String,
  15. value: "",
  16. observer: function (val) {
  17. this.setData({
  18. fPhone: val
  19. })
  20. }
  21. },
  22. cid: {
  23. type: Number|String,
  24. value: ""
  25. },
  26. type: {
  27. type: String,
  28. value: ""
  29. },
  30. agentid: {
  31. type: String|Number,
  32. value: ""
  33. }
  34. },
  35. /**
  36. * 组件的初始数据
  37. */
  38. data: {
  39. dialog: false,
  40. uloading: false,
  41. phone: '',
  42. fName: "",
  43. fPhone: "",
  44. fHouse: "",
  45. cid: "",
  46. type: "",
  47. agentid: ""
  48. },
  49. /**
  50. * 组件的方法列表
  51. */
  52. methods: {
  53. dothis() { },
  54. getinputName(e) {
  55. this.setData({
  56. fName: e.detail.value
  57. })
  58. },
  59. getinputPhone(e) {
  60. this.setData({
  61. fPhone: e.detail.value
  62. })
  63. },
  64. getinputArea(e) {
  65. this.setData({
  66. fHouse: e.detail.value
  67. })
  68. },
  69. submitFunc() {
  70. const that = this;
  71. if (!this.isPhoneNum(this.data.fPhone)) {
  72. wx.showToast({
  73. title: '手机号格式错误!',
  74. icon: "none"
  75. })
  76. return false;
  77. }
  78. this.setData({
  79. uloading: true
  80. })
  81. utils.$post({
  82. url: app.globalData.webUrl + 'client/index/add_customer',
  83. data: {
  84. name: that.data.fName,
  85. phone: that.data.fPhone,
  86. community_name: that.data.fHouse,
  87. agent_id: that.data.agentid
  88. },
  89. header: {
  90. 'Authorization': 'bearer ' + app.globalData.token
  91. },
  92. success: function (r) {
  93. if (r.data.code == '0') {
  94. that.setData({
  95. uloading: false
  96. })
  97. wx.showToast({
  98. title: '报名成功',
  99. icon: "none",
  100. duration: 1000
  101. })
  102. }
  103. that.triggerEvent("close");
  104. }
  105. })
  106. },
  107. hideMaskFunc() {
  108. this.triggerEvent("close");
  109. },
  110. //手机号正则验证
  111. isPhoneNum: function (phone) {
  112. var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(18[0-9]{1})|(19[0-9]{1}))+\d{8})$/;
  113. if (!myreg.test(phone)) {
  114. return false;
  115. }
  116. return true;
  117. },
  118. }
  119. })