store-form.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // pages/store-form/store-form.js
  2. import { comApply } from '../../services/index.js'
  3. import { showToast } from '../../utils/tips.js'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. name:'',
  10. comName: '',
  11. contactNo: '',
  12. position: '',
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad: function (options) {
  18. },
  19. /**
  20. * 生命周期函数--监听页面初次渲染完成
  21. */
  22. onReady: function () {
  23. },
  24. /**
  25. * 生命周期函数--监听页面显示
  26. */
  27. onShow: function () {
  28. },
  29. // 姓名编辑
  30. bindNameInput(e){
  31. this.setData({
  32. name:e.detail.value
  33. })
  34. },
  35. // 公司编辑
  36. bindComInput(e) {
  37. this.setData({
  38. comName: e.detail.value
  39. })
  40. },
  41. // 联系方式编辑
  42. bindPhoneInput(e) {
  43. this.setData({
  44. contactNo: e.detail.value
  45. })
  46. },
  47. // 职务编辑
  48. bindPosInput(e) {
  49. this.setData({
  50. position: e.detail.value
  51. })
  52. },
  53. // 提交时间
  54. bindSubmit(e) {
  55. if (!this.data.name){
  56. showToast('请填写姓名')
  57. return false
  58. }
  59. if (!this.data.comName) {
  60. showToast('请填写公司')
  61. return false
  62. }
  63. if (!this.data.contactNo) {
  64. showToast('请填写联系方式')
  65. }
  66. comApply({
  67. name: this.data.name,
  68. comName: this.data.comName,
  69. contactNo: this.data.contactNo,
  70. position: this.data.position,
  71. }).then(data=>{
  72. showToast('提交成功')
  73. }).catch(err=>{
  74. console.log(err)
  75. })
  76. },
  77. })