From 9c70e8586b62a0230ade2c220c6ffafe084c8652 Mon Sep 17 00:00:00 2001 From: vguanyiwgd Date: Mon, 29 Apr 2024 16:04:43 +0800 Subject: [PATCH] =?UTF-8?q?theme=3D2=EF=BC=8C=E5=A2=9E=E5=8A=A0vip?= =?UTF-8?q?=E5=9B=B4=E9=A4=90=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I53231da8c8e7e58e6af4dba5ade98de7d7d284a3 --- .../api/controllers/api/Dishes.php | 66 ++++++++- .../application/api/controllers/api/Order.php | 45 ++++++ .../application/api/libraries/Common.php | 37 ++++- .../application/api/models/Cart_model.php | 21 ++- .../application/api/models/Common_model.php | 50 ++++++- .../application/api/models/Dishes_model.php | 5 + m/confirmOrder.html | 1 + m/css/main.css | 44 ++++++ m/index2.html | 4 + m/js/main.js | 137 +++++++++++++++++- 10 files changed, 395 insertions(+), 15 deletions(-) diff --git a/backstage/application/api/controllers/api/Dishes.php b/backstage/application/api/controllers/api/Dishes.php index 7461aeb..6e682c5 100644 --- a/backstage/application/api/controllers/api/Dishes.php +++ b/backstage/application/api/controllers/api/Dishes.php @@ -173,6 +173,7 @@ class Dishes extends REST_Controller $meal_date = $this->get_meal_date($meal_dates[$dining_hall_id], $date_id); } + $data['deliver_place_meal_list'] = $meal_date->deliver_place_list; $is_birth = $this->common->is_birth_date($user, $date_id); if($is_birth) { //生日餐 @@ -228,6 +229,9 @@ class Dishes extends REST_Controller $total = $this->common->get_cart_total_price($this->user, $type); $cart_total_price = $total['total_price']; $cart_total_num = $total['total_num']; + // 当前date_id的购物车,围餐房间号id + $cart_info = $this->common->get_cart_total_price($this->user, $type, $date_id); + $data['deliver_place_data'] = $cart_info['deliver_place_data']; $data['order'] = array('num' => $cart_total_num, 'price' => $cart_total_price, 'status' => $status); $data['dining_hall_id'] = $dining_hall_id; @@ -1041,6 +1045,7 @@ class Dishes extends REST_Controller $date_dishes_id = $this->input->post('date_dish_id'); $num = $this->input->post('num'); $date_dishes_ids = stripslashes($this->input->post('date_dish_ids')); + $deliver_place_id = intval($this->input->post('deliver_place_id')) ?: null; // 限制订餐时间 order/add 也有判断 $companyInfo = $this->Common_model->sql_get_one("select * from tb_company where id=".$this->user->company_id); @@ -1186,7 +1191,7 @@ class Dishes extends REST_Controller $type = $this->get_type($dishes_info->dish_type); //$date = $this->Common_model->get_date_by_date_id($dishes_info->date_id); - $result = $this->update_cart_single_dishes($dishes_info, $type, $v->num); + $result = $this->update_cart_single_dishes($dishes_info, $type, $v->num, $deliver_place_id); if ($result['status'] != 1) { $result['data'] = $data; $this->response($result, REST_Controller::HTTP_OK); @@ -1226,7 +1231,7 @@ class Dishes extends REST_Controller } } - private function update_cart_single_dishes($dishes_info, $type, $num) + private function update_cart_single_dishes($dishes_info, $type, $num, $deliver_place_id = '') { //print_r($dishes_info); $cart_dishes = $this->Cart_model->get_cart_dishes($this->user->id, $dishes_info->id); @@ -1241,11 +1246,26 @@ class Dishes extends REST_Controller } + // 围餐的判断: + if($deliver_place_id == ''){ + // 如果mealtype=6,且deliver_place_id=空,就返回错误 + $mealTypeInfo = $this->Common_model->sql_get_one("select c.mealtype from tb_date_dish a, tb_date b, tb_meal_type c where a.date_id=b.id and b.dc_type=c.id and a.id=".$dishes_info->id); + if ($mealTypeInfo['mealtype'] == 6) { + return array( + 'status' => 0, + 'message' => '请选择围餐房间', + ); + } + } + if (count($cart_dishes) > 0) { $cart_dishes = $cart_dishes[0]; if ($num > 0) { $t_data = array("id" => $cart_dishes->id, "uid" => $this->user->id, "date_dish_id" => $dishes_info->id, "num" => $num, "price" => $dish_price, "type" => $type, "expire_time" => time() + $cart_expire_time); + if($deliver_place_id != ''){ + $t_data['deliver_place_id'] = $deliver_place_id; + } $r = $this->Cart_model->replace_cart($t_data); if (!$r) { @@ -1266,7 +1286,9 @@ class Dishes extends REST_Controller } else if ($num > 0) { $t_data = array("uid" => $this->user->id, "date_dish_id" => $dishes_info->id, "num" => $num, "price" => $dish_price, "type" => $type, "expire_time" => time() + $cart_expire_time); - + if($deliver_place_id != ''){ + $t_data['deliver_place_id'] = $deliver_place_id; + } $r = $this->Cart_model->insert_cart($t_data); if ($r > 0) { // $cart_id = $r; @@ -1356,11 +1378,13 @@ class Dishes extends REST_Controller $date_text = $month . '月' . $day . '日' . '(周' . cnWeek($date) . ')'; $dc_type_info = $this->Common_model->get_meal_type_by_id($cd->dc_type); + $result[$cd->dining_hall_id]['data'][$cd->dc_date]['date_name'] = $date_text; $result[$cd->dining_hall_id]['data'][$cd->dc_date]['data'][$cd->dc_type]['type'] = $cd->type; $result[$cd->dining_hall_id]['data'][$cd->dc_date]['data'][$cd->dc_type]['date_id'] = $cd->date_id; $result[$cd->dining_hall_id]['data'][$cd->dc_date]['data'][$cd->dc_type]['meal_name'] = $dc_type_info->name; $result[$cd->dining_hall_id]['data'][$cd->dc_date]['data'][$cd->dc_type]['notes'] = $dc_type_info->notes; + $result[$cd->dining_hall_id]['data'][$cd->dc_date]['data'][$cd->dc_type]['mealtype'] = $dc_type_info->mealtype; $dishes = $this->Dishes_model->get_dishes_by_dishes_id($cd->dish_id); $cd->dish_name = $dishes->dish_name; $result[$cd->dining_hall_id]['data'][$cd->dc_date]['data'][$cd->dc_type]['data'][] = $cd; @@ -1385,6 +1409,20 @@ class Dishes extends REST_Controller foreach ($v2['data'] as &$v3) { // print_r($v3); + if($v3['mealtype'] == 6){ + $v3Data = json_decode(json_encode($v3['data']), 1); + // 围餐展示房间信息 + $cart_deliver_place_ids = array_column($v3Data, 'deliver_place_id'); + // 去重 + $cart_deliver_place_ids = array_unique($cart_deliver_place_ids); + if(count($cart_deliver_place_ids) == 1 && !empty($cart_deliver_place_ids[0])){ + $v3['deliver_place_id'] = $cart_deliver_place_ids[0]; + $v3['deliver_place_name'] = $this->Common_model->sql_get_one("select name from tb_order_deliver_place where enabled=1 and id=".$cart_deliver_place_ids[0])['name']; + }else{ + $v3['deliver_place_id'] = null; + $v3['deliver_place_name'] = null; + } + } $total = $this->common->get_cart_total_price($this->user, $v3['type'], $v3['date_id']); @@ -1713,4 +1751,26 @@ class Dishes extends REST_Controller ) ), REST_Controller::HTTP_OK); } + + public function updateCartDeliverPlaceId_post(){ + $user_id = $this->user->id; + $date_id = $this->input->post('date_id'); + $deliver_place_id = $this->input->post('deliver_place_id'); + + $res = $this->Cart_model->update_cart_by_uid_and_date_id($date_id, $user_id, $deliver_place_id); + if($res){ + $this->response(array( + 'status' => 1, + 'message' => 'ok', + 'data' => array() + ), REST_Controller::HTTP_OK); + + }else{ + $this->response(array( + 'status' => 0, + 'message' => '更新失败', + 'data' => array() + ), REST_Controller::HTTP_OK); + } + } } diff --git a/backstage/application/api/controllers/api/Order.php b/backstage/application/api/controllers/api/Order.php index bb81c36..067f57a 100644 --- a/backstage/application/api/controllers/api/Order.php +++ b/backstage/application/api/controllers/api/Order.php @@ -169,6 +169,44 @@ class Order extends REST_Controller } } + // 判断围餐,mealtype=6,deliver_place_id不能为空 + $dateInfo = $this->Dishes_model->get_date_info_by_date_id($k); + if($dateInfo['mealtype'] == 6){ + $date = $dateInfo['dc_date']; + $dc_type_name = $dateInfo['dc_type_name']; + foreach ($d as $cart_k => $cart_v) { + if(empty($cart_v->deliver_place_id)){ + // 找出$k(date_id)对应的日期和餐次 + $dateInfo = $this->Dishes_model->get_date_info_by_date_id($k); + + $this->response(array( + 'status' => 0, + 'message' => "请先选择【{$date} {$dc_type_name}】的围餐房间", + 'data' => $data + ), REST_Controller::HTTP_OK); + } + } + $deliver_place_ids = json_decode(json_encode($d), 1); + // 获取deliver_place_id + $deliver_place_ids = array_column($deliver_place_ids, 'deliver_place_id'); + $deliver_place_ids = array_unique($deliver_place_ids); + if(count($deliver_place_ids) != 1){ + $this->response(array( + 'status' => 0, + 'message' => "请先选择【{$date} {$dc_type_name}】的围餐房间。", + 'data' => $data + ), REST_Controller::HTTP_OK); + } + // 再判断当前date_id,deliver_place_id是否已经被占用 + $check_deliver_place_id = $this->Common_model->sql_get_one("select * from tb_order where date_id = {$k} and deliver_place_id = {$deliver_place_ids[0]} and state_id in (3,6)"); + if($check_deliver_place_id){ + $this->response(array( + 'status' => 0, + 'message' => "【{$date} {$dc_type_name}】的围餐房间已被占用,请重新选择。", + 'data' => $data + ), REST_Controller::HTTP_OK); + } + } } $this->load->model('User_model', '', TRUE); @@ -378,6 +416,13 @@ class Order extends REST_Controller // print_r($order); // exit; + // 设置围餐的信息 + $dateInfo = $this->Dishes_model->get_date_info_by_date_id($k); + if($dateInfo['mealtype'] == 6) { + // 获取房间号 + $order['deliver_place_id'] = $d[0]->deliver_place_id; + } + $t_total_price += $total['total_price']; $t_total_num += $total['total_num']; diff --git a/backstage/application/api/libraries/Common.php b/backstage/application/api/libraries/Common.php index 89849be..5c9bb2f 100644 --- a/backstage/application/api/libraries/Common.php +++ b/backstage/application/api/libraries/Common.php @@ -289,11 +289,19 @@ class Common $total_price = 0; $cart_dishes_sort = $this->sort_cart_dishes_by_date_id($cart_dishes); - + // 围餐房间id + $deliver_place_ids = []; foreach ($cart_dishes_sort as $k => $cd) { $fee = 0; $date = $this->_CI->Common_model->get_date_by_date_id($k); + if($date_id){ + foreach ($cd as $v) { + // 传了date_id,就是当前date_id的购物车内容 + $deliver_place_ids[] = $v->deliver_place_id; + } + } + if ($type == DISHES_TYPE_COMMON) { $fee = $this->get_fee($type, $date); } @@ -314,9 +322,31 @@ class Common $cart_total_num += $v->num; } } - $total_price += $fee; + $total_price += $fee; } - return array("total_price" => $total_price, "total_num" => $cart_total_num); + + if($date_id){ + // 去重,如果存在空值,或者数量不等于1,就不不返回,让它重新选择房间号,update房间号到tb_cart.deliver_place_id + $deliver_place_ids = array_unique($deliver_place_ids); + if(count($deliver_place_ids) == 1 && $deliver_place_ids[0] != '') { + $deliver_place_id = $deliver_place_ids[0]; + $deliver_place_name = $this->_CI->Common_model->sql_get_one("select * from tb_order_deliver_place where id = '{$deliver_place_id}' and enabled = 1"); + if($deliver_place_name){ + $deliver_place_data = $date_id."_".$deliver_place_id."_".$deliver_place_name['name']; + // 判断当前的围餐房间号是否被占用 + // 已被占用,再次遍历$cart_dishes_sort,将deliver_place_id置空 + $order_has_deliver_place_id = $this->_CI->Common_model->sql_get_one("select * from tb_order where date_id='{$date_id}' and deliver_place_id = '{$deliver_place_id}' and state_id in (3,6) "); + if($order_has_deliver_place_id){ + // 当前房间号已被占用 + $deliver_place_data = ''; + } + }else{ + $deliver_place_data = ''; + } + } + } + + return array("total_price" => $total_price, "total_num" => $cart_total_num, 'deliver_place_data' => $deliver_place_data); } else { return array("total_price" => 0, "total_num" => 0); } @@ -507,7 +537,6 @@ class Common if ($order) { $orderid = $order->id; $order_detail = $this->_CI->Order_model->get_order_detail_by_order_id($orderid, base_url(), ''); - $take_code = $order->take_food_code; //$take_qrcode = base_url($order->qrcode_path); diff --git a/backstage/application/api/models/Cart_model.php b/backstage/application/api/models/Cart_model.php index ae97e38..559e528 100644 --- a/backstage/application/api/models/Cart_model.php +++ b/backstage/application/api/models/Cart_model.php @@ -50,9 +50,9 @@ class Cart_model extends CI_Model if ($cart_id != 0) { $where .= " and a.id = {$cart_id}"; } - $query = $this->db->query("select a.*, b.date_id, b.dish_id, c.dining_hall_id, c.dc_type, d.dish_type, c.dc_date, b.max_num, b.total_max_num, b.book_num - from tb_cart a, tb_date_dish b, tb_date c, tb_dish d - where a.date_dish_id = b.id and b.date_id = c.id and b.dish_id = d.id and a.uid = {$uid} {$where} and d.enabled = 1 order by c.dc_date asc, c.dc_type asc"); + $query = $this->db->query("select a.*, b.date_id, b.dish_id, c.dining_hall_id, c.dc_type, d.dish_type, c.dc_date, b.max_num, b.total_max_num, b.book_num, e.mealtype + from tb_cart a, tb_date_dish b, tb_date c, tb_dish d, tb_meal_type e + where a.date_dish_id = b.id and b.date_id = c.id and b.dish_id = d.id and c.dc_type=e.id and a.uid = {$uid} {$where} and d.enabled = 1 order by c.dc_date asc, c.dc_type asc"); return $query->result(); } @@ -160,4 +160,19 @@ class Cart_model extends CI_Model $query = $this->db->query("select sum(price*num) total_price from tb_shopping_cart a where uid = {$uid} {$where}"); return $query->row(); } + + public function update_cart_by_uid_and_date_id($date_id, $uid, $deliver_place_id){ +// $this->db->where_in('date_dish_id', $this->db->select('id')->get_where('tb_date_dish', array('date_id' => $date_id))->result_array()); +// $this->db->set('deliver_place_id', $deliver_place_id); +// $this->db->where('uid', $uid); +// return $this->db->update('tb_cart'); + + $date_dish_ids = $this->db->select('id')->get_where('tb_date_dish', ['date_id' => $date_id])->result_array(); + $date_dish_ids = array_column($date_dish_ids, 'id'); + + return $this->db->where_in('date_dish_id', $date_dish_ids) + ->where('uid', $uid) + ->set('deliver_place_id', $deliver_place_id) + ->update('tb_cart'); + } } \ No newline at end of file diff --git a/backstage/application/api/models/Common_model.php b/backstage/application/api/models/Common_model.php index ec90304..81a4788 100644 --- a/backstage/application/api/models/Common_model.php +++ b/backstage/application/api/models/Common_model.php @@ -138,13 +138,17 @@ class Common_model extends CI_Model } $where = str_replace('for_dc_type', 'dc_type', $where); - $sql = "SELECT a.* from tb_date a, tb_meal_type c where a.dc_type = c.id and dc_date >= '".date("Y-m-d")."' {$where} order by a.dc_date asc, c.idx desc, a.dc_type asc"; + $sql = "SELECT a.*, c.mealtype from tb_date a, tb_meal_type c where a.dc_type = c.id and dc_date >= '".date("Y-m-d")."' {$where} order by a.dc_date asc, c.idx desc, a.dc_type asc"; $dates = $this->db->query($sql)->result(); + // 获取vip围餐所有的房间号 + $deliver_place_list = $this->db->query("select * from tb_order_deliver_place where enabled=1 and dining_hall_id='".$user->dining_hall_id."'")->result_array(); + $deliver_place_ids = array_column($deliver_place_list, "id"); + $dates2 = array(); $nowtime = time(); - foreach($dates as $item) { + foreach($dates as $index => $item) { $dc_type = $item->dc_type; $dc_date = $item->dc_date; $rule = $rulesInfo[$dc_type]; @@ -154,6 +158,48 @@ class Common_model extends CI_Model $time1 = $dc_date." ".$rule['time']; + // vip围餐修改,如果是围餐类型 且 用户积分账户余额==0,则不显示 (vip围餐:tb_meal_type.mealtype=6) + if($item->mealtype == 6){ + if(!isset($user->jf) || $user->jf <=0){ + // 没有积分账户,或者账户积分<=0,则不能订vip围餐 + continue; + } + // 查找当前date_id 可预定的房间列表 + $date_id = $item->id; + // 所有房间列表的id,用,分隔的字符串 + $deliver_place_ids_str = join(",", $deliver_place_ids); + // 所有房间列表的占用情况情况 + $deliver_place_arr = array(); + // 获取当前date_id 已经被占用的房间列表 + $get_deliver_place_list = array(); + if(!empty($deliver_place_ids_str)){ + $get_deliver_place_list = $this->db->query("select * from tb_order where date_id='{$date_id}' and state_id in (3,6) and deliver_place_id in ({$deliver_place_ids_str})")->result_array(); + } + // 如果含有已经被占用的房间,则判断房间是否已经被占用 +// if(!empty($get_deliver_place_list)){ +// foreach ($get_deliver_place_list as $deliver_place_item){ +// $is_occupy = in_array($deliver_place_item['deliver_place_id'], $deliver_place_ids) ? 1 : 0; +// $deliver_place_arr[] = array( +// 'id' => $deliver_place_item['deliver_place_id'], +// 'name' => $deliver_place_item['deliver_place_name'], +// 'is_occupy' => $is_occupy // 是否占用 +// ); +// } +// }else{ + // 如果没有被占用的房间,则显示所有房间且设置未占用 + foreach ($deliver_place_list as $deliver_place_item){ + $get_deliver_place_ids = array_column($get_deliver_place_list, "deliver_place_id"); + $is_occupy = in_array($deliver_place_item['id'], $get_deliver_place_ids) ? 1 : 0; + $deliver_place_arr[] = array( + 'id' => $deliver_place_item['id'], + 'name' => $deliver_place_item['name'], + 'is_occupy' => $is_occupy // 是否占用 + ); + } +// } + $item->deliver_place_list = $deliver_place_arr; + } + if(strtotime($time1) - $relative_day*86400 > $nowtime) { $dates2[] = $item; } diff --git a/backstage/application/api/models/Dishes_model.php b/backstage/application/api/models/Dishes_model.php index 671318c..7814ac4 100644 --- a/backstage/application/api/models/Dishes_model.php +++ b/backstage/application/api/models/Dishes_model.php @@ -296,4 +296,9 @@ class Dishes_model extends CI_Model return true; } + public function get_date_info_by_date_id($date_id) + { + $query = $this->db->query("select a.*, b.name as dc_type_name, b.mealtype from tb_date a,tb_meal_type b where a.dc_type=b.id and a.id = {$date_id}"); + return $query->row_array(); + } } \ No newline at end of file diff --git a/m/confirmOrder.html b/m/confirmOrder.html index 563ccfe..0c7f137 100644 --- a/m/confirmOrder.html +++ b/m/confirmOrder.html @@ -8,6 +8,7 @@ + diff --git a/m/css/main.css b/m/css/main.css index 4214af2..b19fb83 100644 --- a/m/css/main.css +++ b/m/css/main.css @@ -5653,3 +5653,47 @@ input[name='custom_recharge'].custom_recharge { font-size: 0.65rem; display: none; } + +/*vip围餐样式*/ +.popup-deliver-place{ + width: 90%; + margin: 5%; + height: auto; + border-radius: 0.5rem; +} +.deliver-place-close{ + position: absolute; + right: 0.6rem; + top: -0.3rem; + font-size: 1.2rem; + color: #000; + margin: 0; +} + +.deliver-place-close a{ + color: #ef4437; +} +.flex-row{ + flex-direction: row; +} +.flex-wrap{ + flex-wrap: wrap; +} +.deliver-place-bg-btn-color{ + background-color: #f6f6f6; + color: #000; + border: 2px solid #fff; + font-size: 0.65rem; +} +.deliver-place-bg-btn-color.active{ + border: 2px solid #ef4437; + color: #ef4437; +} +.deliver-place-bg-btn-color.disabled{ + background-color: #f6f6f6; + color: #ccc; + border: 2px solid #f6f6f6; +} +.py-3{padding-top:0.75rem;padding-bottom:0.75rem;} +.font-bold{font-weight: bold;} +.pr-2{padding-right: 0.5rem;} \ No newline at end of file diff --git a/m/index2.html b/m/index2.html index 95ca1e3..1419ad8 100644 --- a/m/index2.html +++ b/m/index2.html @@ -63,6 +63,10 @@ + + + +
diff --git a/m/js/main.js b/m/js/main.js index 86e53ac..a11dee5 100644 --- a/m/js/main.js +++ b/m/js/main.js @@ -7525,6 +7525,20 @@ $(function () { //$('.panel-footer .shop-fl').show(); } + // 如果是vip围餐的date_id,而且 deliver_place_meal_list 非空,就弹窗选房间 + if(data.deliver_place_meal_list){ + $("#deliver-place").val(JSON.stringify(data.deliver_place_meal_list)); + if(data.deliver_place_data){ + $("#deliver-place-data").val(data.deliver_place_data); + }else{ + $("#deliver-place-data").val(""); + popup_deliver_place(data.deliver_place_meal_list); + } + }else{ + $("#deliver-place-data").val(""); + $("#deliver-place").val(""); + } + /* if(data.user.show_fuli === 1){ $('.panel-footer .shop-fl').show(); @@ -7802,6 +7816,13 @@ $(function () { //初始化待阅通知数 $('#page-index2 .cp').html(cp_li); + + // 判断当前是不是围餐 + if(data.deliver_place_meal_list){ + $('#page-index2 .cp').append( + '
  • 围餐房间
  • ' + ); + } $('#page-index2 .ftpic').attr('id', 'ft' + data.dining_hall_id); $('.noticeList num').html( @@ -7812,7 +7833,40 @@ $(function () { dining_halls = data.dining_halls; } - function printReload(self, num, limit, price, type) { + // 弹窗选择房间 + function popup_deliver_place(data, type = 'init'){ + // 判断当前的date_id 是否一样,如果一样就不重新渲染弹窗 + var input_deliver_place_data_val = $("#deliver-place-data").val(); + var input_date_id = input_deliver_place_data_val.split("_")[0]; + var input_deliver_place_id = input_deliver_place_data_val.split("_")[1]; + if(type != 'init' || (input_deliver_place_data_val == '' || input_date_id != date_id)){ + // 弹窗选择房间 + var place_list = ``; + // console.log(place_list) + $.popup(place_list); + + } + + } + function printReload(self, num, limit, price, type) { var thisCpNum = $('.cp .active .badge').html() ? parseInt($('.cp .active .badge').html()) : 0; @@ -8157,6 +8211,52 @@ $(function () { .on('click', '.changeFt', function () { $(page).find('input[name=changeFt]').select('open'); }); + $(document) + .off('click', '.deliverPlace') + .on('click', '.deliverPlace', function () { + var data = $("#deliver-place").val(); + data = JSON.parse(data); + popup_deliver_place(data, ""); + }); + + $(document) + .off('click', '.popup-deliver-place .vip-room') + .on('click', '.popup-deliver-place .vip-room', function () { + if($(this).hasClass("disabled")){ + return; + } + // 给选中的房间添加样式 + var deliver_place_id = $(this).data('id'); + var vip_meal_name = $(this).text(); + + // 异步,把deliver_place_id传到后台,保存到tb_cart的菜品里 + $.ajax({ + type: 'POST', + url: '../api/dishes/updateCartDeliverPlaceId/', + dataType: 'json', + data: { + date_id: date_id, + deliver_place_id: deliver_place_id, + token: user.token, + }, + success: function (ret) { + if (typeof ret.status !== 'undefined') { + if (ret.status === 1) { + $(".popup-deliver-place .vip-room").removeClass("active"); + $(this).addClass('active'); + $("#deliver-place-data").val(date_id+"_"+deliver_place_id+"_"+vip_meal_name); + $.closeModal(".popup-deliver-place"); + }else{ + $.alert(ret.message); + } + } + }, + error: function () { + $.alert('请检查网络!'); + }, + }); + + }); $('.app-qrcode') .off('click') @@ -8258,7 +8358,15 @@ $(function () { num = printReload(self, num, limit, price, type); //cookie不存在 var token = user.token; + // 获取围餐房间号 + var deliver_place_data = $("#deliver-place-data").val(); + var deliver_place_id = null; + if(deliver_place_data){ + // 获取房间号id + console.log(deliver_place_data) + deliver_place_id = deliver_place_data.split("_")[1]; + } $.ajax({ type: 'POST', url: '../api/dishes/add/', @@ -8267,6 +8375,7 @@ $(function () { token: token, date_dish_id: cid, num: num, + deliver_place_id: deliver_place_id }, success: function (ret) { if (typeof ret.status !== 'undefined') { @@ -10329,6 +10438,11 @@ $(function () { '&pid=' + ft.dining_hall_id + '" data-no-cache="true">增加
    '; + + var deliver_place_html = ""; + if(meal.mealtype == 6){ + deliver_place_html = "data-deliver_place_id='"+meal.deliver_place_id+"'"; + } $.each(meal.data, function (i, cs) { cartHtml += '
  • ' + + '" '+deliver_place_html+'>' + cs.num + '

  • '; }); @@ -10357,10 +10471,17 @@ $(function () { meal.rise_info.rise_tip + '

    '; } + if(typeof meal.deliver_place_name !== 'undefined'){ + console.log(meal) + var deliver_place_name = meal.deliver_place_name ? ""+meal.deliver_place_name+"" : "请先选择围餐房间号再下单"; + cartHtml += + '
  • 围餐房间:'+deliver_place_name+'

  • '; + } + if(meal.notes){ var notes = JSON.parse(meal.notes); cartHtml += - '
  • 备注:

  • '; } @@ -10390,6 +10511,8 @@ $(function () { setTimeout(function () { $.showIndicator(); }, 0); + + var token = user.token; $.ajax({ type: 'GET', @@ -10482,6 +10605,13 @@ $(function () { var limit = parseInt(self.parent('p').data('limit')); var cid = parseInt(self.parent('p').data('id')); + + // 判断是否有deliver_place_id + var deliver_place_id = null; + if(self.parent('p').data('deliver_place_id')){ + deliver_place_id = self.parent('p').data('deliver_place_id'); + } + var type = self.data('type'); if (type === 'add') { if (num >= limit) { @@ -10504,6 +10634,7 @@ $(function () { token: token, date_dish_id: cid, num: num, + deliver_place_id: deliver_place_id, }, success: function (ret) { if (typeof ret.status !== 'undefined') {