text: "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var _class,_temp2,_createClass=function(){function n(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(e,t,o){return t&&n(e.prototype,t),o&&n(e,o),e}}(),_get=function e(t,o,n){null===t&&(t=Function.prototype);var r=Object.getOwnPropertyDescriptor(t,o);if(void 0===r){var i=Object.getPrototypeOf(t);return null===i?void 0:e(i,o,n)}if("value"in r)return r.value;var a=r.get;return void 0!==a?a.call(n):void 0},_index=require("../../npm/@tarojs/taro-weapp/index.js"),_index2=_interopRequireDefault(_index),_ajax=require("../../utils/ajax.js"),_ajax2=_interopRequireDefault(_ajax);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _asyncToGenerator(e){return function(){var u=e.apply(this,arguments);return new Promise(function(i,a){return function t(e,o){try{var n=u[e](o),r=n.value}catch(e){return void a(e)}if(!n.done)return Promise.resolve(r).then(function(e){t("next",e)},function(e){t("throw",e)});i(r)}("next")})}}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var CouponList=(_temp2=_class=function(e){function s(){var e,t,n,o,r=this;_classCallCheck(this,s);for(var i=arguments.length,a=Array(i),u=0;u<i;u++)a[u]=arguments[u];return(t=n=_possibleConstructorReturn(this,(e=s.__proto__||Object.getPrototypeOf(s)).call.apply(e,[this].concat(a)))).$usedState=["_$anonymousState__temp","loopArray24","$compid__104","$compid__105","$compid__106","couponList","mode","error"],n.config={navigationBarTitleText:"优惠券"},n.useCoupon=(o=_asyncToGenerator(regeneratorRuntime.mark(function e(t){var o;return regeneratorRuntime.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return o=n.$router.params.orderId,_index2.default.showLoading(),e.prev=2,e.next=5,(0,_ajax2.default)({name:"useCoupon",data:{orderId:o,couponId:t?t.id:-1}});case 5:_index2.default.hideLoading(),_index2.default.eventCenter.trigger("update:order"),_index2.default.navigateBack(),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(2),_index2.default.hideLoading();case 13:case"end":return e.stop()}},e,r,[[2,10]])})),function(e){return o.apply(this,arguments)}),n.handleClickCoupon=function(e){var t=n.$router.params.mode;if("use"===(void 0===t?"take":t))return n.useCoupon(e)},n.handleClickUseNothing=function(){return n.useCoupon(null)},n.customComponents=["Coupon","Cell","Tip","Loading"],_possibleConstructorReturn(n,t)}return _inherits(s,_index.Component),_createClass(s,[{key:"_constructor",value:function(e){_get(s.prototype.__proto__||Object.getPrototypeOf(s.prototype),"_constructor",this).call(this,e),this.state={couponList:null,error:null},this.$$refs=[]}},{key:"componentWillMount",value:function(){var t=this,e=this.$router.params,o=e.mode,n=void 0===o?"take":o,r=e.orderId,i={};"use"===n&&((i={orderId:r}).couponId=_index2.default.getStorageSync("couponIdFromEntry")),(0,_ajax2.default)({name:{take:"getAllCoupon",own:"getMyCoupon",use:"getUsableCoupon"}[n],data:i,success:function(e){"use"===n?t.setState({couponList:e.list}):t.setState({couponList:e})},fail:function(e){e.data&&e.data.info&&t.setState({error:e.data.info})},hideToast:!0})}},{key:"onShareAppMessage",value:function(){}},{key:"onPullDownRefresh",value:function(){this.componentWillMount()}},{key:"_createData",value:function(){var e,n=this;this.__state=arguments[0]||this.state||{},this.__props=arguments[1]||this.props||{};arguments[2];var r=this.$prefix,t=(0,_index.genCompid)(r+"$compid__104"),o=(0,_index.genCompid)(r+"$compid__105"),i=(0,_index.genCompid)(r+"$compid__106"),a=void 0,u=this.$router.params.mode,s=void 0===u?"take":u,p=this.__state,c=p.couponList,l=p.error;return c&&0<c.length?(a=c.map(function(e,t){e={$original:(0,_index.internal_get_original)(e)};var o=(0,_index.genCompid)(r+"gNMEQlKCvq"+t);return _index.propsManager.set({couponInfo:e.$original,mode:s,onClick:n.handleClickCoupon},o),{$compid__103:o,$original:e.$original}}),"use"===s&&_index.propsManager.set({title:"不使用优惠券",onClick:this.handleClickUseNothing,isLink:!0},t)):c?(e="目前没有可"+("use"===s?"使用":"领取")+"的优惠券",_index.propsManager.set({type:"full",text:e},o)):l&&_index.propsManager.set({type:"full",icon:"unhappy",text:l},i),Object.assign(this.__state,{_$anonymousState__temp:e,loopArray24:a,$compid__104:t,$compid__105:o,$compid__106:i,mode:s}),this.__state}}]),s}(),_class.$$events=[],_class.$$componentPath="pages/coupon-list/coupon-list",_temp2);exports.default=CouponList,Component(require("../../npm/@tarojs/taro-weapp/index.js").default.createComponent(CouponList,!0));