shop.js 8.7 KB

1
  1. (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pages/index/shop"],{"07c4":function(t,e,s){"use strict";(function(t){s("0bef"),s("921b");o(s("66fd"));var e=o(s("dafc"));function o(t){return t&&t.__esModule?t:{default:t}}t(e.default)}).call(this,s("543d")["createPage"])},ae95:function(t,e,s){},bd83:function(t,e,s){"use strict";s.r(e);var o=s("f669"),i=s.n(o);for(var n in o)"default"!==n&&function(t){s.d(e,t,(function(){return o[t]}))}(n);e["default"]=i.a},c382:function(t,e,s){"use strict";var o=s("ae95"),i=s.n(o);i.a},d9a8:function(t,e,s){"use strict";var o,i=function(){var t=this,e=t.$createElement,s=(t._self._c,t.__map(t.datalist.images,(function(e,s){var o=e.goodsimage_url.substr(0,e.goodsimage_url.indexOf("_"));return{$orig:t.__get_orig(e),g0:o}})));t.$mp.data=Object.assign({},{$root:{l0:s}})},n=[];s.d(e,"b",(function(){return i})),s.d(e,"c",(function(){return n})),s.d(e,"a",(function(){return o}))},dafc:function(t,e,s){"use strict";s.r(e);var o=s("d9a8"),i=s("bd83");for(var n in i)"default"!==n&&function(t){s.d(e,t,(function(){return i[t]}))}(n);s("c382");var a,r=s("f0c5"),c=Object(r["a"])(i["default"],o["b"],o["c"],!1,null,null,null,!1,o["a"],a);e["default"]=c.exports},f669:function(t,e,s){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var o=n(s("a34a")),i=s("2f62");function n(t){return t&&t.__esModule?t:{default:t}}function a(t,e,s,o,i,n,a){try{var r=t[n](a),c=r.value}catch(l){return void s(l)}r.done?e(c):Promise.resolve(c).then(o,i)}function r(t){return function(){var e=this,s=arguments;return new Promise((function(o,i){var n=t.apply(e,s);function r(t){a(n,o,i,r,c,"next",t)}function c(t){a(n,o,i,r,c,"throw",t)}r(void 0)}))}}function c(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),s.push.apply(s,o)}return s}function l(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?c(Object(s),!0).forEach((function(e){d(t,e,s[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):c(Object(s)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))}))}return t}function d(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}var u=function(){s.e("component/Gobacktop").then(function(){return resolve(s("e3cf"))}.bind(null,s)).catch(s.oe)},h=function(){s.e("component/uinNumber").then(function(){return resolve(s("31a6"))}.bind(null,s)).catch(s.oe)},g=function(){s.e("component/assess").then(function(){return resolve(s("553f"))}.bind(null,s)).catch(s.oe)},p=function(){s.e("component/uni-icon/uni-icon").then(function(){return resolve(s("d4ee"))}.bind(null,s)).catch(s.oe)},f={components:{uniIcon:p,assess:g,uninumberbox:h,Gobacktop:u},data:function(){return{isTop:!1,arrayId:[],bottomtop:"55upx",scopemapId:0,showdialog:!1,has_collected:!1,cartnumber:0,changnumber:100,ismax:!1,goods_storage:"",nuberImg:"",firstImg:"",shopnumber:1,pictureUrl:this.pictureUrl,datalist:{},store_id:0,goodId:0,goods_id:0,windowHeight:0,iScrolltop:1,active:0,scrollTop:0,old:{scrollTop:0},specClass:"none",specSelected:[],totalprice:0,firstprice:0,favorite:!0,shareList:[],imgList:[],desc:"\n \t\t\t\t\t\n \t\t\t\t",specList:[]}},onLaunch:function(){this.active=1},computed:l({},(0,i.mapState)(["hasLogin","userInfo","successlogion"])),onShow:function(){var e=this;t.getSystemInfo({success:function(t){e.windowHeight=t.screenHeight}})},onLoad:function(){var t=r(o.default.mark((function t(e){return o.default.wrap((function(t){while(1)switch(t.prev=t.next){case 0:this.goodId=e.id,this.store_id=e.store_id,this.getshopdetail();case 3:case"end":return t.stop()}}),t,this)})));function e(e){return t.apply(this,arguments)}return e}(),onShareAppMessage:function(e){t.showShareMenu({withShareTicket:!0});var s=this,o=this.goodId,i=this.store_id;return e.from,{title:s.datalist.goods_name,path:"/pages/index/shop?id=".concat(o,"&store_id=").concat(i),imageUrl:s.nuberImg}},onReady:function(){},methods:{getop:function(){this.scrollTop=this.old.scrollTop,this.$nextTick((function(){this.scrollTop=0})),this.isTop=!1},goIndex:function(){var e=this.store_id;t.redirectTo({url:"/pages/index/hotel?id=".concat(e)})},changestorage:function(t){this.shopnumber=t;var e=this.firstprice;this.totalprice=e*this.shopnumber},getshopdetail:function(){var t=this,e={};e.goods_commonid=this.goodId,e.store_id=this.store_id,this.request({url:"/v2/goods/detail",method:"POST",data:e,success:function(e){var s=e.data.data;t.cartnumber=s.cart,t.has_collected=s.has_collected;var o=s;o.images.forEach((function(e){t.firstImg=t.pictureUrl+"/uploads/home/store/goods/"+e.goodsimage_url.substr(0,e.goodsimage_url.indexOf("_"))+"/"+e.goodsimage_url})),0==o.spec_list.length?(t.datalist=s,t.goods_id=s.goods_list[0].goods_id,t.goods_storage=s.goods_storage):(o.spec_list[0].value_list.forEach((function(t,e){t.goods_storage=s.goods_list[e].goods_storage})),t.datalist=o);new RegExp('stlye="" ',"gi");t.datalist.goods_body=t.datalist.goods_body.replace(/\(<img\)/gi,"");var i=new RegExp("<img","gi");t.datalist.goods_body=t.datalist.goods_body.replace(i,'<img class="changeimg"')}})},shopDetail:function(){var e=this.goodId,s=this.store_id;t.navigateTo({url:"/pages/index/commemt?goodId=".concat(e,"&store_id=").concat(s)})},onChange:function(t){this.active=t.detail.name,console.log(this.active)},toggleSpec:function(){this.specClass="show"},openCar:function(){if(this.hasLogin&&this.successlogion){var e=this.store_id;t.navigateTo({url:"/pages/index/cart?store_id=".concat(e)})}else t.navigateTo({url:"/pages/myCenter/logion"})},buynow:function(){var e=this;if(this.hasLogin&&this.successlogion){if(1==this.datalist.store_id||1!=this.datalist.goods_state||this.datalist.goods_storage<1)return void this.$msg("商品已下架");if(0==this.specSelected.length&&0!=this.datalist.spec_list.length)return this.$msg("请选择规格数量"),void(this.specClass="show");if(0==this.specSelected.length&&0==this.datalist.spec_list.length)return this.specClass="show",void(this.specSelected=this.datalist.goods_list);var s=[];s.push({}),s[0].goods_id=this.goods_id,s[0].buy_num=this.shopnumber,this.request({url:"/v1/order/save_og",method:"post",data:{store_id:this.store_id,goods:JSON.stringify(s)},success:function(s){var o=e.store_id,i=s.data.data.order_id;e.specClass="none",t.navigateTo({url:"/pages/index/sureBuy?store=".concat(o,"&order_id=").concat(i)})}})}else t.navigateTo({url:"/pages/myCenter/logion"})},addCar:function(){var e=this;if(this.hasLogin&&this.successlogion){if(1==this.datalist.store_id||1!=this.datalist.goods_state||this.datalist.goods_storage<1)return void this.$msg("商品已下架");if(0==this.specSelected.length&&0==this.datalist.spec_list.length)return this.specClass="show",void(this.specSelected=this.datalist.goods_list);if(0==this.specSelected.length&&0!=this.datalist.spec_list.length)return this.specClass="show",void this.$msg("请选择规格数量");this.request({url:"/v2/order/add_cart",method:"POST",data:{goods_id:this.goods_id,goods_num:this.shopnumber},success:function(){e.$msg("商品添加成功"),e.specClass="none",e.getshopdetail()}})}else t.navigateTo({url:"/pages/myCenter/logion"})},closeCar:function(){this.specClass="none"},selectSpec:function(t,e,s,o){var i=this;if(this.specSelected=[],0!=o){this.datalist.spec_list[t].value_list;this.datalist.spec_list[t].value_list.forEach((function(t){t.value_id===e?i.$set(t,"selected",!0):i.$set(t,"selected",!1)}));for(var n=[],a=0;a<this.datalist.spec_list.length;a++)for(var r=0;r<this.datalist.spec_list[a].value_list.length;r++)this.datalist.spec_list[a].value_list[r].selected&&n.push(this.datalist.spec_list[a].value_list[r].value_id);if(this.arrayId=n,this.arrayId.length==this.datalist.spec_list.length){this.scopemapId=n.join("_");var c=this.datalist.spec_map[this.scopemapId],l=this.datalist.goods_list[c];l.value_name=s,this.nuberImg=l.spec_img,this.specSelected.push(l),this.goods_storage=l.goods_storage,this.goods_id=l.goods_id,this.firstprice=l.goods_price,this.totalprice=l.goods_price*this.shopnumber}}else this.$msg("商品没库存啦")},upper:function(t){},lower:function(t){console.log("底部")},scroll:function(t){this.old.scrollTop=t.detail.scrollTop,t.detail.scrollTop>this.windowHeight?this.iScrolltop=2:this.iScrolltop=1,t.detail.scrollTop>400?this.isTop=!0:this.isTop=!1},toFavorite:function(){var e=this;this.hasLogin&&this.successlogion?this.request({url:"/v1/favorites/collect",method:"post",data:{type:"goods",fav_id:this.goodId},success:function(){e.getshopdetail()}}):t.navigateTo({url:"/pages/myCenter/logion"})},buy:function(){t.navigateTo({url:"./sureBuy"})},stopPrevent:function(){}}};e.default=f}).call(this,s("543d")["default"])}},[["07c4","common/runtime","common/vendor"]]]);