appointment.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // pages/appointment/appointment.js
  2. const app = getApp()
  3. import { submitAppointment } from '../../api/appointment'
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. hasAddress: false,
  10. address: '',
  11. calendarcolor: '#45A6B5',
  12. timeActive: '0',
  13. dialogsShow: false,
  14. appointmentSuccess: false,
  15. newDate: '',
  16. curYear: '-',
  17. curMonth: '-',
  18. maxDate: '',
  19. defaultDate: '',
  20. formatter(day) {
  21. const time = day.date.getTime();
  22. const cDate = new Date()
  23. const cyear = cDate.getFullYear()
  24. const cmonth = cDate.getMonth() + 1;
  25. const cdate = cDate.getDate();
  26. const str = cyear + '-' + cmonth + '-' + cdate
  27. if (time == new Date(str).getTime() || time == new Date(str).getTime() - 86400000) {
  28. day.text = '约满'
  29. day.type = 'disabled'
  30. day.className = 'calendar-all-full'
  31. }
  32. return day;
  33. }
  34. },
  35. /**
  36. * 生命周期函数--监听页面加载
  37. */
  38. onLoad(options) {
  39. },
  40. /**
  41. * 生命周期函数--监听页面显示
  42. */
  43. onShow() {
  44. if (app.globalData.navigateBackParams.address ) {
  45. this.setData({
  46. hasAddress: true,
  47. address: app.globalData.navigateBackParams.address
  48. })
  49. }
  50. this.handleDate()
  51. },
  52. // 处理日期
  53. handleDate () {
  54. const date = new Date()
  55. const time = date.getTime()
  56. const year = date.getFullYear()
  57. const month = date.getMonth() + 1
  58. const day = date.getDate()
  59. const str = year + '-' + month + '-' + day
  60. const _maxDate= 2592000000 + time
  61. const _defaultDate = new Date(str).getTime() + 86400000
  62. this.setData({
  63. curYear: year,
  64. curMonth: month,
  65. maxDate: _maxDate,
  66. defaultDate: _defaultDate
  67. })
  68. },
  69. /**
  70. * 选择地址
  71. */
  72. handleChoseAddress() {
  73. wx.navigateTo({
  74. url: '/pages/address/address?form=appointment&back=1',
  75. })
  76. },
  77. handleChangeAddress () {
  78. if (!this.data.appointmentSuccess) {
  79. wx.navigateTo({
  80. url: '/pages/address/address?form=appointment&back=1',
  81. })
  82. }
  83. },
  84. handleSelect (val) {
  85. var selectMonth = new Date(val.detail).getMonth() + 1
  86. var selectYear = new Date(val.detail).getFullYear()
  87. this.setData({
  88. curYear: selectYear,
  89. curMonth: selectMonth
  90. })
  91. },
  92. handleTime (e) {
  93. console.log(e);
  94. var timeActiveIndex = e.currentTarget.dataset.time
  95. this.setData({
  96. timeActive: timeActiveIndex
  97. })
  98. },
  99. // 激活卡片
  100. handleActiveCard () {
  101. wx.navigateTo({
  102. url: '/pages/scan/scan?form=appointment',
  103. })
  104. },
  105. // 去充值
  106. handleCharge () {},
  107. // 确定
  108. handleConfirm () {
  109. if (!this.data.hasAddress) {
  110. wx.showToast({
  111. title: '请选择地址',
  112. icon: 'error',
  113. mask: true
  114. })
  115. } else {
  116. var itt = this
  117. wx.showLoading({
  118. title: '预约中...'
  119. })
  120. setTimeout(() => {
  121. wx.hideLoading({
  122. success: (res) => {
  123. wx.showToast({
  124. title: '预约成功',
  125. })
  126. itt.setData({
  127. appointmentSuccess: true
  128. })
  129. }
  130. })
  131. }, 1200);
  132. }
  133. }
  134. })