;(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;iarr.length)len=arr.length;for(var i=0,arr2=new Array(len);i 0 && result.pageNo === 1) return // this.list = result.rows || [] // // 处理可用优惠券是否支付使用 // this.list.forEach((item: any) => { // item.checked = false // // 如果使用金额大于订单金额则优惠券不可用 // if (item.useLimit > this.orderAmount) { // item.disabled = true // } else { // item.disabled = false // } // // 处理显示已选择的优惠券 // this.useCoupon.forEach((coupon: any) => { // if (item.couponIssueId === coupon.couponIssueId) { // item.checked = true // } // }) // }) // // 初始化排序 // const canUsable = this.list.filter((list: any) => !list.disabled) // const canUsed = this.list.filter((list: any) => list.disabled) // this.list = [...canUsable, ...canUsed] // this.calcCoupon() // } catch { // // // } // }, onSubmit:function onSubmit(){// 返回选中的优惠券 this.$emit('submit',this.list.filter(function(list){return list.checked;}));this.list.forEach(function(item){item.checked=false;});},onSelect:function onSelect(item){item.checked=!item.checked;this.calcCoupon();},calcCoupon:function calcCoupon(){// 计算优惠券 // 已使用的优惠券 var useList=this.list.filter(function(list){return list.checked;});var limitCount=useList.map(function(list){return Number(list.useLimit||0);});var usePrice=limitCount.length>0?limitCount.reduce(function(sum,list){return sum+list;}):0;// 使用优惠券后,可判断的金额 var useLastAmount=this.orderAmount-usePrice;// 判断使用优惠券之后还有没有其它优惠券可用 this.list.forEach(function(item){if(Number(item.useLimit)>useLastAmount&&!item.checked){item.disabled=true;}else{item.disabled=false;}});}},render:function render(){var _this3=this;return createVNode("div",{"class":styles.choiceCoupon},[createVNode("div",{"class":styles.couponTitle},[createVNode("span",null,[createTextVNode("\u4F18\u60E0\u5238")]),createVNode("i",{"class":styles.iconClose,"onClick":function onClick(){return _this3.$emit('close');}},null)]),createVNode("div",{"class":styles.couponContent},[!this.dataLoading?createVNode(Fragment,null,[this.list.length>0?createVNode(Fragment,null,[this.list.map(function(item){return createVNode(Item,{"item":item,"isSelect":true,"onClick":_this3.onSelect},null);})]):createVNode(ColResult,{"btnStatus":false,"tips":"暂无优惠券","classImgSize":"SMALL"},null)]):createVNode(Loading,{"size":48,"color":"#01C1B5","vertical":true,"style":{height:'100%',justifyContent:'center'}},{default:function _default(){return[createTextVNode("\u52A0\u8F7D\u4E2D...")];}})]),createVNode("div",{"class":[styles.couponFooter,'van-hairline--top']},[createVNode("div",{"class":styles.couponSelectText},[createTextVNode("\u5DF2\u9009"),createVNode("span",null,[this.useLength]),createTextVNode("\u5F20")]),createVNode(Button,{"type":"primary","round":true,"style":{minWidth:'105px',fontSize:'16px'},"onClick":this.onSubmit},{default:function _default(){return[createTextVNode("\u786E\u5B9A")];}})])]);}});/* * 订单类型对应优惠券类型 */var couponEnum={UNIVERSAL:'UNIVERSAL',VIP:'VIP',PINAO_ROOM:'PIANO',GOODS:'MALL',MUSIC:'MUSIC',PRACTICE:'SPARRING',LIVE:'LIVE',VIDEO:'VIDEO'};var UseCoupon=defineComponent({name:'use-conpon',props:{disabled:{type:Boolean,default:false},orderAmount:{type:Number,default:0},orderType:{type:String,default:''},discountPrice:{// 优惠券使用金额 type:Number,default:0}},emits:['couponSelect'],data:function data(){return{popupStatus:false,popupLoading:false,useCouponList:[],useCouponLoading:false,useCouponCount:0,dataLoading:false,list:[]};},computed:{couponCount:function couponCount(){var limitCount=this.useCouponList.map(function(list){return Number(list.discountPrice||0);});var count=0;if(this.disabled){count=this.discountPrice;}else{count=limitCount.length>0?limitCount.reduce(function(sum,list){return sum+list;}):0;}return count;},couponCategory:function couponCategory(){// 如果订单类型不在优惠券类型里面,则默认查询通用券 return couponEnum[this.orderType]||'UNIVERSAL';}},mounted:function mounted(){// this.getUseableCoupon() this.getList();},methods:{getList:function getList(){var _this4=this;return _asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee2(){var res,result,count;return regeneratorRuntime.wrap(function _callee2$(_context2){while(1){switch(_context2.prev=_context2.next){case 0:if(!_this4.dataLoading){_context2.next=2;break;}return _context2.abrupt("return");case 2:_this4.dataLoading=true;_context2.prev=3;_context2.next=6;return request.post("".concat(state.platformApi,"/couponInfo/page"),{data:{couponCategory:_this4.couponCategory,couponType:'FULL_DISCOUNT',useState:'USABLE',orderUse:1,page:1,rows:100}});case 6:res=_context2.sent;_this4.dataLoading=false;result=res.data||{};// 处理重复请求数据 if(!(_this4.list.length>0&&result.pageNo===1)){_context2.next=11;break;}return _context2.abrupt("return");case 11:_this4.list=result.rows||[];// 处理可用优惠券是否支付使用 _this4.list.forEach(function(item){item.checked=false;// 如果使用金额大于订单金额则优惠券不可用 if(item.useLimit>_this4.orderAmount){item.disabled=true;}else{item.disabled=false;}});count=0;_this4.list.forEach(function(item){if(!item.disabled){count++;}});console.log(_this4.list,'list');_this4.useCouponCount=count;_context2.next=21;break;case 19:_context2.prev=19;_context2.t0=_context2["catch"](3);case 21:case"end":return _context2.stop();}}},_callee2,null,[[3,19]]);}))();},// async getUseableCoupon() { // try { // this.useCouponLoading = true // // 判断是哪个端 // const url = // state.platformType === 'STUDENT' ? '/api-student' : '/api-teacher' // const res = await request.get(`${url}/couponInfo/statInfo`) // this.useCouponLoading = false // const result = (res.data || []).find( // result => result.useState === 'USABLE' // ) // this.useCouponCount = result.total || 0 // } catch { // // TODO: handle // } // }, onSubmit:function onSubmit(item){// useCouponList this.useCouponList=item;this.$emit('couponSelect',item);this.popupStatus=false;this.popupLoading=false;}},render:function render(){var _this5=this;return createVNode(Fragment,null,[createVNode(Cell,{"title":"优惠券","class":styles.useCoupon,"style":{borderRadius:'8px'},"isLink":!this.disabled,"clickable":false,"onClick":function onClick(){if(_this5.disabled)return;_this5.popupStatus=true;_this5.popupLoading=true;}},{value:function value(){return!_this5.useCouponLoading&&createVNode(Fragment,null,[_this5.couponCount>0?createVNode("span",{"class":styles.couponCount},[createVNode("i",null,[createTextVNode("-\uFFE5")]),_this5.couponCount]):createVNode(Fragment,null,[_this5.useCouponCount>0?"".concat(_this5.useCouponCount,"\u5F20\u53EF\u4F7F\u7528"):'暂无可使用优惠券'])]);}}),createVNode(Popup,{"show":this.popupStatus,"onUpdate:show":function onUpdateShow($event){return _this5.popupStatus=$event;},"position":"bottom","round":true,"safeAreaInsetBottom":true,"style":{height:'75%'},"onClosed":function onClosed(){_this5.popupLoading=false;}},{default:function _default(){return[_this5.popupLoading&&createVNode(ChoiceCoupon,{"couponCategory":_this5.couponCategory,"useCoupon":_this5.useCouponList,"orderAmount":_this5.orderAmount,"couponList":_this5.list,"onClose":function onClose(){return _this5.popupStatus=false;},"onSubmit":function onSubmit(item){return _this5.onSubmit(item);}},null)];}})]);}});var index=exports('default',defineComponent({name:'order-detail',data:function data(){var query=this.$route.query;return{loading:false,// 是否加载中,为了处理0元订单() orderType:query.orderType,recomUserId:query.recomUserId,// 推荐人id activityId:query.activityId,// 活动编号 id:query.id,agreeStatus:false,popupShow:false,paymentStatus:false,orderAmount:0,// 订单金额,用于使用优惠券,余额,优惠等 orderPrice:0,// 支付金额,最后支付金额 dataLoading:true};},unmounted:function unmounted(){// 销毁时解绑监听 orderStatus.orderInfo={orderNo:'',actualPrice:0,payStatus:false};},computed:{orderList:function orderList(){// 商品列表 var orderObject=orderStatus.orderObject;return orderObject.orderList||[];}},mounted:function mounted(){var _this6=this;return _asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee3(){var item;return regeneratorRuntime.wrap(function _callee3$(_context3){while(1){switch(_context3.prev=_context3.next){case 0:// 判断是否是曲目购买(只有智能陪练才会有入口),其它地方不会有入口 _this6.dataLoading=true;if(!(_this6.orderType=='MUSIC'&&_this6.id)){_context3.next=18;break;}_context3.prev=2;_context3.next=5;return getMusicDetail(_this6.id);case 5:item=_context3.sent;orderStatus.orderObject.orderType='MUSIC';orderStatus.orderObject.orderName=item.musicSheetName;orderStatus.orderObject.orderDesc=item.musicSheetName;orderStatus.orderObject.actualPrice=item.musicPrice;orderStatus.orderObject.recomUserId=_this6.recomUserId;orderStatus.orderObject.activityId=_this6.activityId;// 判断当前订单是否在支付中 if(['WAIT_PAY','PAYING'].includes(item.orderStatus)){orderStatus.orderObject.orderNo=item.orderNo;}else if(['PAID','CLOSE','FAIL'].includes(item.orderStatus)){// 判断订单是否是其它状态 Toast('订单有误');postMessage({api:'back',content:{}});}orderStatus.orderObject.orderList=[_objectSpread({orderType:'MUSIC',goodsName:item.musicSheetName,actualPrice:item.musicPrice},item)];_context3.next=18;break;case 16:_context3.prev=16;_context3.t0=_context3["catch"](2);case 18:_this6.orderAmount=orderStatus.orderObject.actualPrice||0;_this6.orderPrice=orderStatus.orderObject.actualPrice||0;_this6.dataLoading=false;// 0元支付特别处理 if(_this6.orderPrice===0&&orderStatus.orderObject.orderType){_this6.loading=true;_this6.onSubmit();}case 22:case"end":return _context3.stop();}}},_callee3,null,[[2,16]]);}))();},methods:{onAuthSuccess:function onAuthSuccess(){this.popupShow=false;this.onSubmit();// 实名成功后自动支付 },onSubmit:function onSubmit(){var _this7=this;return _asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee4(){var users,orderObject,url,res,result;return regeneratorRuntime.wrap(function _callee4$(_context4){while(1){switch(_context4.prev=_context4.next){case 0:if(!(_this7.orderPrice>0)){_context4.next=8;break;}if(_this7.agreeStatus){_context4.next=4;break;}Toast('请先阅读并同意《酷乐秀平台服务协议》');return _context4.abrupt("return");case 4:users=state.user.data;// 判断是否需要实名认证 if(!(!(users!==null&&users!==void 0&&users.realName)||!(users!==null&&users!==void 0&&users.idCardNo))){_context4.next=8;break;}_this7.popupShow=true;return _context4.abrupt("return");case 8:if(!orderStatus.orderObject.orderNo){_context4.next=11;break;}_this7.paymentStatus=true;return _context4.abrupt("return");case 11:_context4.prev=11;orderObject=orderStatus.orderObject;url=state.platformType==='TEACHER'?'/api-teacher/userOrder/executeOrder':'/api-student/userOrder/executeOrder';_context4.next=16;return request.post(url,{data:{orderName:orderObject.orderName,orderDesc:orderObject.orderDesc,orderType:orderObject.orderType,actualPrice:_this7.orderPrice||0,recomUserId:orderObject.recomUserId,activityId:orderObject.activityId,couponId:orderObject.couponId,orderInfos:_toConsumableArray(orderInfos())}});case 16:res=_context4.sent;result=res.data||{};// 支付成功 if(!(result.status=='PAID')){_context4.next=21;break;}_this7.$router.replace({path:'/tradeDetail',query:{orderNo:result.orderNo}});return _context4.abrupt("return");case 21:// 拉起支付方式 orderStatus.orderObject.orderNo=result.orderNo;orderStatus.orderObject.actualPrice=result.actualPrice;_this7.paymentStatus=true;_context4.next=30;break;case 26:_context4.prev=26;_context4.t0=_context4["catch"](11);_this7.loading=false;if(_this7.orderPrice===0){Dialog.alert({title:'提示',message:'支付失败,请稍后重试!',confirmButtonText:'确定',confirmButtonColor:'#01C1B5'});}case 30:case"end":return _context4.stop();}}},_callee4,null,[[11,26]]);}))();},onBackOut:function onBackOut(){// 关闭订单后需要重置数据 resestState();},onCouponSelect:function onCouponSelect(item){console.log('onCouponSelect',item);var discountCount=0;(item||[]).forEach(function(item){discountCount+=Number(item.discountPrice);});var lastAmount=Number((Number(this.orderAmount)-Number(discountCount)).toFixed(2));this.orderPrice=lastAmount>=0?lastAmount:0;// 设置优惠券编号 var couponIds=(item||[]).map(function(item){return item.couponIssueId;});orderStatus.orderObject.couponId=couponIds.join(',')||'';}},render:function render(){var _this8=this;return createVNode("div",{"class":styles$2['order-detail']},[createVNode(ColHeader,null,null),!this.loading&&createVNode(Fragment,null,[this.orderList.map(function(item){if(item.orderType==='VIP'){return createVNode(OrderVip,{"item":item},null);}}),!this.dataLoading&&createVNode(UseCoupon,{"discountPrice":orderStatus.orderObject.discountPrice,"orderType":this.orderType,"orderAmount":this.orderAmount,"onCouponSelect":this.onCouponSelect,"disabled":orderStatus.orderObject.orderNo?true:false},null),createVNode("div",{"class":styles$2.paymentInfo},[this.orderPrice>0&&createVNode("div",{"class":styles$2.protocol},[createVNode(ColProtocol,{"modelValue":this.agreeStatus,"onUpdate:modelValue":function onUpdateModelValue($event){return _this8.agreeStatus=$event;},"showHeader":true,"style":{paddingLeft:0,paddingRight:0}},null)]),createVNode("div",{"class":styles$2.btnGroup},[createVNode("div",{"class":styles$2.priceSection},[createTextVNode("\u652F\u4ED8\u91D1\u989D\uFF1A"),createVNode("div",{"class":styles$2.price},[createVNode("span",{"class":styles$2.priceUnit},[createTextVNode("\uFFE5")]),createVNode("span",{"class":styles$2.priceNum},[moneyFormat(this.orderPrice)])])]),createVNode(Button,{"type":"primary","round":true,"class":styles$2.btn,"onClick":this.onSubmit},{default:function _default(){return[createTextVNode("\u7ACB\u5373\u652F\u4ED8")];}})])])]),createVNode(ColPopup,{"modelValue":this.popupShow,"onUpdate:modelValue":function onUpdateModelValue($event){return _this8.popupShow=$event;}},{default:function _default(){return[createVNode(UserAuth,{"onSuccess":_this8.onAuthSuccess},null)];}}),createVNode(Popup,{"show":this.paymentStatus,"closeOnClickOverlay":false,"position":"bottom","round":true,"closeOnPopstate":true,"safeAreaInsetBottom":true,"style":{minHeight:'30%'}},{default:function _default(){return[createVNode(Payment,{"modelValue":_this8.paymentStatus,"onUpdate:modelValue":function onUpdateModelValue($event){return _this8.paymentStatus=$event;},"orderInfo":orderStatus.orderObject,"onBackOut":_this8.onBackOut},null)];}})]);}}));}};});})();