Przeglądaj źródła

餐厅和域名修改

WinG 2 lat temu
rodzic
commit
2940fb40c3

+ 2 - 1
app.json

@@ -28,7 +28,8 @@
     "pages/activity/redpacket/redpacket",
     "pages/activity/screen/screen",
 	"pages/canteen/canteen",
-	"pages/canteen/order/order"
+	"pages/canteen/order/order",
+	"pages/canteen/dining/dining"
   ],
   "subpackages": [
     {

BIN
images/footer/dining.png


+ 87 - 54
pages/canteen/canteen.js

@@ -8,14 +8,16 @@ Page({
 	cancelnum:1,
 	canceldata:{},
 	cancelitem:{},
-	oncancel:false
+	oncancel:false,
+	mealInfo:{}
   },
   onShow:function(){
 	  console.log('onshow == canteen')
 	  this.setData({
 	    detail: {}
 	  })
-	  this.getList()
+	  this.getList();
+	  this.getMealInfo();
   },
  //  onLoad: function (options) {
 	  
@@ -55,6 +57,20 @@ Page({
     }
     _request.$get(url, params, success)
   },
+  getMealInfo () {
+    var that = this
+    var url = 'newapi:food/get-meal-info'
+    var params = {
+    }
+    var success = function (res) {
+      var data = res.data.data
+      console.log('mealinfo',data);
+      that.setData({
+      	mealInfo: data
+      })
+    }
+    _request.$get(url, params, success)
+  },
   showCancelm(e){
 	  var that = this
 	  var selectdata = e.currentTarget.dataset.data;
@@ -193,60 +209,72 @@ Page({
 	    onlyFromCamera: true,
 	    success (res) {
 			if(res.errMsg == "scanCode:ok"){
-				let link = res.result.split(':')[1];
-				var url = 'newapi:'+link;
-				var params = {
-				}
-				var success = function (res) {
-				  console.log('用餐提醒',res);
-				  if(res.data.code != 0){
-					  wx.showToast({
-					    title: res.data.msg,
-					    icon: 'none',
-					    duration: 2000
-					  });
-					  return;
-				  }
-				  let data = res.data.data;
-				  let can = '';
-				  if(data.type == 1) can = "早餐";
-				  if(data.type == 2) can = "中餐";
-				  if(data.type == 3) can = "晚餐";
-				  wx.showModal({
-				    title: "用餐提醒",
-				    content: `当前用餐日期${data['foodDate']} [${can}] 数量 ${data['nums']},是否确定用餐?`,
-				    success: function(res) {
-				      if (res.confirm) {
-						  var url = 'newapi:food/comfirm-get-food'
-						  var params = {
+				console.log('scanres',res);
+				// if(res.path == '/pages/canteen/dining/dining'){
+					wx.navigateTo({
+					  url: '/pages/canteen/dining/dining'
+					})
+				// }else{
+				// 	wx.showToast({
+				// 	  title: '扫描失败',
+				// 	  icon: 'error',
+				// 	  duration: 2000
+				// 	});
+				// }
+				// let link = res.result.split(':')[1];
+				// var url = 'newapi:'+link;
+				// var params = {
+				// }
+				// var success = function (res) {
+				//   console.log('用餐提醒',res);
+				//   if(res.data.code != 0){
+				// 	  wx.showToast({
+				// 	    title: res.data.msg,
+				// 	    icon: 'none',
+				// 	    duration: 2000
+				// 	  });
+				// 	  return;
+				//   }
+				//   let data = res.data.data;
+				//   let can = '';
+				//   if(data.type == 1) can = "早餐";
+				//   if(data.type == 2) can = "中餐";
+				//   if(data.type == 3) can = "晚餐";
+				//   wx.showModal({
+				//     title: "用餐提醒",
+				//     content: `当前用餐日期${data['foodDate']} [${can}] 数量 ${data['nums']},是否确定用餐?`,
+				//     success: function(res) {
+				//       if (res.confirm) {
+				// 		  var url = 'newapi:food/comfirm-get-food'
+				// 		  var params = {
 							  
-						  }
-						  var success = function (res) {
-							var result = res.data
-							if(result.code == 0){
-								wx.showToast({
-								  title: '成功,用餐愉快',
-								  icon: 'success',
-								  duration: 3000
-								});
-								that.onShow();
-								return;
-							}else{
-								wx.showToast({
-								  title: result.msg,
-								  icon: 'error',
-								  duration: 3000
-								});
-							}
-						  }
-						  _request.$get(url, params, success)
-				      } else if (res.cancel) {
+				// 		  }
+				// 		  var success = function (res) {
+				// 			var result = res.data
+				// 			if(result.code == 0){
+				// 				wx.showToast({
+				// 				  title: '成功,用餐愉快',
+				// 				  icon: 'success',
+				// 				  duration: 3000
+				// 				});
+				// 				that.onShow();
+				// 				return;
+				// 			}else{
+				// 				wx.showToast({
+				// 				  title: result.msg,
+				// 				  icon: 'error',
+				// 				  duration: 3000
+				// 				});
+				// 			}
+				// 		  }
+				// 		  _request.$get(url, params, success)
+				//       } else if (res.cancel) {
 				  			  
-				      }
-				    }
-				  })
-				}
-				_request.$get(url, params, success)
+				//       }
+				//     }
+				//   })
+				// }
+				// _request.$get(url, params, success)
 			}else{
 				wx.showToast({
 				  title: '扫描失败',
@@ -262,6 +290,11 @@ Page({
       url: '/pages/canteen/order/order'
     })
   },
+  toDining() {
+    wx.navigateTo({
+      url: '/pages/canteen/dining/dining'
+    })
+  },
   toRecharge() {
     // if(this.data.info.user.tel == ''){//未绑定手机号
     // 	wx.navigateTo({

+ 5 - 5
pages/canteen/canteen.wxml

@@ -18,17 +18,17 @@
   <view class="order-list" wx:for="{{detail}}">
 	  <view class="time-box">{{item.food_date}} ({{item.food_day}})</view>
 	  <view wx:for="{{item['details']}}" wx:for-item="oitem">
-		  <view class="order-card {{oitem['confirm']?'isuse':''}}" wx:if="{{oitem['nums'] > 0}}">
+		  <view class="order-card {{oitem['confirm']?'isuse':''}} {{oitem['expired']?'unuse':''}}" wx:if="{{oitem['nums'] > 0}}">
 			  <view class="title">
 				  <text wx:if="{{oitem['type'] == 1}}">早餐</text>
 				  <text wx:if="{{oitem['type'] == 2}}">中餐</text>
 				  <text wx:if="{{oitem['type'] == 3}}">晚餐</text>
 				<small style="font-size: 30rpx;">x{{oitem['nums']}}</small>
 			  </view>
-			  <view class="info" wx:if="{{oitem['type'] == 1}}">使用时间【07:00-09:00】</view>
-			  <view class="info" wx:if="{{oitem['type'] == 2}}">使用时间【11:50-12:50】</view>
-			  <view class="info" wx:if="{{oitem['type'] == 3}}">使用时间【17:50-18:50】</view>
-			  <view class="num">
+			  <view class="info" wx:if="{{oitem['type'] == 1}}">使用时间【{{mealInfo.break_time}}】</view>
+			  <view class="info" wx:if="{{oitem['type'] == 2}}">使用时间【{{mealInfo.lunch_time}}】</view>
+			  <view class="info" wx:if="{{oitem['type'] == 3}}">使用时间【{{mealInfo.dinner_time}}】</view>
+			  <view class="num" wx:if="{{!oitem['expired'] && !oitem['confirm']}}">
 				  状态:未使用
 				  <view class="del" bindtap="showCancelm" data-data="{{item}}" data-oitem="{{oitem}}">退餐</view>
 			  </view>

+ 1 - 1
pages/canteen/canteen.wxss

@@ -198,4 +198,4 @@ border-right: 0;
 font-size: 40rpx;
 
 margin: 0 10rpx;
-}
+}

+ 194 - 0
pages/canteen/dining/dining.js

@@ -0,0 +1,194 @@
+var _request = require('../../../utils/request.js')
+var rid;
+Page({
+  data: {
+    detail: {},
+	userInfo:{},
+	mealInfo:{},
+	info:{},
+	bindTelfirst:0,
+  },
+  onLoad: function (options) {
+	console.log('onload onLoad == dining',options)
+    this.checkLogin();
+  },
+  checkLogin:function(){
+  	  var that = this;
+	//2020登陆检测
+		wx.login({
+			success: res => {
+			  getApp().globalData.try_login = true;
+			  console.log('checkLogin',res.code)
+			  var url = 'xcx/login';
+			  let invite = wx.getStorageSync('invite');
+				  var params = {
+					code: res.code,
+					invite_id: invite//新token模式
+				  }
+				  that.setData({
+					wxlogincode: res.code
+				  })
+				  var success = function (res) {
+					console.log('pageLogin',res);
+					wx.setStorageSync('lbt_session_key', res.data.session_key)
+					wx.setStorageSync('lbt_session_time', Date.now())
+					wx.setStorageSync('lbt_token_key', res.data.token)
+					console.log('nowtoken',res.data.token);
+					
+					if(res.data.wx_user && res.data.wx_user.head != ''){
+						var userInfo = res.data.wx_user;
+						
+						that.info();
+						that.setData({
+							userInfo: userInfo
+						})
+							if(res.data.wx_user.head == '' ){
+								that.setData({
+									checkhead: false
+								})
+								
+								that.setData({
+									userInfo: 'nologin'
+								  })
+							}
+						  //checkwxhead---end
+					}else{
+						that.setData({
+							userInfo: 'nologin'
+						  })
+					}
+				  }
+				  _request.$get(url, params, success)
+			}
+		  })
+  },
+  info(){
+  	  console.log('oninfo');
+    var that = this
+    var url = 'v1/user/info'
+    var params = {}
+    var success = function (res) {
+      console.log(res)
+	  if(!res.data['user']['employ']){
+		  wx.showToast({
+		    title: '没有权限',
+		    icon: 'error',
+		    duration: 3000
+		  });
+		  wx.navigateBack();
+		  return;
+	  }
+      that.setData({
+        info: res.data,
+        show: res.data.wx_user?res.data.wx_user.show_invite_mode:'',
+  		bindTel: res.data.user.tel ? true : false
+      })
+  	  console.log('untel',res.data.user.tel)
+  	  
+  	  console.log('res.data.wx_user',res.data.wx_user)
+  	  if(res.data.wx_user.head == ''){
+  		  console.log('indddddddddddddddddddddddd')
+  		  that.setData({
+  		  	    userInfo: 'nologin'
+  		  	  })
+  	  }
+  	  if(that.data.userInfo != 'nologin' && res.data.user.tel == '' && that.data.bindTelfirst == 0){
+  		  that.setData({
+  		    bindTelfirst:1
+  		  })
+  		wx.navigateTo({
+  		 	url: '/packageUser/pages/user/bind/bind'
+  		})
+  		   		
+  		wx.showToast({
+  		   title: '请先绑定手机号~',
+  		   icon: 'none',
+  		   duration: 2000
+  		}) 
+  	  }
+	  
+	  that.getMeal();
+  	  
+  	  
+    }
+    _request.$get(url, params, success)
+  },
+  getMeal () {
+    var that = this
+    var url = 'newapi:food/get-meal-info'
+    var params = {
+    }
+    var success = function (res) {
+      var data = res.data.data
+      console.log('mealinfo',data);
+	  that.setData({
+	  	mealInfo: data
+	  })
+	  if(data.status == 'eating'){
+		  that.confirmDinging();
+	  }
+    }
+    _request.$get(url, params, success)
+  },
+  confirmDinging(){
+	  var url = 'newapi:food/scan-get-info';
+	  var params = {
+	  }
+	  var success = function (res) {
+	    console.log('用餐提醒',res);
+	    if(res.data.code != 0){
+	  	  wx.showToast({
+	  	    title: res.data.msg,
+	  	    icon: 'none',
+	  	    duration: 2000
+	  	  });
+		  
+	  	  return;
+	    }
+	    let data = res.data.data;
+	    let can = '';
+	    if(data.type == 1) can = "早餐";
+	    if(data.type == 2) can = "中餐";
+	    if(data.type == 3) can = "晚餐";
+	    wx.showModal({
+	      title: "用餐提醒",
+	      content: `当前用餐日期${data['foodDate']} [${can}] 数量 ${data['nums']},是否确定用餐?`,
+	      success: function(res) {
+	        if (res.confirm) {
+	  		  var url = 'newapi:food/comfirm-get-food'
+	  		  var params = {
+	  			  
+	  		  }
+	  		  var success = function (res) {
+	  			var result = res.data
+	  			if(result.code == 0){
+	  				wx.showToast({
+	  				  title: '成功,用餐愉快',
+	  				  icon: 'success',
+	  				  duration: 3000
+	  				});
+					setTimeout(function(){
+						wx.reLaunch({
+						  url: '/pages/canteen/canteen'
+						})
+					},1000)
+	  				return;
+	  			}else{
+	  				wx.showToast({
+	  				  title: result.msg,
+	  				  icon: 'error',
+	  				  duration: 3000
+	  				});
+	  			}
+	  		  }
+	  		  _request.$get(url, params, success)
+	        } else if (res.cancel) {
+	    			  
+	        }
+	      }
+	    })
+	  }
+	  _request.$get(url, params, success)
+  }
+  
+})

+ 6 - 0
pages/canteen/dining/dining.json

@@ -0,0 +1,6 @@
+{
+  "navigationBarTitleText": "用餐",
+  "usingComponents": {
+    "format-time": "../../../component/formatTime/formatTime"
+  }
+}

+ 19 - 0
pages/canteen/dining/dining.wxml

@@ -0,0 +1,19 @@
+<view class="bg">
+	
+	<view class="can" wx:if="{{mealInfo.status == 'eating'}}">
+		<view wx:if="{{mealInfo.mealType == 1}}">可以用【早餐】</view>
+		<view wx:if="{{mealInfo.mealType == 2}}">可以用【中餐】</view>
+		<view wx:if="{{mealInfo.mealType == 3}}">可以用【晚餐】</view>
+		<image src="../../../images/footer/dining.png" class="image"></image>
+	</view>
+	<view class="no" wx:if="{{mealInfo.status == 'wating'}}">暂未到用餐时间哦</view>
+	
+	
+	<view class="uselist">
+		<view class="tit">用餐时间表</view>
+		<view class="list">早餐:{{mealInfo.break_time}}</view>
+		<view class="list">中餐:{{mealInfo.lunch_time}}</view>
+		<view class="list">晚餐:{{mealInfo.dinner_time}}</view>
+	</view>
+	
+</view>

+ 42 - 0
pages/canteen/dining/dining.wxss

@@ -0,0 +1,42 @@
+.bg {
+  position: relative;
+  width: 100%;
+  min-height: 100%;
+background-color: #efefef;
+    overflow: hidden;
+}
+.uselist{
+	    margin: 25rpx;
+	    border-radius: 15rpx;
+	    background: rgba(255,0,0,0.2);
+	    padding: 15rpx;
+	    text-align: center;
+	    font-size: 40rpx;
+}
+.tit{
+	    margin-bottom: 15rpx;
+	    font-size: 44rpx;
+		    color: #333;
+}
+.list{
+	color: #333;
+}
+.can{
+	margin-top: 40rpx;
+	    text-align: center;
+	    padding: 25rpx;
+	    font-size: 50rpx;
+	    color: #eab86a;
+	    vertical-align: middle;
+}
+.can image{
+	width: 120rpx;
+	    height: 120rpx;
+	    display: inline-block;
+}
+.no{
+	    text-align: center;
+	    font-size: 45rpx;
+	    color: #999;
+	    margin: 100rpx;
+}

+ 4 - 0
utils/request.js

@@ -2,6 +2,10 @@
 const apiHost = 'https://fohowapi.hiwavo.com/';
 const apiHostX = 'https://xj.hiwavo.com/';//正式
 
+// 新正式(未审批)
+// const apiHost = 'https://xcx-api.fohowyc.com/';
+// const apiHostX = 'https://app-api.fohowyc.com/';//正式
+
 // 测试
 // const apiHost = 'https://tfohowapi.hiwavo.com/';
 // const apiHostX = 'https://txj.hiwavo.com/';