zs 2 yıl önce
ebeveyn
işleme
1eddd3c8ff

+ 32 - 12
pagesHome/home/index.vue

@@ -8,7 +8,7 @@
 						<!-- <uni-icons type="forward" size="20"></uni-icons> -->
 					</view>
 					<view class="num">
-						桌号:{{shopInfo.table}}
+						桌号:{{shopInfo.table_name}}
 					</view>
 				</view>
 				<!-- <view class="one_2">
@@ -151,6 +151,8 @@
 				is_show: false,
 				// 规格弹框
 				popupShow: '1',
+				// 桌号
+				tableList: [],
 			}
 		},
 		onLoad: async function(e) {
@@ -167,10 +169,12 @@
 			async search() {
 				const that = this;
 				let res;
+				res = await that.$api(`table`, 'GET', {});
+				if (res.errcode == '0') that.$set(that, `tableList`, res.data);
 				res = await that.$api(`shop`, 'GET', {});
 				if (res.errcode == '0') {
 					let data = res.data[0]
-					data.table = '1'
+					data.table_name = that.tableList[0].name
 					that.$set(that, `shopInfo`, data);
 				}
 				res = await that.$api(`goodsTags`, 'GET', {});
@@ -265,22 +269,38 @@
 					if (that.id) {
 						res = await that.$api(`cart/${that.id}`, 'GET', {});
 						if (res.errcode == '0') {
-							let obj = {
-								list: [...list, ...res.data.list],
-								total: that.$plus(that.cartNum.total, res.data.total),
-							}
-							let cart = await that.$api(`cart/${res.data._id}`, 'POST', obj);
-							if (cart.errcode == '0') {
-								uni.navigateTo({
-									url: `/pagesHome/order/add?id=${cart.data._id}&order=${that.order}`
-								})
+							let same = res.data.list.length === list.length && res.data.list.filter(t => !list
+								.includes(t));
+							if (same == false) {
+								let is_add = true
+								for (let val of res.data.list) {
+									for (let i = 0; i < list.length; i++) {
+										if (val._id == list[i]._id) {
+											list[i].num = val.num + list[i].num
+											is_add = false
+										}
+									}
+									if (is_add) {
+										list.push(val)
+									}
+								}
+								let obj = {
+									list: that.buyList,
+									money: that.$plus(that.cartNum.total, res.data.total),
+								}
+								let update = await that.$api(`order/${that.order}`, 'POST', obj);
+								if (update.errcode == '0') {
+									uni.navigateTo({
+										url: `/pagesHome/order/add?id=${that.id}&order=${that.order}`
+									})
+								}
 							}
 						}
 					} else {
 						let obj = {
 							list: list,
 							total: that.cartNum.total,
-							table: '63dc6a6b6a22ff30c8a11470'
+							table: that.tableList[0]._id
 						}
 						res = await that.$api(`cart`, 'POST', obj);
 						if (res.errcode == '0') {

+ 6 - 6
pagesHome/order/add.vue

@@ -3,7 +3,7 @@
 		<view class="info">
 			<view class="one">
 				<view class="one_1">
-					<view class="left">桌号:{{shopInfo.table}}</view>
+					<view class="left">桌号:{{shopInfo.table_name}}</view>
 					<view class="right">人数:{{shopInfo.num}}人</view>
 				</view>
 				<view class="one_2">
@@ -42,13 +42,13 @@
 					</scroll-view>
 				</view>
 				<view class="two_3">
-					共{{list.length}}件商品,合计:<text>¥</text><text>{{shopInfo.total}}</text>
+					共{{list.length}}件商品,合计:<text>¥</text><text>{{shopInfo.money}}</text>
 				</view>
 			</view>
 		</view>
 		<view class="foot">
 			<view class="foot_1">
-				合计<text>¥</text><text>{{shopInfo.total||0}}</text>
+				合计<text>¥</text><text>{{shopInfo.money||0}}</text>
 			</view>
 			<view class="foot_2">
 				<button class="button" @tap.stop="toBuy">下单</button>
@@ -81,13 +81,12 @@
 			async search(e) {
 				const that = this;
 				if (that.id) {
-					let res = await that.$api(`cart/${that.id}`, 'GET', {});
+					let res = await that.$api(`order/${that.order}`, 'GET', {});
 					if (res.errcode == '0') {
 						that.$set(that, `list`, res.data.list)
 						that.$set(that, `shopInfo`, res.data)
 						let table = await that.$api(`table/${res.data.table}`, `GET`)
-						that.$set(that.shopInfo, `table`, table.data.name)
-						that.$set(that.shopInfo, `table_id`, res.data.table)
+						that.$set(that.shopInfo, `table_name`, table.data.name)
 					}
 				}
 			},
@@ -101,6 +100,7 @@
 					time: moment().format('YYYY-MM-DD HH:mm:ss'),
 					list: that.list
 				}
+				if (that.shopInfo.remark) obj.remark = that.shopInfo.remark
 				let res = await that.$api(`order/${that.order}`, 'POST', obj);
 				if (res.errcode == '0') {
 					uni.showToast({

+ 3 - 7
pagesHome/order/index.vue

@@ -3,7 +3,7 @@
 		<view class="info">
 			<view class="one">
 				<view class="one_1">
-					<view class="left">桌号:{{shopInfo.table}}</view>
+					<view class="left">桌号:{{shopInfo.table_name}}</view>
 					<view class="right">
 						<view class="right_1">
 							<text @click="toChang" :class="[is_show==true?'type':'']">店内就餐</text>
@@ -114,17 +114,13 @@
 				let res;
 				if (that.id) {
 					res = await that.$api(`shop`, 'GET', {});
-					if (res.errcode == '0') {
-						let data = res.data[0]
-						data.table = '1'
-						that.$set(that, `shopInfo`, data);
-					}
+					if (res.errcode == '0') that.$set(that, `shopInfo`, res.data[0]);
 					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`, table.data.name)
+						that.$set(that.shopInfo, `table_name`, table.data.name)
 						that.$set(that.shopInfo, `table_id`, res.data.table)
 					}
 				}

+ 2 - 2
pagesHome/order/info.vue

@@ -6,7 +6,7 @@
 			</view>
 			<view class="two">
 				<view class="two_1">
-					<view class="left">桌号:{{shopInfo.table_num}}</view>
+					<view class="left">桌号:{{shopInfo.table_name}}</view>
 					<view class="right">人数:{{shopInfo.num}}人</view>
 				</view>
 				<view class="two_2">
@@ -102,7 +102,7 @@
 						that.$set(that, `list`, res.data.list)
 						that.$set(that, `shopInfo`, res.data)
 						let table = await that.$api(`table/${res.data.table}`, `GET`)
-						that.$set(that.shopInfo, `table_num`, table.data.name)
+						that.$set(that.shopInfo, `table_name`, table.data.name)
 					}
 				}
 			},

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pagesHome/home/index.js.map


Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pagesHome/order/add.js.map


Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pagesHome/order/index.js.map


Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pagesHome/order/info.js.map


Dosya farkı çok büyük olduğundan ihmal edildi
+ 42 - 22
unpackage/dist/dev/mp-weixin/pagesHome/home/index.js


Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
unpackage/dist/dev/mp-weixin/pagesHome/home/index.wxml


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

@@ -237,14 +237,13 @@ 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:
                 that = _this;if (!
-                that.id) {_context2.next = 13;break;}_context2.next = 4;return (
-                  that.$api("cart/".concat(that.id), 'GET', {}));case 4:res = _context2.sent;if (!(
-                res.errcode == '0')) {_context2.next = 13;break;}
+                that.id) {_context2.next = 12;break;}_context2.next = 4;return (
+                  that.$api("order/".concat(that.order), '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.$api("table/".concat(res.data.table), "GET"));case 10:table = _context2.sent;
-                that.$set(that.shopInfo, "table", table.data.name);
-                that.$set(that.shopInfo, "table_id", res.data.table);case 13:case "end":return _context2.stop();}}}, _callee2);}))();
+                that.$set(that.shopInfo, "table_name", table.data.name);case 12:case "end":return _context2.stop();}}}, _callee2);}))();
 
 
     },
@@ -256,15 +255,16 @@ var _moment = _interopRequireDefault(__webpack_require__(/*! moment */ 42));func
                 type = '1';
                 obj = {
                   time: (0, _moment.default)().format('YYYY-MM-DD HH:mm:ss'),
-                  list: that.list };_context3.next = 6;return (
+                  list: that.list };
 
-                  that.$api("order/".concat(that.order), 'POST', obj));case 6:res = _context3.sent;
+                if (that.shopInfo.remark) obj.remark = that.shopInfo.remark;_context3.next = 7;return (
+                  that.$api("order/".concat(that.order), 'POST', obj));case 7:res = _context3.sent;
                 if (res.errcode == '0') {
                   uni.showToast({
                     title: '下单成功',
                     icon: 'none' });
 
-                }case 8:case "end":return _context3.stop();}}}, _callee3);}))();
+                }case 9:case "end":return _context3.stop();}}}, _callee3);}))();
     } } };exports.default = _default;
 /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 1)["default"]))
 

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
unpackage/dist/dev/mp-weixin/pagesHome/order/add.wxml


+ 3 - 7
unpackage/dist/dev/mp-weixin/pagesHome/order/index.js

@@ -295,22 +295,18 @@ 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, data, 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, 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') {
-                  data = res.data[0];
-                  data.table = '1';
-                  that.$set(that, "shopInfo", data);
-                }_context2.next = 8;return (
+                if (res.errcode == '0') that.$set(that, "shopInfo", res.data[0]);_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", table.data.name);
+                that.$set(that.shopInfo, "table_name", table.data.name);
                 that.$set(that.shopInfo, "table_id", res.data.table);case 17:case "end":return _context2.stop();}}}, _callee2);}))();
 
 

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
unpackage/dist/dev/mp-weixin/pagesHome/order/index.wxml


+ 1 - 1
unpackage/dist/dev/mp-weixin/pagesHome/order/info.js

@@ -262,7 +262,7 @@ var _default =
                 that.$set(that, "list", res.data.list);
                 that.$set(that, "shopInfo", res.data);_context2.next = 10;return (
                   that.$api("table/".concat(res.data.table), "GET"));case 10:table = _context2.sent;
-                that.$set(that.shopInfo, "table_num", table.data.name);case 12:case "end":return _context2.stop();}}}, _callee2);}))();
+                that.$set(that.shopInfo, "table_name", table.data.name);case 12:case "end":return _context2.stop();}}}, _callee2);}))();
 
 
     },

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
unpackage/dist/dev/mp-weixin/pagesHome/order/info.wxml