2020-01-03 01:45:58 +08:00
|
|
|
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([[23],{"+URf":function(e,t,a){"use strict";a.r(t);var n=a("jehZ"),i=a.n(n),s=(a("Pwec"),a("CtXQ")),c=(a("7Kak"),a("9yH6")),r=a("p0pE"),l=a.n(r),o=a("q1tI"),m=a.n(o),d=a("Bl7J"),h=a("/MKj"),p=a("t3Un"),u=a("LbTH"),v=a("3a4m"),b=a.n(v);class E extends m.a.Component{constructor(){super(...arguments),this.state={submit:{plan_id:this.props.match.params.plan_id},loading:!1,layout_login:!0,coupon_result:{}}}componentDidMount(){Object(p["b"])("/user/plan/fetch",{plan_id:this.props.match.params.plan_id}).then(e=>{200===e.code&&this.setState(l()({},e.data,{layout_login:!1}),()=>{this.setState({submit:l()({},this.state.submit,{cycle:this.getFirstPrice()})})})})}getFirstPrice(){return this.state.month_price?"month_price":this.state.quarter_price?"quarter_price":this.state.half_year_price?"half_year_price":this.state.year_price?"year_price":void 0}submit(){var e=l()({},this.state.submit);this.state.coupon_result.name&&(e["coupon_code"]=this.state.coupon_result.code),this.setState({loading:!0},()=>{Object(p["b"])("/user/order/save",e).then(e=>{if(200!==e.code)return this.setState({loading:!1});this.setState({loading:!1}),b.a.push("/order/"+e.data)})})}submitOnChange(e,t){this.setState({submit:l()({},this.state.submit,{[e]:t})})}couponCheck(){Object(p["b"])("/user/coupon/check",{code:this.state.coupon}).then(e=>{200===e.code&&this.setState({coupon_result:e.data})})}couponProcess(e,t,a){switch(t){case 1:return a.toFixed(2);case 2:return(e*(a/100)).toFixed(2)}}getTotalAmount(){var e=this.state,t=e.submit,a=e.coupon_result,n=this.state[t.cycle];return a.name&&(n-=this.couponProcess(n,a.type,a.value)),(n/100).toFixed(2)}getCouponJSX(){if(this.state.coupon_result.name)return m.a.createElement("div",null,m.a.createElement("div",{className:"pt-3",style:{color:"#646669"}},"\u6298\u6263"),m.a.createElement("div",{className:"row no-gutters py-3",style:{borderBottom:"1px solid #646669"}},m.a.createElement("div",{className:"col-8"},this.state.coupon_result.name),m.a.createElement("div",{className:"col-4 text-right"},"- \xa5",(this.couponProcess(this.state[this.state.submit.cycle],this.state.coupon_result.type,this.state.coupon_result.value)/100).toFixed(2))))}render(){return console.log(this.state),m.a.createElement(d["a"],i()({},this.props,{loading:this.state.layout_login}),m.a.createElement("main",{id:"main-container"},m.a.createElement("div",{className:"content content-full"},m.a.createElement("h2",{className:"font-w300 mt-4 mb-3"},"\u914d\u7f6e\u8ba2\u9605"),m.a.createElement("div",{className:"row",id:"cashier"},m.a.createElement("div",{className:"col-md-8 col-sm-12"},m.a.createElement("div",{className:"block block-link-pop block-rounded block-bordered py-3 block-fx-shadow"},m.a.createElement("h4",{className:"mb-0 px-3"},this.state.name),this.state.content?m.a.createElement("div",{dangerouslySetInnerHTML:{__html:this.state.content},className:"v2board-plan-content"}):""),m.a.createElement("h3",{className:"font-w300 mt-4 mb-3"},"\u4ed8\u6b3e\u5468\u671f"),m.a.createElement("div",{className:"mb-3"},m.a.createElement(c["a"].Group,{defaultValue:this.getFirstPrice(),size:"large",onChange:e=>this.submitOnChange("cycle",e.target.value)},null!==this.state.month_price?m.a.createElement(c["a"].Button,{value:"month_price"},"\u6708\u4ed8"):"",null!==this.state.quarter_price?m.a.createElement(c["a"].Button,{value:"quarter_price"},"\u5b63\u4ed8"):"",null!==this.state.half_year_price?m.a.createElement(c["a"].Button,{value:"half_year_price"},"\u534a\u5e74\u4ed8"):"",null!==this.state.year_price?m.a.createElement(c["a"].Button,{value:"year_price"},"\u5e74\u4ed8"):""))),m.a.createElement("div",{className:"col-md-4 col-sm-12"},m.a.createElement("div",{className:"block block-link-pop block-rounded block-bordered px-3 py-3 mb-2 text-light",style:{background:"#35383D"}},m.a.createElement("input",{type:"text",className:"form-control v2board-input-coupon p-0",onChange:e=>{this.setState({coupon:e.target.value})},placeholder:"\u4f18\u60e0\u5238\uff1f"}),this.state.coupon&&m.a.createElement("button",{onClick:()=>t
|