clueCollect.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. const app = getApp()
  2. const util = require("../../../utils/util");
  3. const api = require('../../../api/api.js');
  4. const user = require('../../../utils/user.js');
  5. Page({
  6. data: {
  7. name:'',
  8. mobile:'',
  9. city:'',
  10. showPicker:false,
  11. columns:['上海市',
  12. '北京市',
  13. '深圳市',
  14. '南京市',
  15. '苏州市',
  16. '无锡市',
  17. '杭州市',
  18. '青岛市',
  19. '重庆市',
  20. '成都市',
  21. '广州市',],
  22. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad: function (options) {
  27. },
  28. bindName(e){
  29. this.setData({
  30. name: e.detail.value
  31. });
  32. },
  33. bindMobile(e){
  34. this.setData({
  35. mobile: e.detail.value
  36. });
  37. },
  38. cityTap(){
  39. this.setData({
  40. showPicker:true,
  41. });
  42. },
  43. pickerCancel(){
  44. this.setData({
  45. showPicker:false,
  46. })
  47. },
  48. pickerConfirm(e){
  49. console.log(e);
  50. this.setData({
  51. city:e.detail.value,
  52. showPicker:false,
  53. });
  54. },
  55. onReachBottom() {
  56. },
  57. /**
  58. * 生命周期函数--监听页面初次渲染完成
  59. */
  60. onReady: function () {
  61. },
  62. /**
  63. * 生命周期函数--监听页面显示
  64. */
  65. onShow: function () {
  66. },
  67. onHide: function () {
  68. },
  69. onUnload: function () {
  70. },
  71. submit(){
  72. if(this.data.name==''){
  73. wx.showToast({
  74. title: '请输入姓名',
  75. icon: 'none'
  76. });
  77. return false;
  78. }else if(this.data.mobile==''){
  79. wx.showToast({
  80. title: '请输入手机号码',
  81. icon: 'none'
  82. });
  83. return false;
  84. }else if (!/^1\d{10}$/.test(this.data.mobile)) {
  85. wx.showToast({
  86. title: '请输入正确的手机号码',
  87. icon: 'none'
  88. });
  89. return false;
  90. }else if(this.data.city==''){
  91. wx.showToast({
  92. title: '请选择城市',
  93. icon: 'none'
  94. });
  95. return false;
  96. }else{
  97. wx.showLoading({
  98. title: '加载中...',
  99. });
  100. util.request(api.inputSelf, {
  101. city: this.data.city,
  102. name: this.data.name,
  103. tel:this.data.mobile
  104. }, 'POST').then(res=> {
  105. wx.hideLoading();
  106. if (res.errno === 0) {
  107. wx.showToast({
  108. title: '提交成功'
  109. })
  110. }else{
  111. wx.showToast({
  112. title: res.errmsg,
  113. icon: 'none'
  114. });
  115. }
  116. }).catch(err=>{
  117. wx.hideLoading();
  118. });
  119. }
  120. },
  121. /**
  122. * 页面相关事件处理函数--监听用户下拉动作
  123. */
  124. onPullDownRefresh:function () {
  125. },
  126. /**
  127. * 页面上拉触底事件的处理函数
  128. */
  129. onReachBottom: function () {
  130. },
  131. /**
  132. * 用户点击右上角分享
  133. */
  134. onShareAppMessage: function () {
  135. },
  136. })