index.js 12 KB

1
  1. (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["plugins/gift/index/index"],{"0b8d":function(t,e,i){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var n=o(i("a34a")),r=i("2f62");function o(t){return t&&t.__esModule?t:{default:t}}function s(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function a(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?s(Object(i),!0).forEach((function(e){u(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):s(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function u(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function c(t,e,i,n,r,o,s){try{var a=t[o](s),u=a.value}catch(c){return void i(c)}a.done?e(u):Promise.resolve(u).then(n,r)}function f(t){return function(){var e=this,i=arguments;return new Promise((function(n,r){var o=t.apply(e,i);function s(t){c(o,n,r,s,a,"next",t)}function a(t){c(o,n,r,s,a,"throw",t)}s(void 0)}))}}var l=function(){i.e("plugins/gift/components/index/pick-gift").then(function(){return resolve(i("d2b4"))}.bind(null,i)).catch(i.oe)},d=function(){i.e("plugins/gift/components/index/gift-method").then(function(){return resolve(i("74d2"))}.bind(null,i)).catch(i.oe)},h=function(){i.e("plugins/gift/components/index/blessing-message").then(function(){return resolve(i("83be"))}.bind(null,i)).catch(i.oe)},g=function(){Promise.all([i.e("common/vendor"),i.e("plugins/gift/components/index/generate-package")]).then(function(){return resolve(i("1285"))}.bind(null,i)).catch(i.oe)},p=function(){i.e("plugins/gift/components/announcement/gift-navigation").then(function(){return resolve(i("7fae"))}.bind(null,i)).catch(i.oe)},_=function(){i.e("components/basic-component/app-empty-bottom/app-empty-bottom").then(function(){return resolve(i("42cd"))}.bind(null,i)).catch(i.oe)},m=function(){i.e("plugins/gift/components/index/get-right-now").then(function(){return resolve(i("5395"))}.bind(null,i)).catch(i.oe)},b=function(){i.e("plugins/gift/components/index/voice").then(function(){return resolve(i("77d2"))}.bind(null,i)).catch(i.oe)},v={name:"index",data:function(){return{gift_list:[],totalPrice:0,method_type:"direct_open",open_type:0,open_num:null,select_str:"",open_time:"",bless_word:"",config:{},is_gift:!1,gift_id:-1,turn_no:"",gift:{},currentRoute:this.$platDiff.route(),navBool:!1,new_open_type:"",src:"",innerAudioContext:"",is_play:!1,audio:{},recorderManager:null,music_play:!1,bless_music:"",voice_i:0,voice_time:-1}},onLoad:function(e){var i=this;if(this.$commonLoad.onload(e),this.$user.isLogin()){if(e.gift_id&&e.user_id)this.is_gift=!0,this.gift_id=e.gift_id,this.turn_no=e.turn_no,this.getGift(this.gift_id);else if(e.pay_data){var n=JSON.parse(e.pay_data).gift_id;this.$request({url:this.$api.gift.cancel,data:{gift_id:n}})}}else this.$user.getInfo().then((function(){e.gift_id&&e.user_id&&(i.gift_id=e.gift_id,i.is_gift=!0,i.turn_no=e.turn_no,i.getGift(i.gift_id))}));this.request();var r=this;this.recorderManager=t.getRecorderManager({duration:3e4}),this.innerAudioContext=t.createInnerAudioContext(),this.innerAudioContext.onEnded((function(t){r.is_play=!1,r.music_play=!1})),this.innerAudioContext.onStop((function(){})),this.innerAudioContext.autoplay=!0,this.recorderManager.onStop((function(e){t.uploadFile({url:r.$api.upload.file,filePath:e.tempFilePath,name:"file",fileType:"audio",formData:{file:e.tempFilePath,file_name:""},success:function(t){var e=JSON.parse(t.data),i=(e.code,e.data);r.bless_music=i.url}}),r.audio=e})),wx.showShareMenu({menus:["shareAppMessage","shareTimeline"]})},onShow:function(){this.gift_list=this.$storage.getStorageSync("GIFT_CART");for(var t=0;t<this.gift_list.length;t++)this.gift_list[t].number=Number(this.gift_list[t].number),this.gift_list[t].total_cost=parseFloat((this.gift_list[t].number*this.gift_list[t].price).toFixed(2))},onUnload:function(){this.innerAudioContext&&(this.music_play=!1,this.is_play=!1,this.innerAudioContext.stop())},onHide:function(){this.innerAudioContext&&(this.music_play=!1,this.is_play=!1,this.innerAudioContext.stop())},onShareAppMessage:function(){return this.$shareAppMessage({path:"/plugins/gift/index/index",title:this.config.ask_gift})},onShareTimeline:function(){return this.$shareTimeline({title:this.config.ask_gift,query:{}})},methods:{request:function(){var e=this;return f(n.default.mark((function i(){var r,o;return n.default.wrap((function(i){while(1)switch(i.prev=i.next){case 0:return e.$utils.showLoading(),i.prev=1,i.next=4,e.$request({url:e.$api.gift.config,method:"get"});case 4:if(r=i.sent,e.$utils.hideLoading(),0!==r.code){i.next=32;break}e.config=r.data,t.setNavigationBarTitle({title:r.data.title}),o="",i.t0=Number(r.data.theme.id),i.next=1===i.t0?13:2===i.t0?15:3===i.t0?17:4===i.t0?19:5===i.t0?21:6===i.t0?23:25;break;case 13:return o="streamer-gold-gift",i.abrupt("break",26);case 15:return o="romantic-powder-gift",i.abrupt("break",26);case 17:return o="taste-red-gift",i.abrupt("break",26);case 19:return o="elegant-purple-gift",i.abrupt("break",26);case 21:return o="fresh-green-gift",i.abrupt("break",26);case 23:return o="business-blue-gift",i.abrupt("break",26);case 25:o="streamer-gold-gift";case 26:e.$storage.setStorageSync("giftTheme",o),e.$store.commit("gift/setTheme",Number(r.data.theme.id)),e.$store.commit("gift/setGiftPic",r.data.big_gift_pic),e.method_type=e.config.type[0],i.next=33;break;case 32:t.showModal({title:"提示",content:r.msg});case 33:i.next=39;break;case 35:throw i.prev=35,i.t1=i["catch"](1),e.$utils.hideLoading(),new Error(i.t1);case 39:case"end":return i.stop()}}),i,null,[[1,35]])})))()},giftNumber:function(t){var e=t.index,i=t.type;this.gift_list[e].number=i?this.gift_list[e].number+1:this.gift_list[e].number-1,this.changeNumber(e)},giftInput:function(t){var e=t.index,i=t.quantity;if(i>=this.gift_list[e].attr.stock){var n=JSON.parse(JSON.stringify(this.gift_list[e]));n.number=this.gift_list[e].attr.stock,this.$set(this.gift_list,e,n),this.changeNumber(e)}else this.$set(this.gift_list[e],"number",i),this.changeNumber(e)},changeNumber:function(t){var e=this.gift_list[t],i=e.number,n=e.price;this.$set(this.gift_list[t],"total_cost",parseFloat((i*n).toFixed(2))),0===this.gift_list[t].number&&this.$delete(this.gift_list,t),this.$storage.setStorageSync("GIFT_CART",this.gift_list)},submit:function(){var e=this;return f(n.default.mark((function i(){var r,o,s,a,u;return n.default.wrap((function(i){while(1)switch(i.prev=i.next){case 0:for(e.$utils.showLoading(),r=[{mch_id:0,type:e.method_type,open_num:e.open_num,open_time:e.open_time,bless_word:e.bless_word?e.bless_word:e.config.bless_word,bless_music:e.bless_music,open_type:e.open_type,goods_list:[],remark:"",use_integral:0,user_coupon_id:0}],o=0;o<e.gift_list.length;o++){for(s={id:e.gift_list[o].attr.goods_id,attr:[],num:e.gift_list[o].number,cat_id:0,goods_attr_id:e.gift_list[o].attr.id},a=0;a<e.gift_list[o].attr.attr_list.length;a++)s.attr.push({attr_id:e.gift_list[o].attr.attr_list[a].attr_id,attr_group_id:e.gift_list[o].attr.attr_list[a].attr_group_id});r[0].goods_list.push(s)}u={form_data:JSON.stringify({list:r})},e.$store.commit("gift/setFormData",u),"direct_open"===e.method_type?(delete r[0].open_num,delete r[0].open_time):"time_open"===e.method_type?delete r[0].open_num:"num_open"===e.method_type&&delete r[0].open_time,e.$utils.hideLoading(),t.navigateTo({url:"/pages/order-submit/order-submit?preview_url=".concat(encodeURIComponent(e.$api.gift.order_preview),"&submit_url=").concat(encodeURIComponent(e.$api.gift.order_submit),"&pay_data_url=").concat(encodeURIComponent(e.$api.gift.pay_data),"&show_pay_result=false&mch_list=").concat(JSON.stringify(r),"&theme=").concat(e.theme,"&order_page_url=/plugins/gift/share/share&pay_cancel_url=/plugins/gift/index/index")});case 8:case"end":return i.stop()}}),i)})))()},generatePackage:function(){this.submit()},set_methods:function(t){this.method_type=t},set_people_status:function(t){this.open_type=t},change_people:function(t){this.open_num=t},set_lottery_time:function(t,e){this.select_str=t,this.open_time=e},changeTextarea:function(t){this.bless_word=t},pay_data:function(e){var i=this;return f(n.default.mark((function r(){var o;return n.default.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return n.prev=0,n.next=3,i.$request({url:i.$api.gift.pay_data,method:"post",data:a({},e)});case 3:o=n.sent,0===o.code?o.data.hasOwnProperty("id")?(i.$payment.pay(o.data.id).then((function(){i.$storage.setStorageSync("GIFT_CART",[]),t.redirectTo({url:"/plugins/gift/share/share?gift_id=".concat(o.data.gift_id)})})).catch((function(){})),i.$utils.hideLoading()):setTimeout((function(){i.pay_data(e)}),1e3):(i.$utils.hideLoading(),t.showModal({title:"提示",content:o.msg})),n.next=11;break;case 7:throw n.prev=7,n.t0=n["catch"](0),i.$utils.hideLoading(),new Error(n.t0);case 11:case"end":return n.stop()}}),r,null,[[0,7]])})))()},setGift:function(t){this.is_gift=t},getGift:function(e){var i=this;return f(n.default.mark((function r(){var o;return n.default.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return i.$utils.showLoading(),n.next=3,i.$request({url:i.$api.gift.gift,data:{gift_id:e}});case 3:o=n.sent,0===o.code?(i.gift=o.data,i.wordYun(i.gift.list.bless_word)):t.showModal({title:"提示",content:o.msg}),i.$utils.hideLoading();case 6:case"end":return n.stop()}}),r)})))()},setNav:function(){var t=void 0;if(t=this.currentRoute,t){for(var e=0;e<this.tabBarNavs.length;e++)if(t.includes(this.tabBarNavs[e].url.split("?")[0]))return this.navBool=!0;return this.navBool=!1}},play:function(t){this.is_play=t,this.voice_i=0,t?(this.innerAudioContext.src=this.audio.tempFilePath,this.innerAudioContext.play()):this.innerAudioContext.stop()},recorder:function(t){var e=this;t?(clearInterval(this.voice_time),this.voice_i=0,this.voice_time=setInterval((function(){e.voice_i++}),1e3),this.recorderManager.start()):(this.recorderManager.stop(),clearInterval(this.voice_time))},music:function(t,e){this.music_play=t,t?(this.innerAudioContext.src=e,this.innerAudioContext.play()):this.innerAudioContext.stop()},close:function(){this.is_play=!1,this.innerAudioContext.stop()}},watch:{gift_list:{handler:function(t){this.totalPrice=0;for(var e=0;e<t.length;e++)this.totalPrice+=t[e].total_cost;this.totalPrice=this.totalPrice.toFixed(2)},immediate:!0,deep:!0},tabBarNavs:{handler:function(){this.setNav()},immediate:!0}},computed:a(a(a({},(0,r.mapState)("gift",{theme:function(t){return t.theme},big_gift_pic:function(t){return t.big_gift_pic}})),(0,r.mapState)({tabBarNavs:function(t){return t.mallConfig.navbar.navs}})),(0,r.mapGetters)("iPhoneX",{BotHeight:"getNavHei"})),components:{"pick-gift":l,"gift-method":d,"blessing-message":h,"generate-package":g,"gift-navigation":p,"app-empty-bottom":_,"get-right-now":m,voice:b}};e.default=v}).call(this,i("543d")["default"])},"6e45":function(t,e,i){"use strict";i.r(e);var n=i("7f1a"),r=i("f0c6");for(var o in r)"default"!==o&&function(t){i.d(e,t,(function(){return r[t]}))}(o);i("df8b");var s,a=i("f0c5"),u=Object(a["a"])(r["default"],n["b"],n["c"],!1,null,null,null,!1,n["a"],s);e["default"]=u.exports},"7f1a":function(t,e,i){"use strict";var n;i.d(e,"b",(function(){return r})),i.d(e,"c",(function(){return o})),i.d(e,"a",(function(){return n}));var r=function(){var t=this,e=t.$createElement,i=(t._self._c,Number(96)),n=Object.keys(t.gift);t._isMounted||(t.e0=function(e){t.voice_i=0}),t.$mp.data=Object.assign({},{$root:{m0:i,g0:n}})},o=[]},"8da5":function(t,e,i){},c80c:function(t,e,i){"use strict";(function(t){i("2d0a");n(i("66fd"));var e=n(i("6e45"));function n(t){return t&&t.__esModule?t:{default:t}}t(e.default)}).call(this,i("543d")["createPage"])},df8b:function(t,e,i){"use strict";var n=i("8da5"),r=i.n(n);r.a},f0c6:function(t,e,i){"use strict";i.r(e);var n=i("0b8d"),r=i.n(n);for(var o in n)"default"!==o&&function(t){i.d(e,t,(function(){return n[t]}))}(o);e["default"]=r.a}},[["c80c","common/runtime","common/vendor"]]]);