yuY.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. var app = getApp();
  2. var that;
  3. import moment from 'moment' // 时间库
  4. Page({
  5. data: {
  6. userData: {},
  7. name: '',
  8. mobile: '',
  9. },
  10. onLoad() {
  11. that = this;
  12. dd.setNavigationBar({ title: "预约演示" });
  13. that.setData({
  14. userData: app.globalData.userData,
  15. })
  16. },
  17. bindKeyInput(e) {
  18. this.setData({
  19. name: e.detail.value,
  20. });
  21. },
  22. bindKeyInput2(e) {
  23. this.setData({
  24. mobile: e.detail.value,
  25. });
  26. },
  27. submit() {
  28. if (!this.data.name) {
  29. app.globalData.showToast('请输入姓名');
  30. return false;
  31. }
  32. if (!this.data.mobile) {
  33. app.globalData.showToast('请输手机号码');
  34. return false;
  35. }
  36. let str = /^1[345789]\d{9}$/
  37. if (!str.test(this.data.mobile)) {
  38. app.globalData.showToast('手机号码格式不正确')
  39. return false
  40. }
  41. let data={
  42. name:this.data.name,
  43. mobile:this.data.mobile,
  44. }
  45. app.$post('api/employee/appointment', data).then(res => {
  46. if (res.data.code == 1) {
  47. app.globalData.showToast('提交成功,我们的绩效老师将在24小时内与您联系');
  48. setTimeout(()=>{
  49. dd.navigateBack({
  50. delta: 1
  51. })
  52. },1000)
  53. }
  54. });
  55. },
  56. });