apply-leave.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. var app = getApp()
  2. var api = require('../../utils/api.js');
  3. Page({
  4. data: {
  5. date: '',
  6. typeEnum: [
  7. '短假', '长假'
  8. ],
  9. selectedType: 0
  10. },
  11. onLoad: function () {
  12. let date = this.getNowFormatDate();
  13. this.setData({
  14. date: date
  15. })
  16. },
  17. getNowFormatDate() {
  18. var date = new Date();
  19. var seperator1 = "-";
  20. var year = date.getFullYear();
  21. var month = date.getMonth() + 1;
  22. var strDate = date.getDate();
  23. if(month >= 1 && month <= 9) {
  24. month = "0" + month;
  25. }
  26. if (strDate >= 0 && strDate <= 9) {
  27. strDate = "0" + strDate;
  28. }
  29. var currentdate = year + seperator1 + month + seperator1 + strDate;
  30. return currentdate;
  31. },
  32. bindDateChange: function(e) {
  33. console.log('picker发送选择改变,携带值为', e.detail.value)
  34. this.setData({
  35. date: e.detail.value
  36. })
  37. },
  38. formSubmit: function (e) {
  39. let value = e.detail.value
  40. wx.request({
  41. url: api.applyLeaveUrl,
  42. method: 'GET',
  43. data: {
  44. 'student_id': wx.getStorageSync('pt_student').id,
  45. 'date': value.date,
  46. 'type': value.type == 0 ? '1' : '2',
  47. 'days': value.days,
  48. 'remark': value.remark
  49. },
  50. success: res => {
  51. if(res.data.status == 'success') {
  52. wx.showToast({
  53. title: '请假成功',
  54. icon: 'none',
  55. duration: 800
  56. })
  57. } else {
  58. wx.showToast({
  59. title: res.data.info,
  60. icon: 'none',
  61. duration: 800
  62. })
  63. }
  64. }
  65. })
  66. }
  67. })