chunk-6b4efa38.f5535746.js 7.9 KB

1
  1. (window.webpackJsonp=window.webpackJsonp||[]).push([["chunk-6b4efa38"],{"1b69":function(t,e,r){"use strict";r("96cf");var n=r("1da1"),a=r("5daa"),s=r("5f87"),i={};window.ajaxTimeout=2e4,e.a=Object(n.a)(regeneratorRuntime.mark((function t(){var e,r,o,c,u,d,p,f=arguments;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=0<f.length&&void 0!==f[0]?f[0]:"",r=1<f.length&&void 0!==f[1]?f[1]:{},c=3<f.length&&void 0!==f[3]?f[3]:{},u=4<f.length&&void 0!==f[4]?f[4]:i,d=5<f.length?f[5]:void 0,o=(o=2<f.length&&void 0!==f[2]?f[2]:"GET").toLowerCase(),p={method:o,baseURL:"",url:a.a.baseURL+e,data:r,params:c,processData:!0,timeout:window.ajaxTimeout,headers:u,onUploadProgress:d},d&&"function"==typeof d&&(p.onUploadProgress=d),axios.interceptors.request.use((function(t){return t.data.token||(t.data.token=Object(s.c)()),t}),(function(t){return Promise.reject(new Error("服务器异常,请联系管理员!"))})),axios.interceptors.response.use(function(){var t=Object(n.a)(regeneratorRuntime.mark((function t(e){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return 200===e.status&&100<=(r=e.data.code)&&r<=104&&Object(s.d)(),t.abrupt("return",e);case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),(function(t){return Promise.reject(t.response.data)})),t.abrupt("return",new Promise((function(t,e){axios(p).then((function(e){t(e.data)})).catch((function(t){t.response&&t.response.data?e(t.response.data):e(t)}))})));case 12:case"end":return t.stop()}}),t)})))},2147:function(t,e,r){},7027:function(t,e,r){"use strict";r("2147")},"9f53":function(t,e,r){"use strict";r("433b");var n,a=r("d399");r("96cf"),r=r("1da1");e.a={methods:{logout:(n=Object(r.a)(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if("/login"!==this.$route.path)return t.next=3,this.$store.dispatch("user/logout");t.next=4;break;case 3:this.$router.push("/login");case 4:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)}),show_title:function(t){Object(a.a)({message:t})}}}},e6e2:function(t,e,r){"use strict";r.r(e),r("8e6e"),r("ac6a"),r("456d"),r("47e2");var n=r("2241"),a=(r("96cf"),r("1da1")),s=r("2f62"),i=r("9f53"),o=r("1b69"),c="home/",u=function(t,e){return Object(o.a)(c+"orderstock",t,"post",e)},d=function(t,e){return Object(o.a)(c+"orderadd",t,"post",e)},p=function(t,e){return Object(o.a)(c+"addrinfo",t,"post",e)};function f(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)),n}var h,l,m,b,g,v;s={mixins:[i.a],computed:function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?f(Object(r),!0).forEach((function(e){var n,a;n=t,e=r[a=e],a in n?Object.defineProperty(n,a,{value:e,enumerable:!0,configurable:!0,writable:!0}):n[a]=e})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},Object(s.b)(["ad","goodsNum"])),data:function(){return{num:this.goodsNum,total:0,address:[]}},mounted:function(){this.ad&&this.ad.id&&this.initData(this.ad.id),this.getStock()},methods:{getaddress:(v=Object(a.a)(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.set_user_goodsNum(this.num||this.goodsNum);case 2:(e=t.sent)&&0===e.code&&window.vm.$router.push({path:"/address",query:{id:this.ad&&this.ad.id?this.ad.id:"0"}});case 4:case"end":return t.stop()}}),t,this)}))),function(){return v.apply(this,arguments)}),getStock:(g=Object(a.a)(regeneratorRuntime.mark((function t(){var e;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.loading){t.next=14;break}return t.next=3,u({});case 3:if(!(e=t.sent)||0!=e.code){t.next=8;break}this.total=e.data.stock,t.next=14;break;case 8:if(e&&100<=e.code&&e.code<=104)return t.next=11,this.logout();t.next=13;break;case 11:t.next=14;break;case 13:this.total=0;case 14:case"end":return t.stop()}}),t,this)}))),function(){return g.apply(this,arguments)}),initData:(b=Object(a.a)(regeneratorRuntime.mark((function t(e){var r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,p({id:e});case 2:if(!(r=t.sent)||0!==r.code){t.next=6;break}t.next=12;break;case 6:if(r&&100<=r.code&&r.code<=104)return t.next=9,this.logout();t.next=11;break;case 9:t.next=12;break;case 11:this.$store.dispatch("user/set_ad",{}).then((function(t){}));case 12:case"end":return t.stop()}}),t,this)}))),function(t){return b.apply(this,arguments)}),backNum:function(t){this.num=t},handleChange:function(t){},placeOrder:(m=Object(a.a)(regeneratorRuntime.mark((function t(){var e=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.loading){t.next=14;break}if(!this.ad||!this.ad.id){t.next=13;break}if(this.num=this.num||this.goodsNum,isNaN(this.num)&&(this.num=0),0===this.total)return this.show_title("当前商品库存为0,无法购买!"),t.abrupt("return");t.next=7;break;case 7:if(0===this.num)return this.show_title("购买数量不能为0!"),t.abrupt("return");t.next=10;break;case 10:n.a.confirm({title:"确认下单?"}).then(Object(a.a)(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.placeHttpOrder();case 2:case"end":return t.stop()}}),t)})))).catch((function(){})),t.next=14;break;case 13:this.show_title("请选择收货地址!");case 14:case"end":return t.stop()}}),t,this)}))),function(){return m.apply(this,arguments)}),placeHttpOrder:(l=Object(a.a)(regeneratorRuntime.mark((function t(){var e,r;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.loading=!0,r={addrid:this.ad.id,num:this.num+""},t.next=4,d(r);case 4:if(e=t.sent,this.loading=!1,e&&0==e.code)return t.next=9,this.set_user_goodsNum(0);t.next=13;break;case 9:(r=t.sent)&&0===r.code&&window.vm.$router.push({path:"/orderRes",query:{id:e.data.orderid}}),t.next=19;break;case 13:if(e&&100<=e.code&&e.code<=104)return t.next=16,this.logout();t.next=18;break;case 16:t.next=19;break;case 18:this.show_title("连接超时,请重新登录");case 19:case"end":return t.stop()}}),t,this)}))),function(){return l.apply(this,arguments)}),set_user_goodsNum:(h=Object(a.a)(regeneratorRuntime.mark((function t(e){var r=this;return regeneratorRuntime.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,n){r.$store.dispatch("user/set_goodsNum",e).then((function(e){t(e)}))})));case 1:case"end":return t.stop()}}),t)}))),function(t){return h.apply(this,arguments)})}},r("7027"),r=r("2877"),s=Object(r.a)(s,(function(){var t=this,e=t.$createElement;e=t._self._c||e;return e("div",{staticClass:"product",staticStyle:{"padding-top":"46px"}},[e("van-nav-bar",{staticClass:"van-nav-bar-my-fixed",attrs:{title:"产品",fixed:""}}),e("div",{directives:[{name:"loading",rawName:"v-loading",value:t.loading,expression:"loading"}]},[e("div",{staticClass:"kucun"},[t._v("可用库存:"+t._s(t.total)+"袋/2.5kg")]),t.ad&&t.ad.id?e("div",{staticClass:"item-ad",on:{click:t.getaddress}},[e("p",{staticClass:"item-ad__name"},[e("span",[t._v(t._s(t.ad.name))]),e("span",{staticClass:"fr"},[t._v(t._s(t.ad.tel))])]),e("p",{staticClass:"item-ad__address"},[e("span",[t._v(t._s(t.ad.address))])])]):e("div",{staticClass:"kong",on:{click:t.getaddress}},[t._v("添加地址")]),e("div",{staticClass:"product-footer clear"},[e("div",{staticClass:"fl"},[e("input-number",{attrs:{numb:t.num||t.goodsNum,max:t.total},on:{backNum:t.backNum}})],1),e("van-button",{staticClass:"fr",staticStyle:{width:"30%"},attrs:{type:"info"},on:{click:t.placeOrder}},[t._v("确认下单")])],1)])],1)}),[],!1,null,"0bb0af88",null);e.default=s.exports}}]);