apply-leave.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.showModal({
  53. title: '请假成功',
  54. content: '请假成功',
  55. success: function (res) {
  56. wx.switchTab({
  57. url: '/pages/userinfo/userinfo',
  58. })
  59. }
  60. })
  61. } else {
  62. wx.showToast({
  63. title: res.data.info,
  64. icon: 'none',
  65. duration: 800
  66. })
  67. }
  68. }
  69. })
  70. }
  71. })