zs 2 gadi atpakaļ
vecāks
revīzija
89b5a72d13

+ 35 - 17
pagesHome/home/index.vue

@@ -8,7 +8,11 @@
 						<!-- <uni-icons type="forward" size="20"></uni-icons> -->
 					</view>
 					<view class="num">
-						桌号:{{shopInfo.table_name}}
+						<picker @change="tableChange" :value="shopInfo.table_name" :range="tableList" range-key="name">
+							<view>
+								桌号:{{shopInfo.table_name||'请选择用餐桌号'}}
+							</view>
+						</picker>
 					</view>
 				</view>
 				<!-- <view class="one_2">
@@ -174,7 +178,7 @@
 				res = await that.$api(`shop`, 'GET', {});
 				if (res.errcode == '0') {
 					let data = res.data[0]
-					data.table_name = that.tableList[0].name
+					// data.table_name = that.tableList[0].name
 					that.$set(that, `shopInfo`, data);
 				}
 				res = await that.$api(`goodsTags`, 'GET', {});
@@ -260,14 +264,22 @@
 				that.$set(that, `popupShow`, '1')
 				that.$refs.specShow.open();
 			},
+			tableChange(e) {
+				const that = this;
+				let data = that.tableList[e.detail.value];
+				if (data) {
+					that.$set(that.shopInfo, `table_name`, data.name);
+					that.$set(that.shopInfo, `table`, data._id);
+				}
+			},
 			// 去购买
 			async toBuy() {
 				const that = this;
 				let res;
 				let list = that.buyList.filter(i => i.num !== 0)
 				if (list.length > 0) {
-					if (that.id) {
-						res = await that.$api(`cart/${that.id}`, 'GET', {});
+					if (that.order) {
+						res = await that.$api(`order/${that.order}`, 'GET', {});
 						if (res.errcode == '0') {
 							let same = res.data.list.length === list.length && res.data.list.filter(t => !list
 								.includes(t));
@@ -285,10 +297,10 @@
 									}
 								}
 								let obj = {
-									list: that.buyList,
-									money: that.$plus(that.cartNum.total, res.data.total),
+									list: list,
+									total: that.$plus(that.cartNum.total, res.data.money),
 								}
-								let update = await that.$api(`order/${that.order}`, 'POST', obj);
+								let update = await that.$api(`cart/${that.id}`, 'POST', obj);
 								if (update.errcode == '0') {
 									uni.navigateTo({
 										url: `/pagesHome/order/add?id=${that.id}&order=${that.order}`
@@ -297,19 +309,25 @@
 							}
 						}
 					} else {
-						let obj = {
-							list: list,
-							total: that.cartNum.total,
-							table: that.tableList[0]._id
-						}
-						res = await that.$api(`cart`, 'POST', obj);
-						if (res.errcode == '0') {
-							uni.navigateTo({
-								url: `/pagesHome/order/index?id=${res.data._id}`
+						if (that.shopInfo.table) {
+							let obj = {
+								list: list,
+								total: that.cartNum.total,
+								table: that.shopInfo.table
+							}
+							res = await that.$api(`cart`, 'POST', obj);
+							if (res.errcode == '0') {
+								uni.navigateTo({
+									url: `/pagesHome/order/index?id=${res.data._id}`
+								})
+							}
+						} else {
+							uni.showToast({
+								title: '请选择用餐桌号',
+								icon: 'none'
 							})
 						}
 					}
-
 				}
 			},
 			//清空购物车

+ 11 - 8
pagesHome/order/add.vue

@@ -42,13 +42,13 @@
 					</scroll-view>
 				</view>
 				<view class="two_3">
-					共{{list.length}}件商品,合计:<text>¥</text><text>{{shopInfo.money}}</text>
+					共{{list.length}}件商品,合计:<text>¥</text><text>{{shopInfo.total}}</text>
 				</view>
 			</view>
 		</view>
 		<view class="foot">
 			<view class="foot_1">
-				合计<text>¥</text><text>{{shopInfo.money||0}}</text>
+				合计<text>¥</text><text>{{shopInfo.total||0}}</text>
 			</view>
 			<view class="foot_2">
 				<button class="button" @tap.stop="toBuy">下单</button>
@@ -74,20 +74,23 @@
 			that.$set(that, `order`, e.order);
 			that.search();
 		},
-		onShow() {
-			const that = this;
-		},
 		methods: {
 			async search(e) {
 				const that = this;
-				if (that.id) {
-					let res = await that.$api(`order/${that.order}`, 'GET', {});
+				if (that.id && that.order) {
+					let res;
+					res = await that.$api(`cart/${that.id}`, 'GET', {});
 					if (res.errcode == '0') {
 						that.$set(that, `list`, res.data.list)
-						that.$set(that, `shopInfo`, res.data)
+						that.$set(that.shopInfo, `total`, res.data.total)
 						let table = await that.$api(`table/${res.data.table}`, `GET`)
 						that.$set(that.shopInfo, `table_name`, table.data.name)
 					}
+					res = await that.$api(`order/${that.order}`, 'GET', {});
+					if (res.errcode == '0') {
+						that.$set(that.shopInfo, `num`, res.data.num)
+						that.$set(that.shopInfo, `remark`, res.data.remark)
+					}
 				}
 			},
 			// 下单

+ 8 - 4
pagesHome/order/index.vue

@@ -3,7 +3,7 @@
 		<view class="info">
 			<view class="one">
 				<view class="one_1">
-					<view class="left">桌号:{{shopInfo.table_name}}</view>
+					<view class="left">桌号:{{shopInfo.table}}</view>
 					<view class="right">
 						<view class="right_1">
 							<text @click="toChang" :class="[is_show==true?'type':'']">店内就餐</text>
@@ -114,13 +114,17 @@
 				let res;
 				if (that.id) {
 					res = await that.$api(`shop`, 'GET', {});
-					if (res.errcode == '0') that.$set(that, `shopInfo`, res.data[0]);
+					if (res.errcode == '0') {
+						let data = res.data[0]
+						data.table = '1'
+						that.$set(that, `shopInfo`, data);
+					}
 					res = await that.$api(`cart/${that.id}`, 'GET', {});
 					if (res.errcode == '0') {
 						that.$set(that, `list`, res.data.list)
 						that.$set(that.shopInfo, `goods_total`, res.data.total)
 						let table = await that.$api(`table/${res.data.table}`, `GET`)
-						that.$set(that.shopInfo, `table_name`, table.data.name)
+						that.$set(that.shopInfo, `table`, table.data.name)
 						that.$set(that.shopInfo, `table_id`, res.data.table)
 					}
 				}
@@ -165,7 +169,7 @@
 					}
 				}else{
 					uni.showToast({
-						title: '请选择用餐人数',
+						title: '下单成功',
 						icon: 'none'
 					})
 				}

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pagesHome/home/index.js.map


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pagesHome/order/add.js.map


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pagesHome/order/index.js.map


+ 29 - 11
unpackage/dist/dev/mp-weixin/pagesHome/home/index.js

@@ -295,6 +295,10 @@ __webpack_require__.r(__webpack_exports__);
 //
 //
 //
+//
+//
+//
+//
 var _default =
 {
   data: function data() {
@@ -340,7 +344,7 @@ var _default =
                   that.$api("shop", 'GET', {}));case 7:res = _context2.sent;
                 if (res.errcode == '0') {
                   data = res.data[0];
-                  data.table_name = that.tableList[0].name;
+                  // data.table_name = that.tableList[0].name
                   that.$set(that, "shopInfo", data);
                 }_context2.next = 11;return (
                   that.$api("goodsTags", 'GET', {}));case 11:res = _context2.sent;
@@ -426,14 +430,22 @@ var _default =
       that.$set(that, "popupShow", '1');
       that.$refs.specShow.open();
     },
+    tableChange: function tableChange(e) {
+      var that = this;
+      var data = that.tableList[e.detail.value];
+      if (data) {
+        that.$set(that.shopInfo, "table_name", data.name);
+        that.$set(that.shopInfo, "table", data._id);
+      }
+    },
     // 去购买
     toBuy: function toBuy() {var _this4 = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee7() {var that, res, list, same, is_add, _iterator6, _step6, val, i, obj, update, _obj;return _regenerator.default.wrap(function _callee7$(_context7) {while (1) {switch (_context7.prev = _context7.next) {case 0:
                 that = _this4;
 
                 list = that.buyList.filter(function (i) {return i.num !== 0;});if (!(
-                list.length > 0)) {_context7.next = 25;break;}if (!
-                that.id) {_context7.next = 20;break;}_context7.next = 6;return (
-                  that.$api("cart/".concat(that.id), 'GET', {}));case 6:res = _context7.sent;if (!(
+                list.length > 0)) {_context7.next = 29;break;}if (!
+                that.order) {_context7.next = 20;break;}_context7.next = 6;return (
+                  that.$api("order/".concat(that.order), 'GET', {}));case 6:res = _context7.sent;if (!(
                 res.errcode == '0')) {_context7.next = 18;break;}
                 same = res.data.list.length === list.length && res.data.list.filter(function (t) {return !list.
                   includes(t);});if (!(
@@ -451,29 +463,35 @@ var _default =
                     }
                   }} catch (err) {_iterator6.e(err);} finally {_iterator6.f();}
                 obj = {
-                  list: that.buyList,
-                  money: that.$plus(that.cartNum.total, res.data.total) };_context7.next = 16;return (
+                  list: list,
+                  total: that.$plus(that.cartNum.total, res.data.money) };_context7.next = 16;return (
 
-                  that.$api("order/".concat(that.order), 'POST', obj));case 16:update = _context7.sent;
+                  that.$api("cart/".concat(that.id), 'POST', obj));case 16:update = _context7.sent;
                 if (update.errcode == '0') {
                   uni.navigateTo({
                     url: "/pagesHome/order/add?id=".concat(that.id, "&order=").concat(that.order) });
 
-                }case 18:_context7.next = 25;break;case 20:
+                }case 18:_context7.next = 29;break;case 20:if (!
 
 
 
+                that.shopInfo.table) {_context7.next = 28;break;}
                 _obj = {
                   list: list,
                   total: that.cartNum.total,
-                  table: that.tableList[0]._id };_context7.next = 23;return (
+                  table: that.shopInfo.table };_context7.next = 24;return (
 
-                  that.$api("cart", 'POST', _obj));case 23:res = _context7.sent;
+                  that.$api("cart", 'POST', _obj));case 24:res = _context7.sent;
                 if (res.errcode == '0') {
                   uni.navigateTo({
                     url: "/pagesHome/order/index?id=".concat(res.data._id) });
 
-                }case 25:case "end":return _context7.stop();}}}, _callee7);}))();
+                }_context7.next = 29;break;case 28:
+
+                uni.showToast({
+                  title: '请选择用餐桌号',
+                  icon: 'none' });case 29:case "end":return _context7.stop();}}}, _callee7);}))();
+
 
 
 

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
unpackage/dist/dev/mp-weixin/pagesHome/home/index.wxml


