From 3629bfd3292ff5892b3235e58ffe75209e4d3396 Mon Sep 17 00:00:00 2001 From: yvan.ni <765199919@qq.com> Date: Wed, 9 Dec 2020 16:03:39 +0800 Subject: [PATCH] 小程序预约代码 --- pages/user/my_service/appment_main.js | 21 +++++++++++++-------- pages/user/my_service/appment_main.wxml | 2 +- pages/user/my_service/beauty_deta.js | 42 +++++++++++++++++++++++++++++------------- pages/user/my_service/cosmetology_list.js | 21 ++++++++++++++------- pages/user/my_service/cosmetology_list.wxml | 4 ++-- 5 files changed, 59 insertions(+), 31 deletions(-) diff --git a/pages/user/my_service/appment_main.js b/pages/user/my_service/appment_main.js index a0c4050..e1292ac 100644 --- a/pages/user/my_service/appment_main.js +++ b/pages/user/my_service/appment_main.js @@ -368,11 +368,12 @@ Page({ is_textea: 0 }) var itemId = th.data.itemId; //服务id - var url = "/api/weshop/marketing/reservation/storage/page"; + var url = "/api/weshop/marketing/reservation/storage/pagenew"; var key_word = th.data.key_word; key_word = key_word.replace(/\s+/g, ""); getApp().request.promiseGet(url, { data: { + userId:getApp().globalData.user_id, storeId: a.stoid, serviceId: itemId, latitude: th.data.lat, @@ -422,8 +423,9 @@ Page({ }) var itemid = th.data.itemId; //正式使用的项目id var storageId = th.data.storageId; //正式使用的线下门店id - var url = "/api/weshop/marketing/reservation/staff/page"; //接口地址 - getApp().request.promiseGet(url, { + var url = "/api/weshop/marketing/reservation/staff/pagenew"; //接口地址 + + getApp().request.promiseGet(url, { data: { storeId: a.stoid, userId: d.user_id, @@ -434,9 +436,9 @@ Page({ wx.hideLoading(); if (res.data.code == 0) { th.setData({ - beautician_list: res.data.data.pageData + beautician_list: res.data.data }) - if (res.data.data.pageData.length < 1) { + if (res.data.data.length < 1) { getApp().my_warnning("暂无美容师", 0, th); th.settime(); } else { @@ -461,7 +463,9 @@ Page({ var th = this; var bea_index = e.currentTarget.dataset.baaindex; var bea_name = th.data.beautician_list[bea_index].StaffName; - var BeauticianID = th.data.beautician_list[bea_index].Id; + var BeauticianID = th.data.beautician_list[bea_index].staffid; + var StorageId=th.data.beautician_list[bea_index].StorageId + th.setData({ beautician_name: bea_name, beautician: 0, @@ -469,7 +473,8 @@ Page({ beauticianID: BeauticianID, time: "", tment_count: "", - is_textea: 1 + is_textea: 1, + StorageId:StorageId }) }, @@ -559,7 +564,7 @@ Page({ //查询剩下可预约人数 query_more: function() { var th = this; - var url = "/api/weshop/marketing/reservation/can/reservation/count"; + var url = "/api/weshop/marketing/reservation/can/reservation/countnew"; var beauticianID = th.data.beauticianID; //美容师id var projectID = th.data.itemId; //服务id var seekTime = th.data.time; //预约日期 diff --git a/pages/user/my_service/appment_main.wxml b/pages/user/my_service/appment_main.wxml index 8c16bd2..788e683 100644 --- a/pages/user/my_service/appment_main.wxml +++ b/pages/user/my_service/appment_main.wxml @@ -55,7 +55,7 @@ - + {{time==""?'选择时间':time}} diff --git a/pages/user/my_service/beauty_deta.js b/pages/user/my_service/beauty_deta.js index b9d08e7..198743f 100644 --- a/pages/user/my_service/beauty_deta.js +++ b/pages/user/my_service/beauty_deta.js @@ -19,7 +19,7 @@ Page({ comment: "", //美容师评价 aweeks: [], //七天的预约时间 head_img: "", //美容师头像 - time: ["08:00", "09:00", "10:00", "11:00", "12:00", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "19:00", "20:00", "21:00", "22:00"], + time:['08:00','08:30', '09:00', '09:30', '10:00', '10:30', '11:00', '11:30', '12:00', '12:30', '13:00', '13:30', '14:00','14:30', '15:00', '15:30', '16:00', '16:30', '17:00','17:30', '18:00','18:30', '19:00', '19:30', '20:00', '20:30', '21:00', '21:30', '22:00','22:30'], weeks: [], //星期几数组 time_index: -1, //选择预约时间下标 date_id: 0, //选择日期的id @@ -42,12 +42,16 @@ Page({ var minutes = myDate.getMinutes(); //获取当前分钟数(0-59) var hours = myDate.getHours() + ":" + minutes; //获取当前小时数(0-23) var beautician_id = options.BeauticianID; + var storageId = options.StorageId; + + th.setData({ beautician_id: beautician_id, itemId: options.itemId, modify: options.modify, hours: hours, - projectId: options.projectId + projectId: options.projectId, + storageId:storageId }) if (options.url != undefined) { th.setData({ @@ -226,15 +230,18 @@ Page({ query_aweek: function() { var th = this; var beautician_id = th.data.beautician_id; //美容师id + var storageId=th.data.storageId; + var itemId = th.data.itemId; //服务id var projectId = th.data.projectId; //项目id - var url = "/api/weshop/marketing/reservation/staff/seven/time/list"; //接口地址 + var url = "/api/weshop/marketing/reservation/staff/seven/time/listnew"; //接口地址 getApp().request.promiseGet(url, { data: { projectId: projectId, beauticianId: beautician_id, serviceId: itemId, storeId: a.stoid, + storageId:storageId } }).then(res => { if (res.data.code == 0) { @@ -281,11 +288,12 @@ Page({ var SeekTime = th.data.aweeks[date_id].time; var val = th.data.aweeks[date_id].val; - var url = "/api/weshop/marketing/reservation/staff/time/list"; + var url = "/api/weshop/marketing/reservation/staff/time/listnew"; getApp().request.promiseGet(url, { data: { projectId: projectId, - beauticianId: th.data.beautician_id, + staffId: th.data.beautician_id, + storageId:th.data.storageId, serviceId: th.data.itemId, seekTime: SeekTime, storeId: a.stoid, @@ -302,7 +310,7 @@ Page({ //不等于空就是有可以预约的时间 if (time_list != null) { if (res.data.data[0].GroupHour != undefined) { - if (res.data.data[0].GroupHour.length > 11) { + if (res.data.data[0].GroupHour && res.data.data[0].GroupHour.length > 11) { getApp().my_warnning(res.data.data[0].GroupHour, 0, th); } } @@ -310,17 +318,15 @@ Page({ for (var i = 0; i < time.length; i++) { for (var ii = 0; ii < time_list.length; ii++) { //判断固定的时间和可以预约的时间 - if (time[i] == time_list[ii].GroupHour.substring(0, 5)) { + if (time[i] == time_list[ii].begintime.substring(0, 5)) { var date_id = th.data.date_id; - if (date > time_list[ii].GroupHour.substring(0, 2) && date_id == 0) { + if (date > time_list[ii].begintime.substring(0, 2) && date_id == 0) { new_time[i] = ""; break; - } else { - new_time[i] = time_list[ii].GroupHour.substring(0, 5); + }else{ + new_time[i] = time_list[ii].begintime.substring(0, 5); break; } - - } else { new_time[i] = ""; } @@ -393,7 +399,17 @@ Page({ return 1; } return 0; - } + }, + + check_is_in_arr:function(val,pdata) { + if(!val || !pdata) return false; + for(var i in pdata){ + if(pdata[i].begintime.indexOf(val)!=-1){ + return true; + } + } + return false; + } diff --git a/pages/user/my_service/cosmetology_list.js b/pages/user/my_service/cosmetology_list.js index 6147a7e..5d71119 100644 --- a/pages/user/my_service/cosmetology_list.js +++ b/pages/user/my_service/cosmetology_list.js @@ -32,7 +32,7 @@ Page({ }, query_cology: function() { var th = this; - var url = "/api/weshop/marketing/reservation/staff/page"; + var url = "/api/weshop/marketing/reservation/staff/pagenew"; var itemId = th.data.itemId; //服务id var storageId = th.data.storageId; getApp().request.promiseGet(url, { @@ -49,20 +49,20 @@ Page({ if (res.data.code == 0) { th.data.curpage++; var arr1 = th.data.cosmetology_list; - var arr2 = res.data.data.pageData; + var arr2 = res.data.data; var arr3 = [...arr1, ...arr2]; - var ismore = 0; - if (arr3.length == res.data.data.total) ismore = 1 + + th.setData({ cosmetology_list: arr3, - total: res.data.data.total, - ismore: ismore, + total: res.data.data.total, is_service_read: 1, is_cosmetology_read:1 }), wx.stopPullDownRefresh(); //停止下拉刷新 } else { th.setData({ - is_cosmetology_read:1 + is_cosmetology_read:1, + ismore:1 }) } }) @@ -95,6 +95,13 @@ Page({ */ onShow: function() { var th = this; + th.data.curpage++; + th.setData({ + cosmetology_list: [], + total: 0, + is_service_read: 0, + is_cosmetology_read:0 + }) th.query_cology(); }, diff --git a/pages/user/my_service/cosmetology_list.wxml b/pages/user/my_service/cosmetology_list.wxml index 02f99a7..66049b0 100644 --- a/pages/user/my_service/cosmetology_list.wxml +++ b/pages/user/my_service/cosmetology_list.wxml @@ -8,7 +8,7 @@ - + {{item.StaffName}} @@ -27,7 +27,7 @@ - + 预约 -- libgit2 0.21.4