index.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. const app = getApp();
  2. const verify = require("../../../common/js/verify.js");
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. shift: '',
  9. time: '09:00',
  10. date: '',
  11. startDate: '',
  12. image: '',
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad(options) {
  18. const now = new Date();
  19. const date = `${now.getFullYear()}-${String(now.getMonth()+1).padStart(2,'0')}-${String(now.getDate()).padStart(2,'0')}`;
  20. this.setData({
  21. date: date,
  22. startDate: date
  23. });
  24. },
  25. TimeChange(e) {
  26. this.setData({
  27. time: e.detail.value
  28. });
  29. },
  30. DateChange(e) {
  31. this.setData({
  32. date: e.detail.value
  33. });
  34. },
  35. vmodel(e) {
  36. this.setData({
  37. [e.currentTarget.dataset.value]: e.detail.value
  38. })
  39. },
  40. ChooseImage() {
  41. let that = this;
  42. wx.chooseMedia({
  43. count: 1,
  44. success: (res) => {
  45. app.upload(res.tempFiles[0].tempFilePath, function (res) {
  46. that.setData({image: res});
  47. });
  48. },
  49. fail: () => {
  50. app.msg('请检查相册权限是否开启');
  51. }
  52. });
  53. },
  54. DelImg(e) {
  55. this.setData({image:''});
  56. },
  57. ViewImage(e) {
  58. wx.previewImage({
  59. urls: [this.data.image],
  60. });
  61. },
  62. submit() {
  63. let self = this;
  64. if (verify.isEmpty(this.data.shift) && verify.isEmpty(this.data.image)) {
  65. app.msg('班次/出发时间和车票图片至少要填一样');
  66. return false;
  67. }
  68. app.post('talent/appointment/book', {
  69. shift: this.data.shift,
  70. date: this.data.date,
  71. time: this.data.time,
  72. image: this.data.image
  73. }, function (res) {
  74. self.toList();
  75. });
  76. },
  77. toList() {
  78. wx.redirectTo({
  79. url: '/pages/talent/appointment/list',
  80. })
  81. }
  82. })