clueCollect.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. '西安市',
  27. '武汉市'
  28. ],
  29. },
  30. /**
  31. * 生命周期函数--监听页面加载
  32. */
  33. onLoad: function (options) {
  34. },
  35. bindName(e){
  36. this.setData({
  37. name: e.detail.value
  38. });
  39. },
  40. bindMobile(e){
  41. this.setData({
  42. mobile: e.detail.value
  43. });
  44. },
  45. cityTap(){
  46. this.setData({
  47. showPicker:true,
  48. });
  49. },
  50. pickerCancel(){
  51. this.setData({
  52. showPicker:false,
  53. })
  54. },
  55. pickerConfirm(e){
  56. console.log(e);
  57. this.setData({
  58. city:e.detail.value,
  59. showPicker:false,
  60. });
  61. },
  62. onReachBottom() {
  63. },
  64. /**
  65. * 生命周期函数--监听页面初次渲染完成
  66. */
  67. onReady: function () {
  68. },
  69. /**
  70. * 生命周期函数--监听页面显示
  71. */
  72. onShow: function () {
  73. },
  74. onHide: function () {
  75. },
  76. onUnload: function () {
  77. },
  78. submit(){
  79. if(this.data.name==''){
  80. wx.showToast({
  81. title: '请输入姓名',
  82. icon: 'none'
  83. });
  84. return false;
  85. }else if(this.data.mobile==''){
  86. wx.showToast({
  87. title: '请输入手机号码',
  88. icon: 'none'
  89. });
  90. return false;
  91. }else if (!/^1\d{10}$/.test(this.data.mobile)) {
  92. wx.showToast({
  93. title: '请输入正确的手机号码',
  94. icon: 'none'
  95. });
  96. return false;
  97. }else if(this.data.city==''){
  98. wx.showToast({
  99. title: '请选择城市',
  100. icon: 'none'
  101. });
  102. return false;
  103. }else{
  104. wx.showLoading({
  105. title: '加载中...',
  106. });
  107. util.request(api.inputSelf, {
  108. city: this.data.city,
  109. name: this.data.name,
  110. tel:this.data.mobile
  111. }, 'POST').then(res=> {
  112. wx.hideLoading();
  113. if (res.errno === 0) {
  114. wx.showToast({
  115. title: '提交成功'
  116. })
  117. }else{
  118. wx.showToast({
  119. title: res.errmsg,
  120. icon: 'none'
  121. });
  122. }
  123. }).catch(err=>{
  124. wx.hideLoading();
  125. });
  126. }
  127. },
  128. /**
  129. * 页面相关事件处理函数--监听用户下拉动作
  130. */
  131. onPullDownRefresh:function () {
  132. },
  133. /**
  134. * 页面上拉触底事件的处理函数
  135. */
  136. onReachBottom: function () {
  137. },
  138. /**
  139. * 用户点击右上角分享
  140. */
  141. onShareAppMessage: function () {
  142. },
  143. })