+ 11 - 8
unpackage/dist/dev/mp-weixin/pagesHome/order/add.js

@@ -231,20 +231,23 @@ var _moment = _interopRequireDefault(__webpack_require__(/*! moment */ 42));func
               that.$set(that, "order", e.order);
               that.search();case 4:case "end":return _context.stop();}}}, _callee, this);}));function onLoad(_x) {return _onLoad.apply(this, arguments);}return onLoad;}(),
 
-  onShow: function onShow() {
-    var that = this;
-  },
   methods: {
     search: function search(e) {var _this = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee2() {var that, res, table;return _regenerator.default.wrap(function _callee2$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0:
-                that = _this;if (!
-                that.id) {_context2.next = 12;break;}_context2.next = 4;return (
-                  that.$api("order/".concat(that.order), 'GET', {}));case 4:res = _context2.sent;if (!(
+                that = _this;if (!(
+                that.id && that.order)) {_context2.next = 16;break;}_context2.next = 4;return (
+
+                  that.$api("cart/".concat(that.id), 'GET', {}));case 4:res = _context2.sent;if (!(
                 res.errcode == '0')) {_context2.next = 12;break;}
                 that.$set(that, "list", res.data.list);
-                that.$set(that, "shopInfo", res.data);_context2.next = 10;return (
+                that.$set(that.shopInfo, "total", res.data.total);_context2.next = 10;return (
                   that.$api("table/".concat(res.data.table), "GET"));case 10:table = _context2.sent;
-                that.$set(that.shopInfo, "table_name", table.data.name);case 12:case "end":return _context2.stop();}}}, _callee2);}))();
+                that.$set(that.shopInfo, "table_name", table.data.name);case 12:_context2.next = 14;return (
 
+                  that.$api("order/".concat(that.order), 'GET', {}));case 14:res = _context2.sent;
+                if (res.errcode == '0') {
+                  that.$set(that.shopInfo, "num", res.data.num);
+                  that.$set(that.shopInfo, "remark", res.data.remark);
+                }case 16:case "end":return _context2.stop();}}}, _callee2);}))();
 
     },
     // 下单

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
unpackage/dist/dev/mp-weixin/pagesHome/order/add.wxml


