zs vor 2 Jahren
Ursprung
Commit
ae8c397fae

+ 18 - 22
pagesHome/home/index.vue

@@ -281,32 +281,28 @@
 					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));
-							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
-										}
+							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: list,
-									total: that.$plus(that.cartNum.total, res.data.money),
 								}
-								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}`
-									})
+								if (is_add) {
+									list.push(val)
 								}
 							}
+							let obj = {
+								list: list,
+								total: that.$plus(that.cartNum.total, res.data.money),
+							}
+							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}`
+								})
+							}
 						}
 					} else {
 						if (that.shopInfo.table) {

Datei-Diff unterdrückt, da er zu groß ist
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/pagesHome/home/index.js.map


+ 12 - 16
unpackage/dist/dev/mp-weixin/pagesHome/home/index.js

@@ -439,17 +439,14 @@ var _default =
       }
     },
     // 去购买
-    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:
+    toBuy: function toBuy() {var _this4 = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee7() {var that, res, list, 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 = 29;break;}if (!
-                that.order) {_context7.next = 20;break;}_context7.next = 6;return (
+                list.length > 0)) {_context7.next = 27;break;}if (!
+                that.order) {_context7.next = 18;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 (!(
-                same == false)) {_context7.next = 18;break;}
+                res.errcode == '0')) {_context7.next = 16;break;}
                 is_add = true;_iterator6 = _createForOfIteratorHelper(
                 res.data.list);try {for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {val = _step6.value;
                     for (i = 0; i < list.length; i++) {
@@ -464,33 +461,32 @@ var _default =
                   }} catch (err) {_iterator6.e(err);} finally {_iterator6.f();}
                 obj = {
                   list: list,
-                  total: that.$plus(that.cartNum.total, res.data.money) };_context7.next = 16;return (
+                  total: that.$plus(that.cartNum.total, res.data.money) };_context7.next = 14;return (
 
-                  that.$api("cart/".concat(that.id), 'POST', obj));case 16:update = _context7.sent;
+                  that.$api("cart/".concat(that.id), 'POST', obj));case 14: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 = 29;break;case 20:if (!
+                }case 16:_context7.next = 27;break;case 18:if (!
 
 
-
-                that.shopInfo.table) {_context7.next = 28;break;}
+                that.shopInfo.table) {_context7.next = 26;break;}
                 _obj = {
                   list: list,
                   total: that.cartNum.total,
-                  table: that.shopInfo.table };_context7.next = 24;return (
+                  table: that.shopInfo.table };_context7.next = 22;return (
 
-                  that.$api("cart", 'POST', _obj));case 24:res = _context7.sent;
+                  that.$api("cart", 'POST', _obj));case 22:res = _context7.sent;
                 if (res.errcode == '0') {
                   uni.navigateTo({
                     url: "/pagesHome/order/index?id=".concat(res.data._id) });
 
-                }_context7.next = 29;break;case 28:
+                }_context7.next = 27;break;case 26:
 
                 uni.showToast({
                   title: '请选择用餐桌号',
-                  icon: 'none' });case 29:case "end":return _context7.stop();}}}, _callee7);}))();
+                  icon: 'none' });case 27:case "end":return _context7.stop();}}}, _callee7);}))();