scheduleCalc.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. const app = getApp()
  2. const util = require("../../../utils/util");
  3. const api = require('../../../api/api.js');
  4. const user = require('../../../utils/user.js');
  5. // const update = require('../../../api/update.js');
  6. Page({
  7. data: {
  8. firstDate:'请选择',
  9. serviceTimes:'请选择',
  10. serviceFrequency:'请选择',
  11. currentDate:new Date().getTime(),
  12. showPicker:false,
  13. datePicker:false,
  14. columns:[],
  15. serviceTimesCol:['4','24'],
  16. serviceFrequencyCol:['一周一次','两周一次'],
  17. scheduleData:{
  18. mastUseCount:'',
  19. otherUseCount:'',
  20. unUseCount:'',
  21. monthData:[],
  22. },
  23. scheduleList:[
  24. {
  25. month:'2022年10月',
  26. amount:'2',
  27. list:[
  28. {
  29. date:'14日',
  30. tips:'我有档期'
  31. },
  32. {
  33. date:'21日',
  34. tips:'我有档期'
  35. }
  36. ]
  37. },
  38. {
  39. month:'2022年11月',
  40. amount:'4',
  41. list:[
  42. {
  43. date:'1日',
  44. tips:'我有档期'
  45. },
  46. {
  47. date:'7日',
  48. tips:'我有档期'
  49. },
  50. {
  51. date:'14日',
  52. tips:'其他姐妹'
  53. },
  54. {
  55. date:'21日',
  56. tips:'无档期'
  57. }
  58. ]
  59. },
  60. {
  61. month:'2022年12月',
  62. amount:'4',
  63. list:[
  64. {
  65. date:'1日',
  66. tips:'我有档期'
  67. },
  68. {
  69. date:'7日',
  70. tips:'我有档期'
  71. },
  72. {
  73. date:'14日',
  74. tips:'其他姐妹'
  75. },
  76. {
  77. date:'21日',
  78. tips:'无档期'
  79. }
  80. ]
  81. }
  82. ]
  83. },
  84. /**
  85. * 生命周期函数--监听页面加载
  86. */
  87. onLoad: function (options) {
  88. },
  89. selectTimes(){
  90. },
  91. onDateInput(e){
  92. console.log(e);
  93. this.setData({
  94. currentDate:e.detail
  95. });
  96. },
  97. dateSelect(){
  98. this.setData({
  99. showPicker:true,
  100. datePicker:true
  101. })
  102. }
  103. ,
  104. dateCancel(){
  105. this.setData({
  106. showPicker:false
  107. })
  108. },
  109. dateConfirm(){
  110. this.setData({
  111. firstDate:util.formetdate(new Date(this.data.currentDate)),
  112. showPicker:false
  113. })
  114. },
  115. serviceTimesTap(){
  116. this.setData({
  117. showPicker:true,
  118. datePicker:false,
  119. columns:this.data.serviceTimesCol
  120. });
  121. },
  122. frequencySelect(){
  123. this.setData({
  124. showPicker:true,
  125. datePicker:false,
  126. columns:this.data.serviceFrequencyCol
  127. })
  128. },
  129. pickerCancel(){
  130. this.setData({
  131. showPicker:false,
  132. })
  133. },
  134. pickerConfirm(e){
  135. console.log(e);
  136. if(this.data.columns==this.data.serviceTimesCol){
  137. this.setData({
  138. serviceTimes:e.detail.value,
  139. showPicker:false,
  140. });
  141. }else{
  142. this.setData({
  143. serviceFrequency:e.detail.value,
  144. showPicker:false
  145. })
  146. }
  147. },
  148. caclSchedule(){
  149. if(this.data.serviceTimes=='请选择'){
  150. wx.showToast({
  151. title: '请选择服务次数',
  152. icon: 'none'
  153. });
  154. return false;
  155. }else if(this.data.firstDate=='请选择'){
  156. wx.showToast({
  157. title: '请选择首次时间',
  158. icon: 'none'
  159. });
  160. return false;
  161. }else if(this.data.serviceFrequency=='请选择'){
  162. wx.showToast({
  163. title: '请选择服务频率',
  164. icon: 'none'
  165. });
  166. return false;
  167. }else{
  168. wx.showLoading({
  169. title: '加载中...',
  170. });
  171. util.request(api.computerWorkerSchedule, {
  172. firstDate: this.data.firstDate,
  173. serviceTimes:this.data.serviceTimes,
  174. pinlv:this.data.serviceFrequency=='一周一次'?'7':'14'
  175. }, 'GET').then(res=> {
  176. wx.hideLoading();
  177. if (res.errno === 0) {
  178. console.log(res);
  179. this.setData({
  180. scheduleData:res.data
  181. });
  182. }
  183. }).catch(err=>{
  184. wx.hideLoading();
  185. });
  186. }
  187. },
  188. onReachBottom() {
  189. // if (this.data.totalPages > this.data.page) {
  190. // this.setData({
  191. // page: this.data.page + 1
  192. // });
  193. // this.getGoodsList();
  194. // } else {
  195. // wx.showToast({
  196. // title: '没有更多商品了',
  197. // icon: 'none',
  198. // duration: 2000
  199. // });
  200. // return false;
  201. // }
  202. },
  203. /**
  204. * 生命周期函数--监听页面初次渲染完成
  205. */
  206. onReady: function () {
  207. },
  208. /**
  209. * 生命周期函数--监听页面显示
  210. */
  211. onShow: function () {
  212. },
  213. onHide: function () {
  214. },
  215. onUnload: function () {
  216. },
  217. /**
  218. * 页面相关事件处理函数--监听用户下拉动作
  219. */
  220. onPullDownRefresh: function () {
  221. },
  222. /**
  223. * 页面上拉触底事件的处理函数
  224. */
  225. onReachBottom: function () {
  226. },
  227. /**
  228. * 用户点击右上角分享
  229. */
  230. onShareAppMessage: function () {
  231. },
  232. })