yj
2024-12-05 ac3234c308e86f20cc63465573f321561ee00690
1
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pages/cart/cart"],{"32c4":function(t,e,n){"use strict";(function(t){var a=n("47a9");Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var r=a(n("7eb4")),c=a(n("ee10")),i=a(n("7ca3")),o=n("8f59");function u(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,a)}return n}var s={components:{uniNumberBox:function(){n.e("components/uni-number-box").then(function(){return resolve(n("d538"))}.bind(null,n)).catch(n.oe)}},data:function(){return{style:this.$api.style,totalItems:0,total:0,allChecked:!1,empty:!1,cartList:[],loadedItemIds:new Set}},onLoad:function(){},onShow:function(){this.loadData()},computed:function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?u(Object(n),!0).forEach((function(e){(0,i.default)(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}({},(0,o.mapState)(["hasLogin"])),watch:{cartList:function(t){var e=0===t.length;this.empty!==e&&(this.empty=e)}},methods:{loadData:function(){var t=this;return(0,c.default)(r.default.mark((function e(){var n;return r.default.wrap((function(e){while(1)switch(e.prev=e.next){case 0:n=t,n.$api.request("cart","getCartList").then((function(t){t.data.forEach((function(t){t.checked=!0})),n.cartList=t.data,n.calcTotal()}));case 2:case"end":return e.stop()}}),e)})))()},onImageLoad:function(t){this.loadedItemIds.add(t.id),this.$forceUpdate()},onImageError:function(t,e){this[t][e].skuImg="/static/errorImage.jpg"},navToLogin:function(){t.navigateTo({url:"/pages/public/login"})},check:function(t,e){if("item"===t)this.cartList[e].checked=!this.cartList[e].checked;else{var n=!this.allChecked,a=this.cartList;a.forEach((function(t){t.checked=n})),this.allChecked=n}this.calcTotal(t)},numberChange:function(t){var e=this;e.$api.request("cart","updateCartItemNum",{cartId:e.cartList[t.index].id,num:t.number},(function(t){e.$api.msg(t.errmsg)})).then((function(n){e.cartList[t.index].num=t.number,e.calcTotal()}))},deleteCartItem:function(t){var e=this;e.$api.request("cart","removeCartItem",{cartId:e.cartList[t].id}).then((function(n){e.cartList.splice(t,1),e.calcTotal()}))},clearCart:function(){var e=this;t.showModal({content:"清空购物车?",success:function(t){t.confirm&&e.$api.request("cart","removeCartAll").then((function(t){e.cartList=[]}))}})},calcTotal:function(){var t=this,e=t.cartList;if(0!==e.length){var n=0,a=0,r=!0;e.forEach((function(e){!0===e.checked?(a+=e.num,n+=(t.isVip?e.vipPrice:e.price)*e.num):!0===r&&(r=!1)})),this.allChecked=r,this.total=Number(n.toFixed(2)),this.totalItems=a}else t.empty=!0},createOrder:function(){var e=[];this.cartList.forEach((function(t){t.checked&&e.push(t)})),0!==e.length?(console.log(e),this.$api.globalData.skuList=e,t.navigateTo({url:"/pages/order/create?takeway=cart"})):this.$api.msg("您没有选中任何商品")}}};e.default=s}).call(this,n("df3c")["default"])},"52af":function(t,e,n){"use strict";n.r(e);var a=n("5fbe"),r=n("7bff");for(var c in r)["default"].indexOf(c)<0&&function(t){n.d(e,t,(function(){return r[t]}))}(c);n("6faf");var i=n("828b"),o=Object(i["a"])(r["default"],a["b"],a["c"],!1,null,null,null,!1,a["a"],void 0);e["default"]=o.exports},"5fbe":function(t,e,n){"use strict";n.d(e,"b",(function(){return a})),n.d(e,"c",(function(){return r})),n.d(e,"a",(function(){}));var a=function(){var t=this,e=t.$createElement,n=(t._self._c,t.hasLogin&&!0!==t.empty?t.__map(t.cartList,(function(e,n){var a=t.__get_orig(e),r=t.cartList.length,c=t.loadedItemIds.has(e.id),i=t.style(200);return{$orig:a,g0:r,g1:c,m0:i}})):null);t.$mp.data=Object.assign({},{$root:{l0:n}})},r=[]},"6f86":function(t,e,n){"use strict";(function(t,e){var a=n("47a9");n("a346");a(n("3240"));var r=a(n("52af"));t.__webpack_require_UNI_MP_PLUGIN__=n,e(r.default)}).call(this,n("3223")["default"],n("df3c")["createPage"])},"6faf":function(t,e,n){"use strict";var a=n("79f5"),r=n.n(a);r.a},"79f5":function(t,e,n){},"7bff":function(t,e,n){"use strict";n.r(e);var a=n("32c4"),r=n.n(a);for(var c in a)["default"].indexOf(c)<0&&function(t){n.d(e,t,(function(){return a[t]}))}(c);e["default"]=r.a}},[["6f86","common/runtime","common/vendor"]]]);