buy.js 5.6 KB

1
  1. (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["plugins/vip_card/buy/buy"],{"36ef":function(t,e,n){"use strict";var a,i=function(){var t=this,e=t.$createElement;t._self._c},o=[];n.d(e,"b",(function(){return i})),n.d(e,"c",(function(){return o})),n.d(e,"a",(function(){return a}))},5297:function(t,e,n){"use strict";(function(t){n("8748");a(n("66fd"));var e=a(n("f297"));function a(t){return t&&t.__esModule?t:{default:t}}t(e.default)}).call(this,n("543d")["createPage"])},"7d1d":function(t,e,n){"use strict";n.r(e);var a=n("9122"),i=n.n(a);for(var o in a)"default"!==o&&function(t){n.d(e,t,(function(){return a[t]}))}(o);e["default"]=i.a},9122:function(t,e,n){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var a=n("2f62");function i(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,a)}return n}function o(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i(Object(n),!0).forEach((function(e){r(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var d={data:function(){return{detail:{},list:{},card:{expire_day:""},today:"",end_day:"",total_coupon:0,total_card:0,id:0,end_time:"",start_day:"",success:!1,iphone_x:!1,template_message:[],loading:!1}},computed:o({},(0,a.mapState)({theme:function(t){return t.mallConfig.theme},svipImg:function(t){return t.mallConfig.__wxapp_img.vip_card}})),methods:{toDetail:function(){t.navigateTo({url:"/plugins/vip_card/rights/rights?id="+this.id})},toBack:function(){this.success=!1,t.navigateBack()},toCoupon:function(){t.navigateTo({url:"/pages/coupon/index/index"})},toCard:function(){t.navigateTo({url:"/pages/card/index/index"})},toBalance:function(){t.navigateTo({url:"/pages/balance/balance"})},toIntegral:function(){t.navigateTo({url:"/plugins/integral_mall/index/index"})},getSetting:function(){var e=this;e.$showLoading({type:"global",text:"加载中..."}),e.$request({url:e.$api.vip_card.setting}).then((function(n){0==n.code?(e.list=n.data,t.setNavigationBarTitle({title:"购买"+e.list.name}),e.template_message=n.data.template_message,e.getCard()):t.showToast({title:n.msg,icon:"none",duration:1e3})})).catch((function(t){e.$hideLoading()}))},getCard:function(){var e=this;e.$request({url:e.$api.vip_card.card_detail,data:{id:this.id}}).then((function(n){if(e.$hideLoading(),0==n.code){e.card=n.data;var a=Date.parse(new Date);e.end_time>0&&(a=Date.parse(new Date(e.end_time)));var i=1e3*(a/1e3+86400*n.data.expire_day),o=new Date(i),r=o.getFullYear(),d=o.getMonth()+1;d>=1&&d<=9&&(d="0"+d);var c=o.getDate();c>=1&&c<=9&&(c="0"+c),e.end_day=r+"/"+d+"/"+c,e.card.coupons.forEach((function(t){e.total_coupon+=+t.send_num})),e.card.cards.forEach((function(t){e.total_card+=+t.send_num}))}else t.showToast({title:n.msg,icon:"none",duration:1e3})})).catch((function(t){e.$hideLoading()}))},subscribe:function(){var t=this;this.$subscribe(this.template_message).then((function(e){t.toSubmit()})).catch((function(e){t.toSubmit()}))},toSubmit:function(){var e=this;if(this.loading)return!1;this.loading=!0,t.showLoading({title:"购买中..."}),e.$request({url:e.$api.vip_card.order_submit,data:{id:this.id},method:"post"}).then((function(n){0===n.code?e.getPayOrderId(n.data.queue_id,n.data.token):(e.loading=!1,t.hideLoading(),t.showModal({title:"提示",content:n.msg,showCancel:!1}))})).catch((function(n){e.loading=!1,t.hideLoading(),t.showModal({title:"提示",content:n.errMsg,showCancel:!1})}))},getPayOrderId:function(e,n){var a=this;this.$request({url:this.$api.vip_card.pay_data,method:"post",data:{queue_id:e,token:n}}).then((function(i){0===i.code?i.data.retry&&1===i.data.retry?a.getPayDataTimer=setTimeout((function(){a.getPayOrderId(e,n)}),1e3):a.pay(i.data.id):(t.hideLoading(),a.loading=!1,t.showModal({title:"提示",content:i.msg,showCancel:!1}))})).catch((function(e){a.loading=!1,t.hideLoading(),t.showModal({title:"提示",content:e.errMsg,showCancel:!1})}))},pay:function(e){var n=this;n.$payment.pay(e).then((function(e){t.hideLoading(),n.loading=!1,t.showToast({title:"购买成功",duration:1e3}),n.card.send_integral_num>0||n.card.send_balance>0||n.card.coupons.length>0||n.card.cards.length>0?n.success=!0:setTimeout((function(e){t.navigateBack()}),1e3)})).catch((function(e){t.hideLoading(),n.loading=!1,t.showToast({title:"支付失败",icon:"none",duration:1e3})}))}},onLoad:function(e){var n=this;t.getSystemInfo({success:function(t){(t.model.indexOf("iPhone X")>-1||t.model.indexOf("iPhone 11")>-1||t.model.indexOf("iPhone11")>-1||t.model.indexOf("iPhone12")>-1)&&(n.iphone_x=!0)}});var a=new Date,i=a.getFullYear(),o=a.getMonth()+1;o>=1&&o<=9&&(o="0"+o);var r=a.getDate();r>=1&&r<=9&&(r="0"+r),this.today=i+"/"+o+"/"+r,this.id=e.id,this.end_time=e.end,this.expire_day=e.expire_day?e.expire_day:0,n.getSetting(e.id)}};e.default=d}).call(this,n("543d")["default"])},d8a5:function(t,e,n){},f297:function(t,e,n){"use strict";n.r(e);var a=n("36ef"),i=n("7d1d");for(var o in i)"default"!==o&&function(t){n.d(e,t,(function(){return i[t]}))}(o);n("f90e");var r,d=n("f0c5"),c=Object(d["a"])(i["default"],a["b"],a["c"],!1,null,"2c31fb4c",null,!1,a["a"],r);e["default"]=c.exports},f90e:function(t,e,n){"use strict";var a=n("d8a5"),i=n.n(a);i.a}},[["5297","common/runtime","common/vendor"]]]);