pond.js 5.1 KB

1
  1. (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["plugins/pick/pond/pond"],{1464:function(t,i,e){"use strict";(function(t){e("8748");n(e("66fd"));var i=n(e("d981"));function n(t){return t&&t.__esModule?t:{default:t}}t(i.default)}).call(this,e("543d")["createPage"])},"23ec":function(t,i,e){},"69be":function(t,i,e){"use strict";e.r(i);var n=e("f47a9"),s=e.n(n);for(var a in n)"default"!==a&&function(t){e.d(i,t,(function(){return n[t]}))}(a);i["default"]=s.a},"7c71":function(t,i,e){"use strict";var n,s=function(){var t=this,i=t.$createElement;t._self._c},a=[];e.d(i,"b",(function(){return s})),e.d(i,"c",(function(){return a})),e.d(i,"a",(function(){return n}))},b916:function(t,i,e){"use strict";var n=e("23ec"),s=e.n(n);s.a},d981:function(t,i,e){"use strict";e.r(i);var n=e("7c71"),s=e("69be");for(var a in s)"default"!==a&&function(t){e.d(i,t,(function(){return s[t]}))}(a);e("b916");var r,o=e("f0c5"),c=Object(o["a"])(s["default"],n["b"],n["c"],!1,null,"b1d2ba88",null,!1,n["a"],r);i["default"]=c.exports},f47a9:function(t,i,e){"use strict";(function(t){Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var n=s(e("4795"));function s(t){return t&&t.__esModule?t:{default:t}}function a(t,i,e,n,s,a,r){try{var o=t[a](r),c=o.value}catch(u){return void e(u)}o.done?i(c):Promise.resolve(c).then(n,s)}function r(t){return function(){var i=this,e=arguments;return new Promise((function(n,s){var r=t.apply(i,e);function o(t){a(r,n,s,o,c,"next",t)}function c(t){a(r,n,s,o,c,"throw",t)}o(void 0)}))}}var o=function(){Promise.all([e.e("common/vendor"),e.e("components/basic-component/app-iphone-x/app-iphone-x")]).then(function(){return resolve(e("bd7b"))}.bind(null,e)).catch(e.oe)},c={name:"pond",data:function(){return{pond:[],step:1,pick_activity_id:0,pay_pond:[],all_price:0,is_active:!1,rule_num:0,edit:!1,stillNeed:0,buy_goods_list:[],all_num:0}},components:{appIphoneX:o},onLoad:function(t){this.pick_activity_id=t.pick_activity_id,this.rule_num=t.rule_num},onShow:function(){this.getCart()},methods:{changeActive:function(t){console.log(t),t.is_active=!t.is_active},_calcValue:function(t,i){var e=this._getDecimalScale(),n=t.num*e,s=this.step*e;"minus"===i?n-=s:"plus"===i&&(n+=s),n<1||n>t.attrs.stock||(t.num=String(n/e),this.editList())},editInput:function(){this.editList()},_getDecimalScale:function(){var t=1;return~~this.step!==this.step&&(t=Math.pow(10,(this.step+"").split(".")[1].length)),t},selectAll:function(){this.is_active=!this.is_active;for(var t=0;t<this.pond.length;t++)this.pond[t].pick_activity_id!=this.pick_activity_id||this.edit?this.edit&&(this.pond[t].is_active=this.is_active):this.pond[t].is_active=this.is_active},buy:function(){var i=[];this.buy_goods_list=[];var e={mch_id:"0",goods_list:this.buy_goods_list,pick_activity_id:this.pick_activity_id};i.push(e);for(var n=0;n<this.pay_pond.length;n++)this.buy_goods_list.push({id:this.pay_pond[n].goods_id,attr:this.pay_pond[n].attrs.attr,num:this.pay_pond[n].num,cat_id:0,cart_id:this.pay_pond[n].id,goods_attr_id:this.pay_pond[n].attrs.id});if(0===this.stillNeed&&0!==this.buy_goods_list.length){var s="/pages/order-submit/order-submit?mch_list=".concat(JSON.stringify(i),"&preview_url=").concat(encodeURIComponent(this.$api.pick.order_preview),"&submit_url=").concat(encodeURIComponent(this.$api.pick.order_submit));t.navigateTo({url:s})}},setEdit:function(t){if(!1===t)for(var i=0;i<this.pond.length;i++)this.pond[i].is_active=!1;this.is_active=!1,this.edit=t},del:function(){var t=this;return r(n.default.mark((function i(){var e,s,a,r;return n.default.wrap((function(i){while(1)switch(i.prev=i.next){case 0:for(e=JSON.parse(JSON.stringify(t.pay_pond)),s=[],a=0;a<e.length;a++)s.push(e[a].id);return i.next=5,t.$request({url:t.$api.pick.delete,method:"post",data:{cart_id_list:JSON.stringify(s)}});case 5:r=i.sent,0===r.code&&(t.is_active=!1,t.getCart());case 7:case"end":return i.stop()}}),i)})))()},getCart:function(){var t=this;return r(n.default.mark((function i(){var e,s,a;return n.default.wrap((function(i){while(1)switch(i.prev=i.next){case 0:return i.next=2,t.$request({url:t.$api.pick.list});case 2:if(e=i.sent,0===e.code){for(s=e.data.list,a=0;a<s.length;a++)s[a].is_active=!1;t.pond=s}case 4:case"end":return i.stop()}}),i)})))()},editList:function(){var t=this;return r(n.default.mark((function i(){var e,s,a;return n.default.wrap((function(i){while(1)switch(i.prev=i.next){case 0:for(e=JSON.parse(JSON.stringify(t.pond)),s=[],a=0;a<e.length;a++)s.push({attr:e[a].attr_id,goods_id:e[a].goods_id,num:e[a].num});return i.next=5,t.$request({url:t.$api.pick.edit,method:"post",data:{list:JSON.stringify(s)}});case 5:i.sent;case 6:case"end":return i.stop()}}),i)})))()}},watch:{pond:{handler:function(t){this.pay_pond=[];var i=0,e=0;this.all_num=0;for(var n=0;n<t.length;n++)t[n].is_active&&(this.pay_pond.push(t[n]),e++,this.all_num+=Number(t[n].num),i+=t[n].num*t[n].attrs.price);e===t.length?(this.is_active=!0,0===t.length&&(this.is_active=!1)):this.is_active=!1,this.all_num%this.rule_num===0?this.stillNeed=0:this.stillNeed=this.rule_num-this.all_num%this.rule_num,this.all_price=i.toFixed(2)},deep:!0}}};i.default=c}).call(this,e("543d")["default"])}},[["1464","common/runtime","common/vendor"]]]);