|
@@ -292,106 +292,16 @@ __webpack_require__.r(__webpack_exports__);
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
//
|
|
|
|
+//
|
|
|
|
+//
|
|
|
|
+//
|
|
var _default =
|
|
var _default =
|
|
{
|
|
{
|
|
data: function data() {
|
|
data: function data() {
|
|
return {
|
|
return {
|
|
id: '',
|
|
id: '',
|
|
- shopInfo: {
|
|
|
|
- name: '德轩美食',
|
|
|
|
- table: '1',
|
|
|
|
- coupon: [{
|
|
|
|
- name: '满100减10' },
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- name: '满200减30' }],
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- notice: '您好,欢迎进店选购',
|
|
|
|
- logo: __webpack_require__(/*! ../../static/foods_1.webp */ 34) },
|
|
|
|
-
|
|
|
|
- list: [{
|
|
|
|
- _id: '1',
|
|
|
|
- code: '0',
|
|
|
|
- name: '三文鱼',
|
|
|
|
- file: __webpack_require__(/*! ../../static/foods_1.webp */ 34),
|
|
|
|
- price: 126,
|
|
|
|
- spec: '300g',
|
|
|
|
- stock: 100 },
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- _id: '2',
|
|
|
|
- code: '0',
|
|
|
|
- name: '蜜汁扇贝',
|
|
|
|
- file: __webpack_require__(/*! ../../static/foods_2.webp */ 25),
|
|
|
|
- price: 68,
|
|
|
|
- spec: '400g',
|
|
|
|
- stock: 140 },
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- _id: '3',
|
|
|
|
- code: '0',
|
|
|
|
- name: '意大利牛排',
|
|
|
|
- file: __webpack_require__(/*! ../../static/foods_3.webp */ 35),
|
|
|
|
- price: 128,
|
|
|
|
- spec: '600g',
|
|
|
|
- stock: 200 },
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- _id: '4',
|
|
|
|
- code: '0',
|
|
|
|
- name: '糖醋里脊',
|
|
|
|
- file: __webpack_require__(/*! ../../static/foods_4.webp */ 36),
|
|
|
|
- price: 58,
|
|
|
|
- spec: '500g',
|
|
|
|
- stock: 140 },
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- _id: '5',
|
|
|
|
- code: '2',
|
|
|
|
- name: '黑糖珍珠奶茶',
|
|
|
|
- file: __webpack_require__(/*! ../../static/foods_1.webp */ 34),
|
|
|
|
- price: 18,
|
|
|
|
- spec: '500g',
|
|
|
|
- stock: 120 },
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- _id: '6',
|
|
|
|
- code: '2',
|
|
|
|
- name: '雪碧',
|
|
|
|
- file: __webpack_require__(/*! ../../static/foods_2.webp */ 25),
|
|
|
|
- price: 5,
|
|
|
|
- spec: '500g',
|
|
|
|
- stock: 34 },
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- _id: '7',
|
|
|
|
- code: '2',
|
|
|
|
- name: '可口可乐',
|
|
|
|
- file: __webpack_require__(/*! ../../static/foods_3.webp */ 35),
|
|
|
|
- price: 5,
|
|
|
|
- spec: '500g',
|
|
|
|
- stock: 50 },
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- _id: '8',
|
|
|
|
- code: '1',
|
|
|
|
- name: '芝士小蛋糕',
|
|
|
|
- file: __webpack_require__(/*! ../../static/foods_2.webp */ 25),
|
|
|
|
- price: 12,
|
|
|
|
- spec: '260g',
|
|
|
|
- stock: 10 },
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- _id: '9',
|
|
|
|
- code: '1',
|
|
|
|
- name: '草莓千层',
|
|
|
|
- file: __webpack_require__(/*! ../../static/foods_3.webp */ 35),
|
|
|
|
- price: 15,
|
|
|
|
- spec: '350g',
|
|
|
|
- stock: 40 }],
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ shopInfo: {},
|
|
|
|
+ list: [],
|
|
active: '0',
|
|
active: '0',
|
|
tags: {},
|
|
tags: {},
|
|
// 数据是否触底
|
|
// 数据是否触底
|
|
@@ -418,58 +328,73 @@ var _default =
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
// 查询左侧一级列表
|
|
// 查询左侧一级列表
|
|
- search: function search() {var _this = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee2() {var that, type;return _regenerator.default.wrap(function _callee2$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0:
|
|
|
|
- that = _this;
|
|
|
|
- type = [{
|
|
|
|
- icon: 'vip',
|
|
|
|
- name: '主食',
|
|
|
|
- code: '0' },
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- icon: 'fire',
|
|
|
|
- name: '甜品',
|
|
|
|
- code: '1' },
|
|
|
|
-
|
|
|
|
- {
|
|
|
|
- icon: '',
|
|
|
|
- name: '饮料',
|
|
|
|
- code: '2' }];
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- that.$set(that, "typeList", type);
|
|
|
|
- // 查询产品
|
|
|
|
- that.$set(that, "tags", type[0]);
|
|
|
|
- that.searchMarket();case 5:case "end":return _context2.stop();}}}, _callee2);}))();
|
|
|
|
|
|
+ search: function search() {var _this = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee2() {var that, res, data;return _regenerator.default.wrap(function _callee2$(_context2) {while (1) {switch (_context2.prev = _context2.next) {case 0:
|
|
|
|
+ that = _this;_context2.next = 3;return (
|
|
|
|
+
|
|
|
|
+ that.$api("shop", 'GET', {}));case 3:res = _context2.sent;
|
|
|
|
+ if (res.errcode == '0') {
|
|
|
|
+ data = res.data[0];
|
|
|
|
+ data.table = '1';
|
|
|
|
+ that.$set(that, "shopInfo", data);
|
|
|
|
+ }_context2.next = 7;return (
|
|
|
|
+ that.$api("goodsTags", 'GET', {}));case 7:res = _context2.sent;
|
|
|
|
+ if (res.errcode == '0') {
|
|
|
|
+ that.$set(that, "typeList", res.data);
|
|
|
|
+ // 查询产品
|
|
|
|
+ that.$set(that.tags, "code", res.data[0].code);
|
|
|
|
+ that.searchMarket();
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: res.errmsg,
|
|
|
|
+ icon: 'none' });
|
|
|
|
+
|
|
|
|
+ }case 9:case "end":return _context2.stop();}}}, _callee2);}))();
|
|
},
|
|
},
|
|
// 查询产品
|
|
// 查询产品
|
|
- searchMarket: function searchMarket() {var _this2 = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee3() {var that, list;return _regenerator.default.wrap(function _callee3$(_context3) {while (1) {switch (_context3.prev = _context3.next) {case 0:
|
|
|
|
- that = _this2;
|
|
|
|
- list = that.list.filter(function (i) {return i.code == that.tags.code;});
|
|
|
|
- if (list) that.$set(that, "marketList", list);case 3:case "end":return _context3.stop();}}}, _callee3);}))();
|
|
|
|
|
|
+ searchMarket: function searchMarket() {var _this2 = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee4() {var that, res;return _regenerator.default.wrap(function _callee4$(_context4) {while (1) {switch (_context4.prev = _context4.next) {case 0:
|
|
|
|
+ that = _this2;_context4.next = 3;return (
|
|
|
|
+ that.$api("goods", 'GET', {
|
|
|
|
+ type: that.tags.code }));case 3:res = _context4.sent;
|
|
|
|
+
|
|
|
|
+ if (res.errcode == '0') {
|
|
|
|
+ that.$nextTick( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee3() {var _iterator, _step, val, _iterator2, _step2, s;return _regenerator.default.wrap(function _callee3$(_context3) {while (1) {switch (_context3.prev = _context3.next) {case 0:_iterator = _createForOfIteratorHelper(
|
|
|
|
+ that.buyList);try {for (_iterator.s(); !(_step = _iterator.n()).done;) {val = _step.value;_iterator2 = _createForOfIteratorHelper(
|
|
|
|
+ res.data);try {for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {s = _step2.value;
|
|
|
|
+ if (s._id == val._id) s.num = val.num;
|
|
|
|
+ }} catch (err) {_iterator2.e(err);} finally {_iterator2.f();}
|
|
|
|
+ }} catch (err) {_iterator.e(err);} finally {_iterator.f();}case 2:case "end":return _context3.stop();}}}, _callee3);})));
|
|
|
|
+
|
|
|
|
+ that.$set(that, "marketList", res.data);
|
|
|
|
+ } else {
|
|
|
|
+ uni.showToast({
|
|
|
|
+ title: res.errmsg,
|
|
|
|
+ icon: 'none' });
|
|
|
|
+
|
|
|
|
+ }case 5:case "end":return _context4.stop();}}}, _callee4);}))();
|
|
},
|
|
},
|
|
// 改变数量
|
|
// 改变数量
|
|
- bindChange: function bindChange(e) {var _this3 = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee5() {var that;return _regenerator.default.wrap(function _callee5$(_context5) {while (1) {switch (_context5.prev = _context5.next) {case 0:
|
|
|
|
|
|
+ bindChange: function bindChange(e) {var _this3 = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee6() {var that;return _regenerator.default.wrap(function _callee6$(_context6) {while (1) {switch (_context6.prev = _context6.next) {case 0:
|
|
that = _this3;
|
|
that = _this3;
|
|
- that.$nextTick( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee4() {var list, cart, _iterator, _step, val, _iterator2, _step2, _loop;return _regenerator.default.wrap(function _callee4$(_context4) {while (1) {switch (_context4.prev = _context4.next) {case 0:
|
|
|
|
|
|
+ that.$nextTick( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee5() {var list, cart, _iterator3, _step3, val, _iterator4, _step4, _loop;return _regenerator.default.wrap(function _callee5$(_context5) {while (1) {switch (_context5.prev = _context5.next) {case 0:
|
|
list = that.buyList.find(function (i) {return i._id == e._id;});
|
|
list = that.buyList.find(function (i) {return i._id == e._id;});
|
|
if (list) {
|
|
if (list) {
|
|
if (list.num == 0) {
|
|
if (list.num == 0) {
|
|
cart = that.buyList.filter(function (i) {return i._id !== list._id;});
|
|
cart = that.buyList.filter(function (i) {return i._id !== list._id;});
|
|
if (cart) that.$set(that, "buyList", cart);
|
|
if (cart) that.$set(that, "buyList", cart);
|
|
- } else {_iterator = _createForOfIteratorHelper(
|
|
|
|
- that.buyList);try {for (_iterator.s(); !(_step = _iterator.n()).done;) {val = _step.value;
|
|
|
|
|
|
+ } else {_iterator3 = _createForOfIteratorHelper(
|
|
|
|
+ that.buyList);try {for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {val = _step3.value;
|
|
if (val._id == list._id) val.num = list.num;
|
|
if (val._id == list._id) val.num = list.num;
|
|
- }} catch (err) {_iterator.e(err);} finally {_iterator.f();}
|
|
|
|
|
|
+ }} catch (err) {_iterator3.e(err);} finally {_iterator3.f();}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (e.num != 0) that.buyList.push(e);
|
|
if (e.num != 0) that.buyList.push(e);
|
|
- }_iterator2 = _createForOfIteratorHelper(
|
|
|
|
- that.typeList);try {_loop = function _loop() {var s = _step2.value;
|
|
|
|
|
|
+ }_iterator4 = _createForOfIteratorHelper(
|
|
|
|
+ that.typeList);try {_loop = function _loop() {var s = _step4.value;
|
|
var num = that.buyList.filter(function (i) {return i.code == s.code;});
|
|
var num = that.buyList.filter(function (i) {return i.code == s.code;});
|
|
var buy = num.filter(function (i) {return i.num !== 0;});
|
|
var buy = num.filter(function (i) {return i.num !== 0;});
|
|
- if (buy) s.num = buy.length;};for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {_loop();
|
|
|
|
- }} catch (err) {_iterator2.e(err);} finally {_iterator2.f();}_context4.next = 6;return (
|
|
|
|
- that.countMoney());case 6:case "end":return _context4.stop();}}}, _callee4);})));case 2:case "end":return _context5.stop();}}}, _callee5);}))();
|
|
|
|
|
|
+ if (buy) s.num = buy.length;};for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {_loop();
|
|
|
|
+ }} catch (err) {_iterator4.e(err);} finally {_iterator4.f();}_context5.next = 6;return (
|
|
|
|
+ that.countMoney());case 6:case "end":return _context5.stop();}}}, _callee5);})));case 2:case "end":return _context6.stop();}}}, _callee6);}))();
|
|
|
|
|
|
},
|
|
},
|
|
// 计算总额
|
|
// 计算总额
|
|
@@ -478,11 +403,11 @@ var _default =
|
|
var list = that.buyList.filter(function (i) {return i.num !== 0;});
|
|
var list = that.buyList.filter(function (i) {return i.num !== 0;});
|
|
var totalMoney = 0;
|
|
var totalMoney = 0;
|
|
// 渲染结束执行下面方法
|
|
// 渲染结束执行下面方法
|
|
- that.$nextTick(function () {var _iterator3 = _createForOfIteratorHelper(
|
|
|
|
- list),_step3;try {for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {var val = _step3.value;
|
|
|
|
|
|
+ that.$nextTick(function () {var _iterator5 = _createForOfIteratorHelper(
|
|
|
|
+ list),_step5;try {for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {var val = _step5.value;
|
|
var total = that.$multiply(val.price, val.num);
|
|
var total = that.$multiply(val.price, val.num);
|
|
totalMoney += Number(total);
|
|
totalMoney += Number(total);
|
|
- }} catch (err) {_iterator3.e(err);} finally {_iterator3.f();}
|
|
|
|
|
|
+ }} catch (err) {_iterator5.e(err);} finally {_iterator5.f();}
|
|
that.$set(that.cartNum, "num", list.length);
|
|
that.$set(that.cartNum, "num", list.length);
|
|
that.$set(that.cartNum, "total", totalMoney);
|
|
that.$set(that.cartNum, "total", totalMoney);
|
|
});
|
|
});
|
|
@@ -494,26 +419,38 @@ var _default =
|
|
that.$refs.specShow.open();
|
|
that.$refs.specShow.open();
|
|
},
|
|
},
|
|
// 去购买
|
|
// 去购买
|
|
- toBuy: function toBuy() {
|
|
|
|
- var that = this;
|
|
|
|
- var key = '1';
|
|
|
|
- if (that.buyList.length > 0) {
|
|
|
|
- if (that.id) {
|
|
|
|
- uni.navigateTo({
|
|
|
|
- url: "/pagesHome/order/add?key=".concat(key) });
|
|
|
|
|
|
+ toBuy: function toBuy() {var _this4 = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee7() {var that, res, 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 = 14;break;}if (!
|
|
|
|
+ that.id) {_context7.next = 9;break;}_context7.next = 5;return (
|
|
|
|
+ that.$api("cart/".concat(that.id), 'GET', {}));case 5:res = _context7.sent;
|
|
|
|
+ if (res.errcode == '0') {
|
|
|
|
+ console.log(res.data);
|
|
|
|
+ // uni.navigateTo({
|
|
|
|
+ // url: `/pagesHome/order/add?id=${res.data._id}`
|
|
|
|
+ // })
|
|
|
|
+ }_context7.next = 14;break;case 9:
|
|
|
|
+
|
|
|
|
+ obj = {
|
|
|
|
+ list: that.buyList,
|
|
|
|
+ total: that.cartNum.total,
|
|
|
|
+ table: '63dc9f7de85ec93564c717a0' };_context7.next = 12;return (
|
|
|
|
+
|
|
|
|
+ that.$api("cart", 'POST', obj));case 12:res = _context7.sent;
|
|
|
|
+ if (res.errcode == '0') {
|
|
|
|
+ uni.navigateTo({
|
|
|
|
+ url: "/pagesHome/order/index?id=".concat(res.data._id) });
|
|
|
|
+
|
|
|
|
+ }case 14:case "end":return _context7.stop();}}}, _callee7);}))();
|
|
|
|
|
|
- } else {
|
|
|
|
- uni.navigateTo({
|
|
|
|
- url: "/pagesHome/order/index?key=".concat(key) });
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
- }
|
|
|
|
},
|
|
},
|
|
// 关闭弹框
|
|
// 关闭弹框
|
|
toDelete: function toDelete() {
|
|
toDelete: function toDelete() {
|
|
- var that = this;var _iterator4 = _createForOfIteratorHelper(
|
|
|
|
- that.typeList),_step4;try {for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {var val = _step4.value;val.num = 0;}} catch (err) {_iterator4.e(err);} finally {_iterator4.f();}
|
|
|
|
|
|
+ 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();}
|
|
that.$set(that, "buyList", []);
|
|
that.$set(that, "buyList", []);
|
|
that.$set(that.cartNum, "num", 0);
|
|
that.$set(that.cartNum, "num", 0);
|
|
that.$set(that.cartNum, "total", 0);
|
|
that.$set(that.cartNum, "total", 0);
|
|
@@ -537,7 +474,7 @@ var _default =
|
|
var that = this;
|
|
var that = this;
|
|
that.$set(that, "marketList", []);
|
|
that.$set(that, "marketList", []);
|
|
that.$set(that, "active", index);
|
|
that.$set(that, "active", index);
|
|
- that.$set(that, "tags", e);
|
|
|
|
|
|
+ that.$set(that.tags, "code", e.code);
|
|
that.searchMarket();
|
|
that.searchMarket();
|
|
} } };exports.default = _default;
|
|
} } };exports.default = _default;
|
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 1)["default"]))
|
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 1)["default"]))
|