1234567891011121314151617181920212223 |
- ;(function(){function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value;}catch(error){reject(error);return;}if(info.done){resolve(value);}else{Promise.resolve(value).then(_next,_throw);}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value);}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err);}_next(undefined);});};}System.register(['./index-legacy.dda51a96.js','./index.module-legacy.f5231e7e.js','./vendor-legacy.73abbe39.js','./index-legacy.f25f109a7.js','./index-legacy.f25f109a8.js','./index-legacy.f25f109a11.js','./index-legacy.f25f109a4.js','./index-legacy.f25f109a9.js','./index-legacy.f25f109a12.js','./index-legacy.0533982c.js','./index-legacy.4b2d517a.js','./cart-legacy.e8d257f5.js','./shop-mall-legacy.9b596ca0.js'],function(exports){'use strict';var ColHeader,styles,defineComponent,Toast,Dialog,createVNode,CheckboxGroup,Checkbox,Card,Stepper,Image,isVNode,SubmitBar,createTextVNode,Fragment,iconSellOut,request,moneyFormat,ColResult,formateAttr,getCartCount;return{setters:[function(module){ColHeader=module.C;},function(module){styles=module.s;},function(module){defineComponent=module.d;Toast=module.T;Dialog=module.D;createVNode=module.b;CheckboxGroup=module.a2;Checkbox=module.G;Card=module.a3;Stepper=module.Y;Image=module.I;isVNode=module.v;SubmitBar=module.a0;createTextVNode=module.j;Fragment=module.F;},function(){},function(){},function(){},function(){},function(){},function(){},function(module){iconSellOut=module.i;},function(module){request=module.r;moneyFormat=module.m;ColResult=module.C;},function(module){formateAttr=module.f;},function(module){getCartCount=module.g;}],execute:function execute(){function _isSlot(s){return typeof s==='function'||Object.prototype.toString.call(s)==='[object Object]'&&!isVNode(s);}var index=exports('default',defineComponent({name:'cart',data:function data(){return{loading:true,dataShow:false,isManage:false,cartList:[],selectItems:[]};},computed:{checkAll:function checkAll(){var selectLen=this.selectItems.length;var cartLen=this.cartList.length;if(!cartLen)return false;return selectLen===cartLen;},len:function len(){var n=this.selectItems.length;return n;},totalPrice:function totalPrice(){var price=0;var items=this.selectItems;this.cartList.forEach(function(n){if(items.includes(n.id)&&typeof n.price==='number'){price+=n.price*n.quantity;}});return price*100;}},mounted:function mounted(){this.getCartList();},methods:{getCartList:function getCartList(){var _this=this;return _asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee(){var _yield$request$get,code,data;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0:_this.loading=true;_this.cartList=[];_context.prev=2;_context.next=5;return request.get('/api-mall-portal/cart/list');case 5:_yield$request$get=_context.sent;code=_yield$request$get.code;data=_yield$request$get.data;if(code===200){_this.cartList=data.map(function(n){return n;});}_this.$nextTick(function(){setTimeout(function(){_this.cartList=data.map(function(n){n.stock=n.stock-n.lockStock;n.stock=n.stock<=0?0:n.stock;return n;});},0);});_context.next=14;break;case 12:_context.prev=12;_context.t0=_context["catch"](2);case 14:_this.dataShow=true;_this.loading=false;case 16:case"end":return _context.stop();}}},_callee,null,[[2,12]]);}))();},setCheckAll:function setCheckAll(){var _this2=this;var selectItems=[];if(!this.checkAll){this.cartList.forEach(function(n){if(!_this2.isManage){if(n.stock>0){selectItems.push(n.id);}}else{selectItems.push(n.id);}});}this.selectItems=selectItems;},setCartItem:function setCartItem(item){return _asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee2(){var _yield$request$get2,code,data;return regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:_context2.prev=0;_context2.next=3;return request.get('/api-mall-portal/cart/update/quantity',{params:{id:item.id,quantity:item.quantity}});case 3:_yield$request$get2=_context2.sent;code=_yield$request$get2.code;data=_yield$request$get2.data;item.stock=data;if(item.quantity>data){item.quantity=data;setTimeout(function(){Toast('库存不足');},500);}_context2.next=12;break;case 10:_context2.prev=10;_context2.t0=_context2["catch"](0);case 12:case"end":return _context2.stop();}}},_callee2,null,[[0,10]]);}))();},onChecked:function onChecked(id){var items=this.selectItems;if(items.includes(id)){items.splice(items.indexOf(id),1);}else{items.push(id);}this.selectItems=items;},onDeleteCartItem:function onDeleteCartItem(){var _this3=this;return _asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee4(){return regeneratorRuntime.wrap(function _callee4$(_context4){while(1){switch(_context4.prev=_context4.next){case 0:Dialog.confirm({message:'是否确认删除选中的商品?',confirmButtonColor:'var(--van-primary)'}).then(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee3(){var ids,_yield$request$post,code,data;return regeneratorRuntime.wrap(function _callee3$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:ids=_this3.selectItems.join(',');_context3.prev=1;_context3.next=4;return request.post('/api-mall-portal/cart/delete?ids='+ids);case 4:_yield$request$post=_context3.sent;code=_yield$request$post.code;data=_yield$request$post.data;if(code===200){_this3.getCartList();_this3.selectItems=[];_this3.isManage=false;getCartCount();}_context3.next=12;break;case 10:_context3.prev=10;_context3.t0=_context3["catch"](1);case 12:case"end":return _context3.stop();}}},_callee3,null,[[1,10]]);})));case 1:case"end":return _context4.stop();}}},_callee4);}))();},//生成确认订单
- generateConfirmOrder:function generateConfirmOrder(){var _this4=this;return _asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee5(){return regeneratorRuntime.wrap(function _callee5$(_context5){while(1){switch(_context5.prev=_context5.next){case 0:_this4.$router.push({path:'/cartConfirm',query:{cartIds:_this4.selectItems.join(',')}});// return
- // const ids: number[] = [...this.selectItems]
- // try {
- // let { code, data } = await request.post(
- // '/api-mall-portal/order/generateConfirmOrder',
- // {
- // params: {
- // cartIds: ids.join(',')
- // }
- // }
- // )
- // if (code === 200) {
- // cartConfirm.calcAmount = data.calcAmount
- // cartConfirm.cartPromotionItemList = data.cartPromotionItemList
- // cartConfirm.memberReceiveAddressList = data.memberReceiveAddressList
- // // alert(JSON.stringify(data.memberReceiveAddressList))
- // this.$router.push({
- // path: '/cartConfirm'
- // })
- // }
- // } catch (error) {}
- case 1:case"end":return _context5.stop();}}},_callee5);}))();},gotoShopMall:function gotoShopMall(){this.$router.replace('/');}},render:function render(){var _this5=this;var _slot;return createVNode(Fragment,null,[this.dataShow?createVNode("div",null,[createVNode(ColHeader,{"onClickRight":function onClickRight(){_this5.isManage=!_this5.isManage;if(!_this5.isManage){_this5.cartList.forEach(function(n){if(n.stock<=0){_this5.selectItems=_this5.selectItems.filter(function(item){return item!=n.id;});}});}}},{right:function right(){return createVNode("span",{"class":styles.rightText},[_this5.isManage?'完成':'管理']);}}),createVNode("div",{"class":[styles.cartBox]},[this.cartList.length?createVNode(CheckboxGroup,{"modelValue":this.selectItems,"onUpdate:modelValue":function onUpdateModelValue($event){return _this5.selectItems=$event;}},_isSlot(_slot=this.cartList.map(function(item){return createVNode("div",{"class":styles.cartItem},[createVNode(Checkbox,{"name":item.id,"disabled":item.stock<=0&&!_this5.isManage},{default:function _default(){return[createVNode(Card,{"price":moneyFormat(item.price),"desc":formateAttr(item.productAttr),"title":item.productName,"thumb":item.productPic},{num:function num(){return createVNode(Stepper,{"modelValue":item.quantity,"onUpdate:modelValue":function onUpdateModelValue($event){return item.quantity=$event;},"onClick":function onClick(e){e.stopPropagation();},"onChange":function onChange(){console.log(1);if(item.quantity){_this5.setCartItem(item);}},"inputWidth":"50px","buttonSize":"24px","min":1,"max":item.stock>200?200:item.stock,"integer":true},null);},thumb:function thumb(){return createVNode("div",null,[createVNode(Image,{"src":item.productPic},null),item.stock<=0&&createVNode("div",{"class":styles.sellOut},[createVNode(Image,{"src":iconSellOut,"fit":"cover","class":styles.sellOutImg},null)])]);}})];}})]);}))?_slot:{default:function _default(){return[_slot];}}):null,!this.loading&&!this.cartList.length&&createVNode(ColResult,{"tips":"购物车空空如也","buttonText":"去商城逛逛","classImgSize":"GOODS","type":"goods","onClick":function onClick(){return _this5.gotoShopMall();}},null),createVNode("div",{"style":{height:'var(--van-submit-bar-height)'}},null),this.isManage?createVNode("div",{"class":styles.delete},[createVNode(SubmitBar,{"buttonText":"删除","buttonColor":"var(--van-primary)","disabled":this.len===0,"safeAreaInsetBottom":false,"onSubmit":function onSubmit(){return _this5.onDeleteCartItem();}},{default:function _default(){return[createVNode(Checkbox,{"modelValue":_this5.checkAll,"onClick":function onClick(value){return _this5.setCheckAll();}},{default:function _default(){return[createTextVNode("\u5168\u9009")];}})];}})]):createVNode("div",{"class":styles.submit},[createVNode(SubmitBar,{"price":this.totalPrice,"buttonText":"\u7ED3\u7B97(".concat(this.len,")"),"buttonColor":"var(--van-primary)","safeAreaInsetBottom":false,"disabled":this.len===0,"onSubmit":function onSubmit(){return _this5.generateConfirmOrder();}},{default:function _default(){return[createVNode(Checkbox,{"modelValue":_this5.checkAll,"onClick":function onClick(value){return _this5.setCheckAll();}},{default:function _default(){return[createTextVNode("\u5168\u9009")];}})];}})])])]):null]);}}));}};});})();
|