|
@@ -269,6 +269,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
//
|
|
|
//
|
|
|
//
|
|
|
+//
|
|
|
+//
|
|
|
var _default =
|
|
|
{
|
|
|
data: function data() {
|
|
@@ -285,11 +287,12 @@ var _default =
|
|
|
popupShow: '1',
|
|
|
// 规格数组
|
|
|
specList: [],
|
|
|
- specInfo: {},
|
|
|
+ specsInfo: {},
|
|
|
// 规格信息
|
|
|
is_specs: 0,
|
|
|
// 购买数量
|
|
|
buy_num: 1,
|
|
|
+ is_zero: false,
|
|
|
// 底部商品导航
|
|
|
options: [{
|
|
|
icon: 'shop',
|
|
@@ -315,6 +318,10 @@ var _default =
|
|
|
that.searchToken();_context.next = 5;return (
|
|
|
that.search());case 5:case "end":return _context.stop();}}}, _callee, this);}));function onLoad(_x) {return _onLoad.apply(this, arguments);}return onLoad;}(),
|
|
|
|
|
|
+ onShow: function onShow() {
|
|
|
+ var that = this;
|
|
|
+ that.searchOther();
|
|
|
+ },
|
|
|
methods: {
|
|
|
searchToken: function searchToken() {
|
|
|
var that = this;
|
|
@@ -345,7 +352,7 @@ var _default =
|
|
|
});
|
|
|
if (data) {
|
|
|
res.data.money = data[0].money;
|
|
|
- that.$set(that, "specInfo", data[0]);
|
|
|
+ that.$set(that, "specsInfo", data[0]);
|
|
|
that.$set(that, "specList", data);
|
|
|
}
|
|
|
that.$set(that, "info", res.data);
|
|
@@ -371,13 +378,65 @@ var _default =
|
|
|
that.$refs.popup.open();
|
|
|
},
|
|
|
// 加入购物车
|
|
|
- toMarket: function toMarket(e) {return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee3() {return _regenerator.default.wrap(function _callee3$(_context3) {while (1) {switch (_context3.prev = _context3.next) {case 0:case "end":return _context3.stop();}}}, _callee3);}))();},
|
|
|
+ toMarket: function toMarket(e) {var _this2 = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee3() {var that, user, info, specsInfo, res, obj;return _regenerator.default.wrap(function _callee3$(_context3) {while (1) {switch (_context3.prev = _context3.next) {case 0:
|
|
|
+ that = _this2;
|
|
|
+ user = that.user;
|
|
|
+ info = that.info;
|
|
|
+ specsInfo = that.specsInfo;if (!(
|
|
|
+ user && user._id)) {_context3.next = 12;break;}
|
|
|
+
|
|
|
+ obj = {
|
|
|
+ user: user._id,
|
|
|
+ supplier_id: info.supplier_id,
|
|
|
+ spec: specsInfo._id,
|
|
|
+ goods: info._id,
|
|
|
+ num: that.buy_num };_context3.next = 8;return (
|
|
|
+
|
|
|
+ that.$api("/Cart", 'POST', obj));case 8:res = _context3.sent;
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ uni.showToast({
|
|
|
+ title: "\u52A0\u5165\u8D2D\u7269\u8F66\u6210\u529F",
|
|
|
+ icon: 'none' });
|
|
|
+
|
|
|
+ that.toClose();
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: res.errmsg,
|
|
|
+ icon: 'none' });
|
|
|
+
|
|
|
+ }_context3.next = 13;break;case 12:
|
|
|
+
|
|
|
+ uni.navigateTo({
|
|
|
+ url: "/pages/login/index" });case 13:case "end":return _context3.stop();}}}, _callee3);}))();
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
// 加数量
|
|
|
- toCount: function toCount(e) {return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee4() {return _regenerator.default.wrap(function _callee4$(_context4) {while (1) {switch (_context4.prev = _context4.next) {case 0:case "end":return _context4.stop();}}}, _callee4);}))();},
|
|
|
+ toCount: function toCount(e) {var _this3 = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee4() {var that;return _regenerator.default.wrap(function _callee4$(_context4) {while (1) {switch (_context4.prev = _context4.next) {case 0:
|
|
|
+ that = _this3;
|
|
|
+ that.$set(that, "buy_num", e);case 2:case "end":return _context4.stop();}}}, _callee4);}))();
|
|
|
+ },
|
|
|
// 选择规格
|
|
|
- toSpecs: function toSpecs(e) {return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee5() {return _regenerator.default.wrap(function _callee5$(_context5) {while (1) {switch (_context5.prev = _context5.next) {case 0:case "end":return _context5.stop();}}}, _callee5);}))();},
|
|
|
+ toSpecs: function toSpecs(e) {var _this4 = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee5() {var that, specs, dataIndex;return _regenerator.default.wrap(function _callee5$(_context5) {while (1) {switch (_context5.prev = _context5.next) {case 0:
|
|
|
+ that = _this4;
|
|
|
+ specs = that.specList;
|
|
|
+ dataIndex = specs.findIndex(function (i) {return i._id == e._id;});
|
|
|
+ that.$set(that, "is_specs", dataIndex);
|
|
|
+ that.$set(that, "specsInfo", e);
|
|
|
+ that.$set(that, "buy_num", 1);
|
|
|
+ if (e.num <= 0) that.$set(that, "is_zero", true);else
|
|
|
+ that.$set(that, "is_zero", false);case 7:case "end":return _context5.stop();}}}, _callee5);}))();
|
|
|
+ },
|
|
|
+ searchOther: function searchOther() {var _this5 = this;return _asyncToGenerator( /*#__PURE__*/_regenerator.default.mark(function _callee6() {var that, res;return _regenerator.default.wrap(function _callee6$(_context6) {while (1) {switch (_context6.prev = _context6.next) {case 0:
|
|
|
+ that = _this5;_context6.next = 3;return (
|
|
|
+ that.$api("/Cart/num", 'GET', {
|
|
|
+ user: that.user._id }));case 3:res = _context6.sent;
|
|
|
+
|
|
|
+ if (res.errcode == '0') that.$set(that.options[1], "info", res.data);case 5:case "end":return _context6.stop();}}}, _callee6);}))();
|
|
|
+ },
|
|
|
toClose: function toClose() {
|
|
|
var that = this;
|
|
|
+ that.searchOther();
|
|
|
that.$refs.popup.close();
|
|
|
} } };exports.default = _default;
|
|
|
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 1)["default"]))
|