1 line
6.1 KiB
JavaScript
1 line
6.1 KiB
JavaScript
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pagesMall/cart/index"],{"7aa4":function(t,e,n){"use strict";var o=n("e831"),i=n.n(o);i.a},"7d07":function(t,e,n){"use strict";(function(t){var o=n("47a9");Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=o(n("7ca3")),r=n("8f59");function a(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,o)}return n}function s(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?a(Object(n),!0).forEach((function(e){(0,i.default)(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var c={components:{mallCart:function(){n.e("pagesMall/component/mall/cart").then(function(){return resolve(n("bd13"))}.bind(null,n)).catch(n.oe)},quantityModal:function(){n.e("pagesMall/component/modal/quantity").then(function(){return resolve(n("2570"))}.bind(null,n)).catch(n.oe)}},data:function(){return{pageShow:!1,loadEnd:!1,cartList:[],allSelected:!1}},computed:s(s({},(0,r.mapState)({themeColor:function(t){return t.app.themeColor}})),{},{totalPrice:function(){var t=this.cartList.filter((function(t){return t.selected})).reduce((function(t,e){return t+parseFloat(e.price)*parseInt(e.number)}),0);return parseFloat(t).toFixed(2)},selectedList:function(){return this.cartList.filter((function(t){return t.selected}))}}),watch:{cartList:{handler:function(){this.allSelected=this.cartList.every((function(t){return t.selected}))},immediate:!0,deep:!0}},onLoad:function(){var e=this;t.getStorageSync("token")?(t.showLoading({title:"加载中"}),this.getCartList((function(){e.loadEnd=!0,t.hideLoading()}))):this.loadEnd=!0},onShow:function(){this.loadEnd&&t.getStorageSync("token")&&this.getCartList()},onPullDownRefresh:function(){t.getStorageSync("token")?this.getCartList((function(){t.stopPullDownRefresh()})):t.stopPullDownRefresh()},methods:{pageChange:function(t){this.pageShow=t},getCartList:function(e){var n=this;this.$util.request("mall.cartList").then((function(o){if(e&&e(),1==o.code){var i=o.data||[];i.length&&n.selectedList.length&&i.forEach((function(t){n.selectedList.some((function(e){return e.id===t.id}))&&n.$set(t,"selected",!0)})),n.cartList=i}else t.showToast({title:o.msg,icon:"none"})})).catch((function(t){e&&e(),console.error("获取购物车列表",t)}))},toShopping:function(){this.$util.toPage({mode:1,path:"/pages/mall/index"})},changeNumber:function(t,e){var n=this,o=this.cartList[t];if(1==e){if(!(parseInt(o.number)>1))return void this.handleDelete(o.id);o.number=parseInt(o.number)-1}else if(2==e)o.number=parseInt(o.number)+1;else if(3==e)return void this.$refs.quantityModal.open(o.number,t);this.updateCartNumber(o,(function(){n.$set(n.cartList,t,o)}))},changeQuantity:function(t,e){var n=this,o=this.cartList[e];o.number=t,this.updateCartNumber(o,(function(){n.$set(n.cartList,e,o)}))},updateCartNumber:function(e,n){t.showLoading({title:"加载中",mask:!0}),this.$util.request("mall.updateCartNumber",{goods_id:e.id,number:e.number}).then((function(e){t.hideLoading(),1==e.code?n&&n():t.showToast({title:e.msg,icon:"none"})})).catch((function(e){t.hideLoading(),console.error("更新购物车商品数量",e)}))},handleDelete:function(e){var n=this;e?t.showModal({content:"确认删除该商品吗?",confirmColor:this.themeColor,success:function(t){t.confirm&&n.deleteEvent(e)}}):this.selectedList.length?t.showModal({content:"确认要删除这".concat(this.selectedList.length,"种商品吗?"),confirmColor:this.themeColor,success:function(t){if(t.confirm){var e=n.selectedList.map((function(t){return t.id}));n.deleteEvent(e.join())}}}):t.showToast({icon:"none",title:"请选择要删除的商品",duration:2e3})},deleteEvent:function(e){var n=this;t.showLoading({title:"加载中",mask:!0}),this.$util.request("mall.deleteCart",{goods_id:e}).then((function(e){t.hideLoading(),1==e.code?(t.showToast({icon:"success",title:"删除成功",duration:2e3}),n.getCartList()):t.showToast({title:e.msg,icon:"none"})})).catch((function(e){t.hideLoading(),console.error("删除事件",e)}))},changeSelect:function(t){var e=this.cartList[t];e.selected=!e.selected,this.$set(this.cartList,t,e)},toggleSelectAll:function(){var t=this;this.cartList.forEach((function(e){t.$set(e,"selected",!t.allSelected)})),this.$forceUpdate()},toSettlement:function(){if(this.selectedList.length){var e=!1;for(var n in this.selectedList)if(2==this.selectedList[n].goods_status){e=!0;break}e?t.showToast({title:"存在已下架商品",icon:"none",duration:2e3}):(this.$store.commit("app/setMallOrder",{isCartItem:!0,list:this.selectedList}),this.$util.toPage({mode:1,path:"/pagesMall/goods/order"}))}else t.showToast({title:"请至少选择一件商品",icon:"none",duration:2e3})}}};e.default=c}).call(this,n("df3c")["default"])},"8c9d":function(t,e,n){"use strict";n.r(e);var o=n("9a49"),i=n("e73a");for(var r in i)["default"].indexOf(r)<0&&function(t){n.d(e,t,(function(){return i[t]}))}(r);n("7aa4");var a=n("828b"),s=Object(a["a"])(i["default"],o["b"],o["c"],!1,null,null,null,!1,o["a"],void 0);e["default"]=s.exports},9562:function(t,e,n){"use strict";(function(t,e){var o=n("47a9");n("aa6c");o(n("3240"));var i=o(n("8c9d"));t.__webpack_require_UNI_MP_PLUGIN__=n,e(i.default)}).call(this,n("3223")["default"],n("df3c")["createPage"])},"9a49":function(t,e,n){"use strict";n.d(e,"b",(function(){return o})),n.d(e,"c",(function(){return i})),n.d(e,"a",(function(){}));var o=function(){var t=this,e=t.$createElement,n=(t._self._c,t.loadEnd?t.cartList.length:null),o=t.loadEnd?t.cartList.length:null,i=t.loadEnd?t.cartList.length:null,r=t.loadEnd&&i?t.selectedList.length:null;t.$mp.data=Object.assign({},{$root:{g0:n,g1:o,g2:i,g3:r}})},i=[]},e73a:function(t,e,n){"use strict";n.r(e);var o=n("7d07"),i=n.n(o);for(var r in o)["default"].indexOf(r)<0&&function(t){n.d(e,t,(function(){return o[t]}))}(r);e["default"]=i.a},e831:function(t,e,n){}},[["9562","common/runtime","common/vendor"]]]); |