Files
2025-06-11 10:21:51 +08:00

1 line
5.8 KiB
JavaScript

(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pages/cart/cart"],{3736:function(t,e,c){"use strict";(function(t,e){var n=c("47a9");c("7d57");n(c("3240"));var o=n(c("d06d"));t.__webpack_require_UNI_MP_PLUGIN__=c,e(o.default)}).call(this,c("3223")["default"],c("df3c")["createPage"])},"410a":function(t,e,c){"use strict";var n=c("7c61"),o=c.n(n);o.a},"71ca":function(t,e,c){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n={components:{recommendProduct:function(){c.e("components/recommendProduct/recommendProduct").then(function(){return resolve(c("0f7f"))}.bind(null,c)).catch(c.oe)}},data:function(){return{isloadding:!0,scrollviewHigh:0,loadding:!0,isEdit:!1,tableData:[],arrIds:[],checkedAll:!1,totalPrice:0,totalProduct:0,store_open:1,is_auto:0}},onLoad:function(){},onShow:function(){this.getData(),this.getTabBarLinks()},mounted:function(){this.init()},methods:{init:function(){var e=this;t.getSystemInfo({success:function(t){var c=t.windowWidth/750,n=t.windowHeight-98*c;e.scrollviewHigh=n}})},getData:function(){var e=this;e.isloadding=!0,e._get("order.cart/lists",{},(function(c){var n=t.getStorageSync("TabBar").is_auto&&0!=t.getStorageSync("TabBar").is_auto;e.is_auto=n,e.isloadding=!1,e.tableData=c.data.productList,e.store_open=c.data.store_open,e.tableData.forEach((function(t,e){t.checked=!1})),e.loadding=!1,e._initGoodsChecked()}))},_initGoodsChecked:function(){var t=this,e=this,c=e.getCheckedData(),n=0;e.tableData.forEach((function(t){t.productList.forEach((function(t){n++,t.checked=e.inArray("".concat(t.cart_id),c)}))})),e.totalProduct=n,e.isEdit=!1,e.checkedAll=c.length==e.totalProduct,e.tableData.forEach((function(e,c){t.onUpsupChecked(t.tableData,c)})),e.updateTotalPrice()},getCheckedData:function(){var e=t.getStorageSync("CheckedData");return e||[]},checkItem:function(t,e,c){t.checked=!t.checked,this.$set(this.tableData[e].productList,c,t),console.log(this.tableData),this.onUpsupChecked(this.tableData,e),this.onUpdateChecked(),this.updateTotalPrice(),console.log(this.getCheckedData().length),this.checkedAll=this.getCheckedData().length==this.totalProduct},onUpsupChecked:function(t,e){for(var c=!0,n=0;n<t[e].productList.length;n++)t[e].productList[n].checked||(c=!1);this.$set(t[e],"checked",c),console.log("item====="+c)},onUpdateChecked:function(){var e=[];this.tableData.forEach((function(t){t.productList.forEach((function(t){1==t.checked&&e.push("".concat(t.cart_id))}))})),console.log(e),t.setStorageSync("CheckedData",e)},checkStprItem:function(t,e){console.log(t),t.checked=!t.checked,t.productList.forEach((function(e,c){e.checked=t.checked})),this.updateTotalPrice(),this.onUpdateChecked(),console.log(this.getCheckedData().length),this.checkedAll=this.getCheckedData().length==this.totalProduct},onCheckedAll:function(){var t=this,e=this;e.checkedAll=!e.checkedAll,e.tableData.forEach((function(c){t.$set(c,"checked",e.checkedAll),c.productList.forEach((function(t){t.checked=e.checkedAll}))})),e.updateTotalPrice(),e.onUpdateChecked()},updateTotalPrice:function(){for(var t=0,e=this.tableData,c=0;c<e.length;c++)for(var n=0;n<e[c].productList.length;n++)1==e[c].productList[n]["checked"]&&(t+=e[c].productList[n]["total_num"]*e[c].productList[n]["product_price"]);this.totalPrice=t.toFixed(2)},Submit:function(){var e=this.getCheckedIds();if(0==e.length)return t.showToast({title:"请选择商品",icon:"none"}),!1;this.gotoPage("/pages/order/confirm-order?order_type=cart&cart_ids="+e)},addFunc:function(e){var c=this,n=e.product_id,o=e.spec_sku_id;t.showLoading({title:"加载中"}),c._post("order.cart/add",{product_id:n,spec_sku_id:o,total_num:1},(function(e){t.hideLoading(),c.loadding=!1,c.getData()}),(function(){c.loadding=!1}))},reduceFunc:function(e){var c=this,n=e.product_id,o=e.spec_sku_id;e.total_num<=1||(t.showLoading({title:"加载中"}),c._post("order.cart/sub",{product_id:n,spec_sku_id:o},(function(e){c.loadding=!1,t.hideLoading(),c.getData()}),(function(){c.loadding=!1})))},onDelete:function(){var e=this,c=e.getCheckedIds();if(!c.length)return e.showError("您还没有选择商品"),!1;t.showModal({title:"提示",content:"您确定要移除选择的商品吗?",success:function(t){t.confirm&&e._post("order.cart/delete",{cart_id:c},(function(t){e.getData(),e.onDeleteEvent(c)}))}})},getCheckedIds:function(){var t=[];return this.tableData.forEach((function(e){e.productList.forEach((function(e){1==e.checked&&t.push("".concat(e.cart_id))}))})),t},onDeleteEvent:function(t){var e=this;return t.forEach((function(t){e.tableData.forEach((function(c,n){t=="".concat(c.cart_id)&&e.tableData.splice(n,1)}))})),e.$nextTick((function(){e.onUpdateChecked()})),!0},inArray:function(t,e){for(var c in e)if(e[c]==t)return!0;return!1},gotoShop:function(){this.gotoPage("/pages/index/index")}}};e.default=n}).call(this,c("df3c")["default"])},"7c61":function(t,e,c){},b6e6:function(t,e,c){"use strict";c.r(e);var n=c("71ca"),o=c.n(n);for(var a in n)["default"].indexOf(a)<0&&function(t){c.d(e,t,(function(){return n[t]}))}(a);e["default"]=o.a},bf58:function(t,e,c){"use strict";c.d(e,"b",(function(){return o})),c.d(e,"c",(function(){return a})),c.d(e,"a",(function(){return n}));var n={recommendProduct:function(){return c.e("components/recommendProduct/recommendProduct").then(c.bind(null,"0f7f"))}},o=function(){var t=this,e=t.$createElement,c=(t._self._c,t.theme()||""),n=t.theme(),o=t.loadding?null:t.tableData.length,a=t.loadding?null:t.tableData.length,i=t.loadding?null:t.tableData.length;t._isMounted||(t.e0=function(e){t.isEdit=!t.isEdit}),t.$mp.data=Object.assign({},{$root:{m0:c,m1:n,g0:o,g1:a,g2:i}})},a=[]},d06d:function(t,e,c){"use strict";c.r(e);var n=c("bf58"),o=c("b6e6");for(var a in o)["default"].indexOf(a)<0&&function(t){c.d(e,t,(function(){return o[t]}))}(a);c("410a");var i=c("828b"),d=Object(i["a"])(o["default"],n["b"],n["c"],!1,null,"6d95e5ef",null,!1,n["a"],void 0);e["default"]=d.exports}},[["3736","common/runtime","common/vendor"]]]);