123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- var util = require('../../../utils/util.js');
- var api = require('../../../config/api.js');
- var check = require('../../../utils/check.js');
- var app = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- orderId:'',
- serviceId:'',
- bookCount:0,
- orderStatusText:'订单服务中',
- activeTab:1,
- orderBook:{
- status:'',
- },
- jzOrderBookDetails:[],
- unusedSerList:[],
- usedSerList:[],
- serList:[],
- choosePopup:false,
- timeList:check.getTimeList(1),
- dateList:util.getDateList(new Date(new Date().getTime()+60*60*1000*24),1),
- timeIndex:0,//选中的时间段
- dateIndex:0,//选中的日期
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- orderId: options.orderId
- });
- this.getServiceDetail();
- },
- getServiceDetail: function() {
- // wx.showLoading({
- // title: '加载中',
- // });
- // setTimeout(function() {
- // wx.hideLoading();
- // }, 2000);
- util.request(api.ServiceDetail, {
- order_id: this.data.orderId
- // order_id: '1342922'
- }).then(res=> {
- // wx.hideLoading();
- if (res.errno === 0) {
- let jzOrderBookDetails=res.data.jzOrderBookDetails;
- let unusedSerList=jzOrderBookDetails.filter(item=>{
- return item.status===0||item.status==1
- });
- let usedSerList=jzOrderBookDetails.filter(item=>{
- return item.status==3||item.status==4
- });
- let timeList=check.getTimeList(res.data.goods.serviceDuration);
- this.setData({
- goods:res.data.goods,
- orderBook:res.data.orderBook,
- jzOrderBookDetails:jzOrderBookDetails,
- activeTab:1,
- unusedSerList:unusedSerList,
- usedSerList:usedSerList,
- serList:unusedSerList,
- timeList:timeList
- });
- }
-
- });
- },
- onTabChange(e){
-
- this.setData({
- activeTab:e.detail.name,});
- if(this.data.activeTab==1){
- this.setData({
- serList:this.data.unusedSerList
- });
-
- }else{
- this.setData({
- serList:this.data.usedSerList
- })
- }
- },
- showAppoint(e){
- this.setData({
- choosePopup:true,
- serviceId:e.currentTarget.dataset.id
- });
- },
- onClose(){
- this.setData({
- choosePopup:false
- });
- },
- dateCheck(e){
- let index=e.currentTarget.dataset.index;
- this.setData({
- dateIndex:index
- });
- },
- timeCheck(e){
- let index=e.currentTarget.dataset.index;
- this.setData({
- timeIndex:index
- });
- },
- confirmTime(){
- let date=this.data.dateList[this.data.dateIndex].date;
- let week=this.data.dateList[this.data.dateIndex].week;
- let time=this.data.timeList[this.data.timeIndex].time;
- console.log(date,week,time);
-
- let params={
- detail_id:this.data.serviceId,
- date:date,
- startTime:time.split('-')[0],
- endTime:time.split('-')[1],
-
- };
- util.request(api.ServiceOrderBook, params, "GET")
- .then(res=> {
- console.log(res);
- if (res.errno == 0) {
- wx.showToast({
- title: '预约成功',
- icon: 'none',
- duration: 2000
- });
- this.setData({
- // oneTimeAppoint:date+' '+week+' '+time,
- choosePopup:false,
- });
- this.getServiceDetail();
- } else {
- util.showErrorToast(res.errmsg);
- }
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|