serviceDetail.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. var check = require('../../../utils/check.js');
  4. var app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. orderId:'',
  11. serviceId:'',
  12. bookCount:0,
  13. orderStatusText:'订单服务中',
  14. activeTab:1,
  15. orderBook:{
  16. status:'',
  17. },
  18. jzOrderBookDetails:[],
  19. unusedSerList:[],
  20. usedSerList:[],
  21. serList:[],
  22. choosePopup:false,
  23. timeList:check.getTimeList(1),
  24. dateList:util.getDateList(new Date(new Date().getTime()+60*60*1000*24),1),
  25. timeIndex:0,//选中的时间段
  26. dateIndex:0,//选中的日期
  27. },
  28. /**
  29. * 生命周期函数--监听页面加载
  30. */
  31. onLoad: function (options) {
  32. this.setData({
  33. orderId: options.orderId
  34. });
  35. this.getServiceDetail();
  36. },
  37. getServiceDetail: function() {
  38. // wx.showLoading({
  39. // title: '加载中',
  40. // });
  41. // setTimeout(function() {
  42. // wx.hideLoading();
  43. // }, 2000);
  44. util.request(api.ServiceDetail, {
  45. order_id: this.data.orderId
  46. // order_id: '1342922'
  47. }).then(res=> {
  48. // wx.hideLoading();
  49. if (res.errno === 0) {
  50. let jzOrderBookDetails=res.data.jzOrderBookDetails;
  51. let unusedSerList=jzOrderBookDetails.filter(item=>{
  52. return item.status===0||item.status==1
  53. });
  54. let usedSerList=jzOrderBookDetails.filter(item=>{
  55. return item.status==3||item.status==4
  56. });
  57. let timeList=check.getTimeList(res.data.goods.serviceDuration);
  58. this.setData({
  59. goods:res.data.goods,
  60. orderBook:res.data.orderBook,
  61. jzOrderBookDetails:jzOrderBookDetails,
  62. activeTab:1,
  63. unusedSerList:unusedSerList,
  64. usedSerList:usedSerList,
  65. serList:unusedSerList,
  66. timeList:timeList
  67. });
  68. }
  69. });
  70. },
  71. onTabChange(e){
  72. this.setData({
  73. activeTab:e.detail.name,});
  74. if(this.data.activeTab==1){
  75. this.setData({
  76. serList:this.data.unusedSerList
  77. });
  78. }else{
  79. this.setData({
  80. serList:this.data.usedSerList
  81. })
  82. }
  83. },
  84. showAppoint(e){
  85. this.setData({
  86. choosePopup:true,
  87. serviceId:e.currentTarget.dataset.id
  88. });
  89. },
  90. onClose(){
  91. this.setData({
  92. choosePopup:false
  93. });
  94. },
  95. dateCheck(e){
  96. let index=e.currentTarget.dataset.index;
  97. this.setData({
  98. dateIndex:index
  99. });
  100. },
  101. timeCheck(e){
  102. let index=e.currentTarget.dataset.index;
  103. this.setData({
  104. timeIndex:index
  105. });
  106. },
  107. confirmTime(){
  108. let date=this.data.dateList[this.data.dateIndex].date;
  109. let week=this.data.dateList[this.data.dateIndex].week;
  110. let time=this.data.timeList[this.data.timeIndex].time;
  111. console.log(date,week,time);
  112. let params={
  113. detail_id:this.data.serviceId,
  114. date:date,
  115. startTime:time.split('-')[0],
  116. endTime:time.split('-')[1],
  117. };
  118. util.request(api.ServiceOrderBook, params, "GET")
  119. .then(res=> {
  120. console.log(res);
  121. if (res.errno == 0) {
  122. wx.showToast({
  123. title: '预约成功',
  124. icon: 'none',
  125. duration: 2000
  126. });
  127. this.setData({
  128. // oneTimeAppoint:date+' '+week+' '+time,
  129. choosePopup:false,
  130. });
  131. this.getServiceDetail();
  132. } else {
  133. util.showErrorToast(res.errmsg);
  134. }
  135. });
  136. },
  137. /**
  138. * 生命周期函数--监听页面初次渲染完成
  139. */
  140. onReady: function () {
  141. },
  142. /**
  143. * 生命周期函数--监听页面显示
  144. */
  145. onShow: function () {
  146. },
  147. /**
  148. * 生命周期函数--监听页面隐藏
  149. */
  150. onHide: function () {
  151. },
  152. /**
  153. * 生命周期函数--监听页面卸载
  154. */
  155. onUnload: function () {
  156. },
  157. /**
  158. * 页面相关事件处理函数--监听用户下拉动作
  159. */
  160. onPullDownRefresh: function () {
  161. },
  162. /**
  163. * 页面上拉触底事件的处理函数
  164. */
  165. onReachBottom: function () {
  166. },
  167. /**
  168. * 用户点击右上角分享
  169. */
  170. onShareAppMessage: function () {
  171. }
  172. })