Files
Smart-Farm/front/shop/pages/detail.js
2025-12-22 17:13:05 +08:00

1 line
11 KiB
JavaScript

(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["shop/pages/detail"],{"0394":function(t,e,n){"use strict";n.r(e);var r=n("629e"),i=n("7a37");for(var o in i)["default"].indexOf(o)<0&&function(t){n.d(e,t,(function(){return i[t]}))}(o);n("31ee");var s=n("f0c5"),a=Object(s["a"])(i["default"],r["b"],r["c"],!1,null,null,null,!1,r["a"],void 0);e["default"]=a.exports},"20e5":function(t,e,n){"use strict";(function(t){var r=n("4ea4");Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=r(n("2eee")),o=r(n("448a")),s=r(n("c973")),a=r(n("9523")),u=n("26cb");function c(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function l(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?c(Object(n),!0).forEach((function(e){(0,a.default)(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var d={components:{parser:function(){Promise.all([n.e("common/vendor"),n.e("components/jyf-Parser/index")]).then(function(){return resolve(n("c84c"))}.bind(null,n)).catch(n.oe)}},data:function(){return{options:{},detail:{},speImg:"",videoContexts:{},shopItemInfo:{},selectArr:[],subIndex:[],currentSpecs:{},currentNum:1,totalPrice:0,seckillWidth:119,param:{page:1,limit:10},list:{data:[]},add_order_type:1}},computed:(0,u.mapState)({primaryColor:function(t){return t.config.configInfo.primaryColor},subColor:function(t){return t.config.configInfo.subColor},userInfo:function(t){return t.user.userInfo},shopCarList:function(t){return t.order.shopCarList}}),onLoad:function(t){this.$util.showLoading(),this.options=t,this.initIndex()},onPullDownRefresh:function(){t.showNavigationBarLoading(),this.initRefresh(),t.stopPullDownRefresh()},onShareAppMessage:function(t){var e=this.userInfo.id,n=this.detail,r=n.id,i=n.goods_name,o=n.cover,s="/shop/pages/detail?pid=".concat(e,"&id=").concat(r);return this.$util.log(s),{title:i,imageUrl:o,path:s}},methods:l(l({},(0,u.mapActions)(["getConfigInfo","getShopCarList"])),{},{initIndex:function(){var t=this;return(0,s.default)(i.default.mark((function e(){return i.default.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,Promise.all([t.getDetail(),t.getList()]);case 2:case"end":return e.stop()}}),e)})))()},initRefresh:function(){this.initIndex()},countEnd:function(){var t=this;this.$util.log("倒计时完了"),setTimeout((function(){t.initRefresh()}),1e3)},linkpress:function(t){console.log("linkpress",t)},getDetail:function(){var t=this;return(0,s.default)(i.default.mark((function e(){var n,r,o,s,a,u;return i.default.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return n=t.options.id,e.next=3,t.$api.shop.goodsInfo({id:n});case 3:if(r=e.sent,r.spe_price.map((function(t){if(t.is_show=!0,t.kill_atv&&t.kill_atv.id){var e=t.kill_atv,n=e.price,r=e.init_price;t.kill_atv.reduce_price=1*r-1*n}})),r.spe_text.map((function(e){e.cate.length<1||(t.selectArr.push(""),t.subIndex.push(-1))})),r.kill_list&&r.kill_list.id&&(o=r.kill_list,s=o.price,a=o.init_price,r.kill_list.reduce_price=1*a-1*s),r.store_info.star_percent=(1*r.store_info.star/5*100).toFixed(2)+"%",t.detail=r,t.speImg="",t.shopItemInfo={},t.selectArr=[],t.subIndex=[],t.currentSpecs={},t.checkItem(),t.checkInpath(-1),setTimeout((function(){t.toSetResHeight()}),100),!(t.shopItemInfo.length<1)){e.next=19;break}return e.abrupt("return");case 19:if(u=t.shopItemInfo[Object.keys(t.shopItemInfo)[0]],u){e.next=23;break}return t.$util.hideAll(),e.abrupt("return");case 23:t.currentSpecs=u,t.selectArr=u.spe_array_text,t.detail.spe_text.forEach((function(e,n){e.cate.length<1||e.cate.forEach((function(e,r){u.spe_array_text.forEach((function(i,o){i==e.id&&(1==e.is_img&&(t.speImg=e.image),t.subIndex[o]=r,t.checkInpath(n))}))}))})),t.$util.hideAll();case 27:case"end":return e.stop()}}),e)})))()},toSetResHeight:function(){var e=this;return(0,s.default)(i.default.mark((function n(){var r,o,s,a,u;return i.default.wrap((function(n){while(1)switch(n.prev=n.next){case 0:r=e.detail.kill_list,o=void 0===r?{}:r,s=e.currentSpecs,a=void 0===s?{}:s,a&&a.id&&a.kill_atv&&a.kill_atv.id||o&&o.id?(e.seckillWidth=119,u=t.createSelectorQuery(),u.select(".reduce-info").boundingClientRect((function(t){console.log(t,"=====data"),e.seckillWidth=t.width+5})).exec()):e.seckillWidth=0;case 3:case"end":return n.stop()}}),n)})))()},getList:function(){var t=this;return(0,s.default)(i.default.mark((function e(){var n,r,o,s;return i.default.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return n=t.list,r=t.options.id,o=Object.assign({},t.param,{goods_id:r,type:3,is_goods:0}),e.next=5,t.$api.mine.goodsEvaluateList(o);case 5:s=e.sent,1==t.param.page||(s.data=n.data.concat(s.data)),t.list=s,t.loading=!1,t.$util.hideAll();case 9:case"end":return e.stop()}}),e)})))()},playCurrent:function(t){var e=this.current;for(var n in this.current=t,this.videoContexts)if(n!=t)this.videoContexts[n].pause(),this.text[n].is_play=!1;else if(t==e){var r=this.text[n].is_play;r?this.videoContexts[n].pause():this.videoContexts[n].play(),this.text[n].is_play=!r}else this.videoContexts[n].play(),this.text[n].is_play=!0},onPlay:function(t){},onPause:function(t){},onEnded:function(t){var e=this.$util.getDataSet(t),n=e.index;this.detail.text[n].is_play=!1},onError:function(t){},onTimeUpdate:function(t){},onWaiting:function(t){},onProgress:function(t){},onLoadedMetaData:function(t){},toPreviewImage:function(t,e){var n=this.list.data[t].imgs;this.$util.previewImage({current:n[e],urls:n})},skuClick:function(t,e,n){var r=this;if(t.is_show){var i=this.selectArr[e]!=t.id;this.$set(this.selectArr,e,i?t.id:""),this.$set(this.subIndex,e,i?n:"-1"),1==t.is_img&&(this.speImg=i?t.image:""),this.checkInpath(e),this.countBuy(),setTimeout((function(){r.toSetResHeight()}),10)}},checkInpath:function(t){for(var e=0,n=this.detail.spe_text.length;e<n;e++)if(e!=t)for(var r=this.detail.spe_text[e].cate.length,i=0;i<r;i++)if(-1==this.subIndex[e]||i!=this.subIndex[e]){var s=(0,o.default)(this.selectArr);this.$set(s,e,this.detail.spe_text[e].cate[i].id);var a=s.filter((function(t){return""!==t&&"undefined"!==typeof t}));this.shopItemInfo.hasOwnProperty(a)?this.$set(this.detail.spe_text[e].cate[i],"is_show",!0):this.$set(this.detail.spe_text[e].cate[i],"is_show",!1)}},checkItem:function(){var t=this,e=[];this.detail.spe_price.forEach((function(t){t.is_show&&(t.stock<1||e.push(t))}));e.reduce((function(e,n){return e.concat(n.spe_array_text.reduce((function(e,r){return e.concat(e.map((function(e){return t.shopItemInfo.hasOwnProperty([].concat((0,o.default)(e),[r]))||(t.shopItemInfo[[].concat((0,o.default)(e),[r])]=n),[].concat((0,o.default)(e),[r])})))}),[[]]))}),[[]])},countBuy:function(){var t=this;return(0,s.default)(i.default.mark((function e(){var n,r,o,s,a;return i.default.wrap((function(e){while(1)switch(e.prev=e.next){case 0:n=t.selectArr.every((function(t){return""!=t})),t.currentSpecs=n?t.shopItemInfo[t.selectArr]:{},t.currentNum=0,t.currentSpecs.stock>=1&&(t.currentNum=1),r=t.currentSpecs,o=r.id,s=void 0===o?0:o,a=r.price,t.totalPrice=s?(a*t.currentNum).toFixed(2):0;case 6:case"end":return e.stop()}}),e)})))()},toAddOrder:function(t){this.add_order_type=t,this.$refs.show_spe_item.open()},changeNum:function(t){var e=this;return(0,s.default)(i.default.mark((function n(){var r,o,s,a,u,c,l;return i.default.wrap((function(n){while(1)switch(n.prev=n.next){case 0:if(r=e.currentSpecs.id,r){n.next=4;break}return e.$util.showToast({title:"请选择规格"}),n.abrupt("return");case 4:if(o=1*(e.currentNum+t),!(o<1)){n.next=8;break}return e.$util.showToast({title:"此商品最少购买1件"}),n.abrupt("return");case 8:if(s=1*e.currentSpecs.stock,!(o>s)){n.next=12;break}return e.$util.showToast({title:"数量不能大于库存"}),n.abrupt("return");case 12:e.currentNum=o,a=e.currentSpecs,u=a.id,c=void 0===u?0:u,l=a.price,e.cur_wholesale.id?1*e.cur_wholesale.total_price:0,e.totalPrice=c?(l*e.currentNum).toFixed(2):0;case 16:case"end":return n.stop()}}),n)})))()},toAddCar:function(){var t=this;return(0,s.default)(i.default.mark((function e(){var n,r,o,s,a,u,c,l,d,f,p,h,g,_;return i.default.wrap((function(e){while(1)switch(e.prev=e.next){case 0:if(n=t.add_order_type,r=JSON.parse(JSON.stringify(n)),r=1===r?1:2,o=t.detail,s=o.id,a=o.store,u=a[0],c=t.currentSpecs,l=c.id,d=c.integral_atv,f=void 0===d?{}:d,l){e.next=9;break}return t.$util.showToast({title:"请选择规格"}),e.abrupt("return");case 9:if(p=t.currentNum,h=t.currentSpecs.stock,!(p<1)){e.next=14;break}return t.$util.showToast({title:"此商品最少购买1件"}),e.abrupt("return");case 14:if(!(p>1*h)){e.next=17;break}return t.$util.showToast({title:"数量不能大于库存"}),e.abrupt("return");case 17:return t.$util.showLoading(),g={store_id:u,goods_id:s,spe_id:l,goods_num:p,is_show:r},e.next=21,t.$api.shop.addCar(g);case 21:if(t.$util.hideAll(),1!=r){e.next=28;break}return t.$util.showToast({title:"加入成功"}),e.next=26,t.getShopCarList();case 26:e.next=32;break;case 28:t.$refs.show_spe_item.close(),_="/shop/pages/order?is_show=2",f.id&&4===n&&(_="".concat(_,"&no_i=0")),t.$util.goUrl({url:_});case 32:case"end":return e.stop()}}),e)})))()}})};e.default=d}).call(this,n("543d")["default"])},"2e7a":function(t,e,n){},"31ee":function(t,e,n){"use strict";var r=n("2e7a"),i=n.n(r);i.a},"3db6":function(t,e,n){"use strict";(function(t,e){var r=n("4ea4");n("b03e");r(n("66fd"));var i=r(n("0394"));t.__webpack_require_UNI_MP_PLUGIN__=n,e(i.default)}).call(this,n("bc2e")["default"],n("543d")["createPage"])},"629e":function(t,e,n){"use strict";n.d(e,"b",(function(){return r})),n.d(e,"c",(function(){return i})),n.d(e,"a",(function(){}));var r=function(){var t=this,e=t.$createElement,n=(t._self._c,t.detail.id&&t.list.all_count>0?t.__map(t.list.data,(function(e,n){var r=t.__get_orig(e),i=n<2?e.imgs&&e.imgs.length>0:null,o=n<2&&i?t.__map(e.imgs,(function(n,r){var i=t.__get_orig(n),o=r<3?2==r&&e.imgs.length>3:null,s=r<3&&o?e.imgs.length:null;return{$orig:i,g1:o,g2:s}})):null;return{$orig:r,g0:i,l0:o}})):null);t._isMounted||(t.e0=function(e){return e.stopPropagation(),t.$util.goUrl({url:"/mine/pages/evaluate/more?id="+t.options.id+"&type=3"})},t.e1=function(e){return t.$util.goUrl({url:"/shop/pages/store?id="+t.detail.store_info.id})},t.e2=function(e){return e.stopPropagation(),t.$util.goUrl({url:"/pages/home",openType:"switchTab"})},t.e3=function(e){return e.stopPropagation(),t.$util.goUrl({url:"/shop/pages/car"})},t.e4=function(e){return e.stopPropagation(),t.$refs.show_spe_item.close()}),t.$mp.data=Object.assign({},{$root:{l1:n}})},i=[]},"7a37":function(t,e,n){"use strict";n.r(e);var r=n("20e5"),i=n.n(r);for(var o in r)["default"].indexOf(o)<0&&function(t){n.d(e,t,(function(){return r[t]}))}(o);e["default"]=i.a}},[["3db6","common/runtime","common/vendor"]]]);