;(function(){function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable;})),keys.push.apply(keys,symbols);}return keys;}function _objectSpread(target){for(var i=1;i { // if (authPopup.value) { // // 设置是否显示导航栏 0 显示 1 不显示 // postMessage({ api: 'setBarStatus', content: { status: 0 } }) // } else { // postMessage({ api: 'setBarStatus', content: { status: 1 } }) // } // }) // 提交 var _onSubmit=function onSubmit(){var _address$value;if(!((_address$value=address.value)!==null&&_address$value!==void 0&&_address$value.id)){Toast('请选择收货地址');return;}if(!agreeStatus.value){Toast('请先阅读并同意《产品及服务协议》');return;}var users=state.user.data;// 判断是否需要实名认证 if(!(users!==null&&users!==void 0&&users.student.realName)||!(users!==null&&users!==void 0&&users.student.idCardNo)){authPopup.value=true;return;}createOrder();};var router=useRouter();//创建订单 var createOrder=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee3(){var _address$value2;var ids,payAmount,body,_yield$request$post2,code,data;return regeneratorRuntime.wrap(function _callee3$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:ids=cartConfirm.cartPromotionItemList.reduce(function(arr,value){arr.push(value.id);return arr;},[]);payAmount=cartConfirm.calcAmount.payAmount-cartConfirm.calcAmount.promotionAmount;body={cartIds:ids,memberReceiveAddressId:(_address$value2=address.value)===null||_address$value2===void 0?void 0:_address$value2.id,platformType:state.platformType,orderAmount:Number((payAmount>=0?payAmount:0).toFixed(2)),couponId:cartUseAmount.value.couponId,useBalance:cartUseAmount.value.useBalance// 是否使用余额 };_context3.prev=3;_context3.next=6;return request.post('/api-mall-portal/order/generateOrder',{data:body});case 6:_yield$request$post2=_context3.sent;code=_yield$request$post2.code;data=_yield$request$post2.data;if(!(code===200)){_context3.next=15;break;}if(!(data.order.status===1)){_context3.next=13;break;}router.replace({path:"/shopTrade",query:{orderNo:data===null||data===void 0?void 0:data.order.orderSn,id:data===null||data===void 0?void 0:data.order.id}});return _context3.abrupt("return");case 13:paymentPopup.value=true;// orderInfo.orderNo = data?.order.orderSn || '' // orderInfo.actualPrice = data?.order.payAmount || 0 orderInfo.value=data===null||data===void 0?void 0:data.pay;case 15:_context3.next=19;break;case 17:_context3.prev=17;_context3.t0=_context3["catch"](3);case 19:case"end":return _context3.stop();}}},_callee3,null,[[3,17]]);}));return function createOrder(){return _ref3.apply(this,arguments);};}();//认证成功 var onAuthSuccess=function onAuthSuccess(){authPopup.value=false;console.log(state.user.data);_onSubmit();// 实名成功后自动支付 };// { // moneyFormat( // cartConfirm.calcAmount.payAmount - // cartConfirm.calcAmount.promotionAmount // ) // } var needPayPrice=function needPayPrice(){var payAmount=cartConfirm.calcAmount.payAmount-cartConfirm.calcAmount.promotionAmount;var price=Number((payAmount>=0?payAmount:0).toFixed(2));console.log(price);if(cartUseAmount.value.useBalance){price=price-cartUseAmount.value.balance<=0?0:Number((price-cartUseAmount.value.balance).toFixed(2));}return price;};return function(){return createVNode(Fragment,null,[createVNode(ColHeader,null,null),loading.value?null:createVNode("div",null,[cartConfirm.cartPromotionItemList.length?createVNode("div",{"class":styles.cartConfirm},[createVNode("div",{"class":styles.cartConfirmBox},[createVNode(Address,{"item":address.value,"setAddress":setAddress},null)]),createVNode("div",{"style":{marginTop:'20px'},"class":[styles.cartBox,styles.cartConfirmBox]},[createVNode("div",{"class":styles.shopBox},[cartConfirm.cartPromotionItemList.map(function(item){return createVNode("div",{"class":[styles.cartItem],"style":{marginBottom:'10px'}},[createVNode(Card,{"price":moneyFormat(item.price),"desc":formateAttr(item.productAttr),"title":item.productName,"thumb":item.productPic,"num":item.quantity},null)]);})]),createVNode(CellGroup,{"border":true},{default:function _default(){return[createVNode(UseCoupons,{"useSystem":"MALL","typeDetail":"MALLCOUPON","orderAmount":cartConfirm.calcAmount.totalAmount,"onCouponSelect":function onCouponSelect(coupon){console.log(coupon,'coupon');var discountPrice=coupon.map(function(n){return n.faceValue;}).reduce(function(total,n){return total+n;},0);var couponId=coupon.map(function(n){return n.couponCodeId;}).join(',');cartConfirm.calcAmount.promotionAmount=discountPrice;cartUseAmount.value.couponId=couponId;console.log(cartUseAmount,'coupon');// orderInfo.couponId = couponId }},null),createVNode(Cell,{"onClick":function onClick(){console.log(true,'111');cartUseAmount.value.useBalance=!cartUseAmount.value.useBalance;}},{title:"\u4F59\u989D\u652F\u4ED8\uFF08\u5269\u4F59\uFF1A\uFFE5".concat(moneyFormat(cartUseAmount.value.balance),"\uFF09"),'right-icon':function rightIcon(){return createVNode(Checkbox,{"modelValue":cartUseAmount.value.useBalance},null);}}),createVNode(Cell,{"border":false,"title":"总额","value":'¥ '+moneyFormat(cartConfirm.calcAmount.totalAmount)},null)];}})]),createVNode("div",{"class":styles.payProtocol},[createVNode(ColProtocol,{"showHeader":true,"modelValue":agreeStatus.value,"onUpdate:modelValue":function onUpdateModelValue($event){return agreeStatus.value=$event;}},null),createVNode(SubmitBar,{"buttonText":"\u7ED3\u7B97(".concat(cartConfirm.cartPromotionItemList.length,")"),"buttonColor":"var(--van-primary)","disabled":cartConfirm.cartPromotionItemList.length===0,"onSubmit":function onSubmit(){return _onSubmit();}},{default:function _default(){return[createVNode("div",{"class":styles.confirmBottom},[createTextVNode("\u5408\u8BA1"),' ',createVNode("span",{"class":styles['price-des']},[createTextVNode("\xA5"),moneyFormat(needPayPrice())])])];}})]),createVNode("div",{"style":{height:'var(--van-submit-bar-height)'}},null),createVNode(ColPopup,{"modelValue":authPopup.value,"onUpdate:modelValue":function onUpdateModelValue($event){return authPopup.value=$event;}},{default:function _default(){return[createVNode(UserAuth,{"onSuccess":onAuthSuccess},null)];}}),createVNode(Popup,{"show":paymentPopup.value,"closeOnClickOverlay":false,"position":"bottom","round":true,"closeOnPopstate":true,"safeAreaInsetBottom":true,"style":{minHeight:'30%'}},{default:function _default(){return[createVNode(Payment,{"paymentWay":paymentWay.value,"modelValue":paymentPopup.value,"onUpdate:modelValue":function onUpdateModelValue($event){return paymentPopup.value=$event;},"orderInfo":orderInfo.value,"paymentType":"goodsPay","onBackOut":function onBackOut(){return paymentPopup.value=false;}},null)];}})]):createVNode(ColResult,{"buttonText":"去购物车","onClick":function onClick(){router.push({path:'/cart'});}},null)])]);};}}));}};});})();