+ 8 - 4
unpackage/dist/dev/mp-weixin/pagesHome/order/index.js

@@ -295,18 +295,22 @@ var _moment = _interopRequireDefault(__webpack_require__(/*! moment */ 42));func
 
   },
   methods: {
-    search: function search(e) {var _this = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee2() {var that, res, table;return _regenerator.default.wrap(function _callee2$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0:
+    search: function search(e) {var _this = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee2() {var that, res, data, table;return _regenerator.default.wrap(function _callee2$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0:
                 that = _this;if (!
 
                 that.id) {_context2.next = 17;break;}_context2.next = 4;return (
                   that.$api("shop", 'GET', {}));case 4:res = _context2.sent;
-                if (res.errcode == '0') that.$set(that, "shopInfo", res.data[0]);_context2.next = 8;return (
+                if (res.errcode == '0') {
+                  data = res.data[0];
+                  data.table = '1';
+                  that.$set(that, "shopInfo", data);
+                }_context2.next = 8;return (
                   that.$api("cart/".concat(that.id), 'GET', {}));case 8:res = _context2.sent;if (!(
                 res.errcode == '0')) {_context2.next = 17;break;}
                 that.$set(that, "list", res.data.list);
                 that.$set(that.shopInfo, "goods_total", res.data.total);_context2.next = 14;return (
                   that.$api("table/".concat(res.data.table), "GET"));case 14:table = _context2.sent;
-                that.$set(that.shopInfo, "table_name", table.data.name);
+                that.$set(that.shopInfo, "table", table.data.name);
                 that.$set(that.shopInfo, "table_id", res.data.table);case 17:case "end":return _context2.stop();}}}, _callee2);}))();
 
 
@@ -351,7 +355,7 @@ var _moment = _interopRequireDefault(__webpack_require__(/*! moment */ 42));func
                 }_context3.next = 12;break;case 11:
 
                 uni.showToast({
-                  title: '请选择用餐人数',
+                  title: '下单成功',
                   icon: 'none' });case 12:case "end":return _context3.stop();}}}, _callee3);}))();
 
 

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
unpackage/dist/dev/mp-weixin/pagesHome/order/index.wxml