|
@@ -381,15 +381,15 @@ var _default =
|
|
|
list = that.buyList.find(function (i) {return i._id == e._id;});
|
|
|
if (list) {
|
|
|
if (list.num == 0) {
|
|
|
- cart = that.buyList.filter(function (i) {return i._id !== list._id;});
|
|
|
+ cart = that.buyList.filter(function (i) {return i._id !== e._id;});
|
|
|
if (cart) that.$set(that, "buyList", cart);
|
|
|
} else {_iterator3 = _createForOfIteratorHelper(
|
|
|
that.buyList);try {for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {val = _step3.value;
|
|
|
- if (val._id == list._id) val.num = e.num;
|
|
|
+ if (val._id == e._id) val.num = e.num;
|
|
|
}} catch (err) {_iterator3.e(err);} finally {_iterator3.f();}
|
|
|
}
|
|
|
} else {
|
|
|
- if (e.num != 0) that.buyList.push(e);
|
|
|
+ if (e.num !== 0) that.buyList.push(e);
|
|
|
}_iterator4 = _createForOfIteratorHelper(
|
|
|
that.typeList);try {_loop = function _loop() {var s = _step4.value;
|
|
|
var num = that.buyList.filter(function (i) {return i.code == s.code;});
|
|
@@ -417,45 +417,48 @@ var _default =
|
|
|
// 查看选择商品详情
|
|
|
toView: function toView() {
|
|
|
var that = this;
|
|
|
+ var list = that.buyList.filter(function (i) {return i.num !== 0;});
|
|
|
+ that.$set(that, "buyList", list);
|
|
|
that.$set(that, "popupShow", '1');
|
|
|
that.$refs.specShow.open();
|
|
|
},
|
|
|
// 去购买
|
|
|
- toBuy: function toBuy() {var _this4 = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee7() {var that, res, obj, cart, _obj;return _regenerator.default.wrap(function _callee7$(_context7) {while (1) {switch (_context7.prev = _context7.next) {case 0:
|
|
|
- that = _this4;if (!(
|
|
|
-
|
|
|
- that.buyList.length > 0)) {_context7.next = 19;break;}if (!
|
|
|
- that.id) {_context7.next = 14;break;}_context7.next = 5;return (
|
|
|
- that.$api("cart/".concat(that.id), 'GET', {}));case 5:res = _context7.sent;if (!(
|
|
|
- res.errcode == '0')) {_context7.next = 12;break;}
|
|
|
+ toBuy: function toBuy() {var _this4 = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee7() {var that, res, list, obj, cart, _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 = 20;break;}if (!
|
|
|
+ that.id) {_context7.next = 15;break;}_context7.next = 6;return (
|
|
|
+ that.$api("cart/".concat(that.id), 'GET', {}));case 6:res = _context7.sent;if (!(
|
|
|
+ res.errcode == '0')) {_context7.next = 13;break;}
|
|
|
obj = {
|
|
|
- list: [].concat(_toConsumableArray(that.buyList), _toConsumableArray(res.data.list)),
|
|
|
- total: that.$plus(that.cartNum.total, res.data.total) };_context7.next = 10;return (
|
|
|
+ list: [].concat(_toConsumableArray(list), _toConsumableArray(res.data.list)),
|
|
|
+ total: that.$plus(that.cartNum.total, res.data.total) };_context7.next = 11;return (
|
|
|
|
|
|
- that.$api("cart/".concat(res.data._id), 'POST', obj));case 10:cart = _context7.sent;
|
|
|
+ that.$api("cart/".concat(res.data._id), 'POST', obj));case 11:cart = _context7.sent;
|
|
|
if (cart.errcode == '0') {
|
|
|
uni.navigateTo({
|
|
|
url: "/pagesHome/order/add?id=".concat(cart.data._id, "&order=").concat(that.order) });
|
|
|
|
|
|
- }case 12:_context7.next = 19;break;case 14:
|
|
|
+ }case 13:_context7.next = 20;break;case 15:
|
|
|
|
|
|
|
|
|
_obj = {
|
|
|
- list: that.buyList,
|
|
|
+ list: list,
|
|
|
total: that.cartNum.total,
|
|
|
- table: '63dc6a6b6a22ff30c8a11470' };_context7.next = 17;return (
|
|
|
+ table: '63dc6a6b6a22ff30c8a11470' };_context7.next = 18;return (
|
|
|
|
|
|
- that.$api("cart", 'POST', _obj));case 17:res = _context7.sent;
|
|
|
+ that.$api("cart", 'POST', _obj));case 18:res = _context7.sent;
|
|
|
if (res.errcode == '0') {
|
|
|
uni.navigateTo({
|
|
|
url: "/pagesHome/order/index?id=".concat(res.data._id) });
|
|
|
|
|
|
- }case 19:case "end":return _context7.stop();}}}, _callee7);}))();
|
|
|
+ }case 20:case "end":return _context7.stop();}}}, _callee7);}))();
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
- // 关闭弹框
|
|
|
+ //清空购物车
|
|
|
toDelete: function toDelete() {
|
|
|
var that = this;var _iterator6 = _createForOfIteratorHelper(
|
|
|
that.typeList),_step6;try {for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {var val = _step6.value;val.num = 0;}} catch (err) {_iterator6.e(err);} finally {_iterator6.f();}
|
|
@@ -465,18 +468,6 @@ var _default =
|
|
|
that.searchMarket();
|
|
|
that.$refs.specShow.close();
|
|
|
},
|
|
|
- // 分页
|
|
|
- toPage: function toPage() {
|
|
|
- var that = this;
|
|
|
- },
|
|
|
- // 触底
|
|
|
- toScroll: function toScroll(e) {
|
|
|
- var that = this;
|
|
|
- var up = that.scrollTop;
|
|
|
- that.$set(that, "scrollTop", e.detail.scrollTop);
|
|
|
- var num = Math.sign(up - e.detail.scrollTop);
|
|
|
- if (num == 1) that.$set(that, "is_bottom", false);
|
|
|
- },
|
|
|
// 左侧一级选择
|
|
|
toChange: function toChange(index, e) {
|
|
|
var that = this;
|