mirror of
https://github.com/sergeyyarkov/digital-store.git
synced 2026-10-11 18:29:11 +03:00
fixed render and response
This commit is contained in:
parent
d9f3d3ef5f
commit
1edfb84bc8
@ -53,7 +53,7 @@ const routes = {
|
||||
const dbo = db.db('digital_store');
|
||||
dbo.collection('storeInfo').find().toArray((err, result) => {
|
||||
if (err) throw err;
|
||||
res.send(result);
|
||||
res.send(result[0].items);
|
||||
db.close();
|
||||
})
|
||||
});
|
||||
|
||||
6
dist/public/img/service-icons/uplay.svg
vendored
Normal file
6
dist/public/img/service-icons/uplay.svg
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="50pt" height="50pt" viewBox="0 0 50 50" version="1.1">
|
||||
<g id="surface7">
|
||||
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(20.392157%,59.607843%,85.882353%);fill-opacity:1;" d="M 19.5 0 C 17.570312 0 16 1.570312 16 3.5 C 16 5.429688 17.570312 7 19.5 7 C 21.429688 7 23 5.429688 23 3.5 C 23 1.570312 21.429688 0 19.5 0 Z M 7.59375 2 C 3.261719 2 0 5.550781 0 10.25 C 0 14.527344 4.402344 16.5 7.375 16.5 C 10.441406 16.5 15 14.429688 15 8.65625 C 15 3.398438 10.152344 2 7.59375 2 Z M 31.3125 5.03125 C 18.890625 5.03125 8.8125 16.082031 8.8125 29.65625 C 8.8125 41.664062 23.785156 49 31.9375 49 C 40.46875 49 50 38.972656 50 25.53125 C 50 12.53125 35.816406 5.03125 31.3125 5.03125 Z M 18 19 L 23 19 L 23 30.5 C 23 31.328125 23.671875 32 24.5 32 L 33.5 32 C 34.328125 32 35 31.328125 35 30.5 L 35 19 L 40 19 L 40 37 L 24.5 37 C 20.910156 37 18 34.089844 18 30.5 Z M 18 19 "/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1021 B |
4
dist/public/js/bundle.js
vendored
4
dist/public/js/bundle.js
vendored
@ -3918,7 +3918,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) *
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"ItemsComponent\", function() { return ItemsComponent; });\n/* harmony import */ var _core_component__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../core/component */ \"./src/js/core/component.js\");\n/* harmony import */ var _services_api_service__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../services/api.service */ \"./src/js/services/api.service.js\");\n/* harmony import */ var _templates_item_template__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../templates/item.template */ \"./src/js/templates/item.template.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n\n\n\nvar ItemsComponent =\n/*#__PURE__*/\nfunction (_Component) {\n _inherits(ItemsComponent, _Component);\n\n function ItemsComponent(id, _ref) {\n var _this;\n\n var loader = _ref.loader;\n\n _classCallCheck(this, ItemsComponent);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(ItemsComponent).call(this, id));\n _this.loader = loader;\n\n _this.loader.show();\n\n return _this;\n }\n\n _createClass(ItemsComponent, [{\n key: \"init\",\n value: function init() {\n var fData, items, categories, html;\n return regeneratorRuntime.async(function init$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n if (!this.$el) {\n _context.next = 9;\n break;\n }\n\n _context.next = 3;\n return regeneratorRuntime.awrap(_services_api_service__WEBPACK_IMPORTED_MODULE_1__[\"apiService\"].getItems());\n\n case 3:\n fData = _context.sent;\n items = fData[0].items;\n categories = Object.keys(items);\n html = Object(_templates_item_template__WEBPACK_IMPORTED_MODULE_2__[\"renderItem\"])(categories, items);\n this.$el.querySelector('#roster').insertAdjacentHTML('afterbegin', html);\n this.loader.hide();\n\n case 9:\n case \"end\":\n return _context.stop();\n }\n }\n }, null, this);\n }\n }]);\n\n return ItemsComponent;\n}(_core_component__WEBPACK_IMPORTED_MODULE_0__[\"Component\"]);\n\n//# sourceURL=webpack:///./src/js/components/items.component.js?");
|
||||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"ItemsComponent\", function() { return ItemsComponent; });\n/* harmony import */ var _core_component__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../core/component */ \"./src/js/core/component.js\");\n/* harmony import */ var _services_api_service__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../services/api.service */ \"./src/js/services/api.service.js\");\n/* harmony import */ var _templates_item_template__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../templates/item.template */ \"./src/js/templates/item.template.js\");\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } return _assertThisInitialized(self); }\n\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\n\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }\n\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\n\n\n\n\nvar ItemsComponent =\n/*#__PURE__*/\nfunction (_Component) {\n _inherits(ItemsComponent, _Component);\n\n function ItemsComponent(id, _ref) {\n var _this;\n\n var loader = _ref.loader;\n\n _classCallCheck(this, ItemsComponent);\n\n _this = _possibleConstructorReturn(this, _getPrototypeOf(ItemsComponent).call(this, id));\n _this.loader = loader;\n\n _this.loader.show();\n\n return _this;\n }\n\n _createClass(ItemsComponent, [{\n key: \"init\",\n value: function init() {\n var fData, categories, html;\n return regeneratorRuntime.async(function init$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n if (!this.$el) {\n _context.next = 8;\n break;\n }\n\n _context.next = 3;\n return regeneratorRuntime.awrap(_services_api_service__WEBPACK_IMPORTED_MODULE_1__[\"apiService\"].getItems());\n\n case 3:\n fData = _context.sent;\n categories = Object.keys(fData);\n html = Object(_templates_item_template__WEBPACK_IMPORTED_MODULE_2__[\"renderItem\"])(categories, fData);\n this.$el.querySelector('#roster').insertAdjacentHTML('afterbegin', html);\n this.loader.hide();\n\n case 8:\n case \"end\":\n return _context.stop();\n }\n }\n }, null, this);\n }\n }]);\n\n return ItemsComponent;\n}(_core_component__WEBPACK_IMPORTED_MODULE_0__[\"Component\"]);\n\n//# sourceURL=webpack:///./src/js/components/items.component.js?");
|
||||
|
||||
/***/ }),
|
||||
|
||||
@ -3978,7 +3978,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) *
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"renderItem\", function() { return renderItem; });\nfunction renderItem(categories, items) {\n var html = '';\n categories.forEach(function (category) {\n html += \"<div class=\\\"items-category\\\">\\n <h2 class=\\\"small-title\\\">\".concat(category, \"</h2>\\n </div>\");\n items[category].forEach(function (item) {\n html += \"\\n <div class=\\\"items-list\\\">\\n <div class=\\\"items-list__name\\\">\\n <div class=\\\"list-icon\\\">\\n <img src=\\\"./img/service-icons/\".concat(item.image, \"\\\" alt=\\\"#\\\">\\n </div>\\n <div class=\\\"list-title\\\">\\n <a href=\\\"#\\\">\").concat(item.title, \"</a>\\n </div>\\n </div>\\n <div class=\\\"items-list__info\\\">\\n <div class=\\\"list-count\\\">\\n <span>\").concat(item.count, \" \\u0448\\u0442.</span>\\n </div>\\n <div class=\\\"list-one\\\">\\n <span>\\u0426\\u0435\\u043D\\u0430 \\u0437\\u0430 1 \\u0448\\u0442.</span>\\n </div>\\n <div class=\\\"list-price\\\">\\n <span>\").concat(item.price, \"</span>\\n </div>\\n <div class=\\\"list-buttons\\\">\\n <button class=\\\"btn-small waves-effect waves-light\\\">\\u041A\\u0443\\u043F\\u0438\\u0442\\u044C</button>\\n <button class=\\\"btn-small waves-effect waves-light\\\"><i\\n class=\\\"material-icons\\\">shopping_cart</i></button>\\n </div>\\n </div>\\n </div>\\n \");\n });\n });\n return html;\n} // <div class=\"items-list\">\n// <div class=\"items-list__name\">\n// <div class=\"list-icon\">\n// <img src=\"./img/service-icons/origin.svg\" alt=\"#\">\n// </div>\n// <div class=\"list-title\">\n// <a href=\"#\">Cs:go(prime) + открыта тп + инв. 901руб Cs:go(prime) + открыта\n// тп + инв. 901руб. .</a>\n// </div>\n// </div>\n// <div class=\"items-list__info\">\n// <div class=\"list-count\">\n// <span>1 шт.</span>\n// </div>\n// <div class=\"list-one\">\n// <span>Цена за 1 шт.</span>\n// </div>\n// <div class=\"list-price\">\n// <span>145.00₽</span>\n// </div>\n// <div class=\"list-buttons\">\n// <button class=\"btn-small waves-effect waves-light\">Купить</button>\n// <button class=\"btn-small waves-effect waves-light\"><i\n// class=\"material-icons\">shopping_cart</i></button>\n// </div>\n// </div>\n// </div>\n\n//# sourceURL=webpack:///./src/js/templates/item.template.js?");
|
||||
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"renderItem\", function() { return renderItem; });\nfunction renderItem(categories, items) {\n var html = '';\n categories.forEach(function (category) {\n html += \"<div class=\\\"items-category\\\">\\n <h2 class=\\\"small-title\\\">\".concat(category, \"</h2>\\n </div>\");\n items[category].forEach(function (item) {\n if (item) {\n html += \"\\n <div class=\\\"items-list\\\">\\n <div class=\\\"items-list__name\\\">\\n <div class=\\\"list-icon\\\">\\n <img src=\\\"./img/service-icons/\".concat(item.image, \"\\\" alt=\\\"#\\\">\\n </div>\\n <div class=\\\"list-title\\\">\\n <a href=\\\"#\\\">\").concat(item.title, \"</a>\\n </div>\\n </div>\\n <div class=\\\"items-list__info\\\">\\n <div class=\\\"list-count\\\">\\n <span>\").concat(item.count, \" \\u0448\\u0442.</span>\\n </div>\\n <div class=\\\"list-one\\\">\\n <span>\\u0426\\u0435\\u043D\\u0430 \\u0437\\u0430 1 \\u0448\\u0442.</span>\\n </div>\\n <div class=\\\"list-price\\\">\\n <span>\").concat(item.price, \"</span>\\n </div>\\n <div class=\\\"list-buttons\\\">\\n <button class=\\\"btn-small waves-effect waves-light\\\">\\u041A\\u0443\\u043F\\u0438\\u0442\\u044C</button>\\n <button class=\\\"btn-small waves-effect waves-light\\\"><i\\n class=\\\"material-icons\\\">shopping_cart</i></button>\\n </div>\\n </div>\\n </div>\\n \");\n } else {\n html += \"\\n <div class=\\\"items-list\\\">\\n <div class=\\\"items-list__name\\\">\\n <div class=\\\"list-title\\\">\\n <span>\\u0412 \\u044D\\u0442\\u043E\\u0439 \\u043A\\u0430\\u0442\\u0435\\u0433\\u043E\\u0440\\u0438\\u0438 \\u043F\\u043E\\u043A\\u0430 \\u0447\\u0442\\u043E \\u043D\\u0435\\u0442\\u0443 \\u0442\\u043E\\u0432\\u0430\\u0440\\u043E\\u0432</span>\\n </div>\\n </div>\\n </div>\\n \";\n }\n });\n });\n return html;\n}\n\n//# sourceURL=webpack:///./src/js/templates/item.template.js?");
|
||||
|
||||
/***/ }),
|
||||
|
||||
|
||||
@ -13,10 +13,9 @@ export class ItemsComponent extends Component {
|
||||
|
||||
if (this.$el) {
|
||||
const fData = await apiService.getItems(),
|
||||
items = fData[0].items,
|
||||
categories = Object.keys(items);
|
||||
categories = Object.keys(fData);
|
||||
|
||||
const html = renderItem(categories, items);
|
||||
const html = renderItem(categories, fData);
|
||||
this.$el.querySelector('#roster').insertAdjacentHTML('afterbegin', html);
|
||||
this.loader.hide();
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -6,64 +6,49 @@ export function renderItem(categories, items) {
|
||||
html += `<div class="items-category">
|
||||
<h2 class="small-title">${category}</h2>
|
||||
</div>`;
|
||||
items[category].forEach(item => {
|
||||
html += `
|
||||
<div class="items-list">
|
||||
<div class="items-list__name">
|
||||
<div class="list-icon">
|
||||
<img src="./img/service-icons/${item.image}" alt="#">
|
||||
items[category].forEach(item => {
|
||||
if (item) {
|
||||
html += `
|
||||
<div class="items-list">
|
||||
<div class="items-list__name">
|
||||
<div class="list-icon">
|
||||
<img src="./img/service-icons/${item.image}" alt="#">
|
||||
</div>
|
||||
<div class="list-title">
|
||||
<a href="#">${item.title}</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-title">
|
||||
<a href="#">${item.title}</a>
|
||||
<div class="items-list__info">
|
||||
<div class="list-count">
|
||||
<span>${item.count} шт.</span>
|
||||
</div>
|
||||
<div class="list-one">
|
||||
<span>Цена за 1 шт.</span>
|
||||
</div>
|
||||
<div class="list-price">
|
||||
<span>${item.price}</span>
|
||||
</div>
|
||||
<div class="list-buttons">
|
||||
<button class="btn-small waves-effect waves-light">Купить</button>
|
||||
<button class="btn-small waves-effect waves-light"><i
|
||||
class="material-icons">shopping_cart</i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="items-list__info">
|
||||
<div class="list-count">
|
||||
<span>${item.count} шт.</span>
|
||||
</div>
|
||||
<div class="list-one">
|
||||
<span>Цена за 1 шт.</span>
|
||||
</div>
|
||||
<div class="list-price">
|
||||
<span>${item.price}</span>
|
||||
</div>
|
||||
<div class="list-buttons">
|
||||
<button class="btn-small waves-effect waves-light">Купить</button>
|
||||
<button class="btn-small waves-effect waves-light"><i
|
||||
class="material-icons">shopping_cart</i></button>
|
||||
`
|
||||
} else {
|
||||
html += `
|
||||
<div class="items-list">
|
||||
<div class="items-list__name">
|
||||
<div class="list-title">
|
||||
<span>В этой категории пока что нету товаров</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`
|
||||
});
|
||||
`
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return html;
|
||||
}
|
||||
// <div class="items-list">
|
||||
// <div class="items-list__name">
|
||||
// <div class="list-icon">
|
||||
// <img src="./img/service-icons/origin.svg" alt="#">
|
||||
// </div>
|
||||
// <div class="list-title">
|
||||
// <a href="#">Cs:go(prime) + открыта тп + инв. 901руб Cs:go(prime) + открыта
|
||||
// тп + инв. 901руб. .</a>
|
||||
// </div>
|
||||
// </div>
|
||||
// <div class="items-list__info">
|
||||
// <div class="list-count">
|
||||
// <span>1 шт.</span>
|
||||
// </div>
|
||||
// <div class="list-one">
|
||||
// <span>Цена за 1 шт.</span>
|
||||
// </div>
|
||||
// <div class="list-price">
|
||||
// <span>145.00₽</span>
|
||||
// </div>
|
||||
// <div class="list-buttons">
|
||||
// <button class="btn-small waves-effect waves-light">Купить</button>
|
||||
// <button class="btn-small waves-effect waves-light"><i
|
||||
// class="material-icons">shopping_cart</i></button>
|
||||
// </div>
|
||||
// </div>
|
||||
// </div>
|
||||
Loading…
x
Reference in New Issue
Block a user