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

1 line
12 KiB
JavaScript

(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["shop/pages/store"],{7949:function(t,e,n){"use strict";var r=n("a0cc"),a=n.n(r);a.a},"7ba6":function(t,e,n){"use strict";n.r(e);var r=n("f386"),a=n("e8fa");for(var s in a)["default"].indexOf(s)<0&&function(t){n.d(e,t,(function(){return a[t]}))}(s);n("7949");var i=n("f0c5"),o=Object(i["a"])(a["default"],r["b"],r["c"],!1,null,null,null,!1,r["a"],void 0);e["default"]=o.exports},a0cc:function(t,e,n){},a65c:function(t,e,n){"use strict";(function(t){var r=n("4ea4");Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var a=r(n("2eee")),s=r(n("448a")),i=r(n("9523")),o=r(n("c973")),c=n("26cb");function u(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?u(Object(n),!0).forEach((function(e){(0,i.default)(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}var d={components:{},data:function(){return{options:{},storeInfo:{},cateList:[],cateInd:0,cateId:0,changeCate:"changeCate0",shopHeight:0,param:{page:1,cate_id:0},list:{data:[]},loading:!0,current:0,goodsInd:0,detail:{},speImg:"",shopItemInfo:{},selectArr:[],subIndex:[],currentSpecs:{},currentNum:1,totalPrice:0,carIsHave:{id:0,isHave:!1},lockTap:!1}},computed:(0,c.mapState)({primaryColor:function(t){return t.config.configInfo.primaryColor},subColor:function(t){return t.config.configInfo.subColor},configInfo:function(t){return t.config.configInfo},userInfo:function(t){return t.user.userInfo},shopCarList:function(t){return t.order.shopCarList}}),onLoad:function(t){var e=this;return(0,o.default)(a.default.mark((function n(){return a.default.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return e.$util.showLoading(),e.options=t,n.next=4,e.initIndex();case 4:case"end":return n.stop()}}),n)})))()},onPullDownRefresh:function(){t.showNavigationBarLoading(),this.initRefresh(),t.stopPullDownRefresh()},onReachBottom:function(){this.list.current_page>=this.list.last_page||this.loading||(this.param.page=this.param.page+1,this.loading=!0,this.getList())},methods:l(l(l({},(0,c.mapActions)(["getConfigInfo","updateCommonOptions","getShopCarList"])),(0,c.mapMutations)(["updateUserItem"])),{},{initIndex:function(){var t=this;return(0,o.default)(a.default.mark((function e(){return a.default.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return t.$refs.show_spe_item.close(),t.$refs.show_car_item.close(),e.next=4,Promise.all([t.getCateList(),t.getShopCarList()]);case 4:setTimeout((function(){t.toSetResHeight()}),200);case 5:case"end":return e.stop()}}),e)})))()},initRefresh:function(){this.param.page=1,this.initIndex()},getCateList:function(){var t=this;return(0,o.default)(a.default.mark((function e(){var n,r,s,i,o,c;return a.default.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return n=t.options.id,e.next=3,t.$api.shop.goodsIndex({store_id:n});case 3:if(r=e.sent,s=r.cate_id,i=r.store_info,t.storeInfo=i,t.cateList=s,0!=s.length){e.next=12;break}return t.$util.hideAll(),t.loading=!1,e.abrupt("return");case 12:o=t.cateId,c=s.findIndex((function(t){return t.id==o})),c=-1==c?0:c,t.cateInd=c,t.cateId=s[c].id,t.getList();case 18:case"end":return e.stop()}}),e)})))()},toSearch:function(t){this.loading=!0,this.param.page=1,this.param.goods_name=t,this.getList()},getList:function(){var t=this;return(0,o.default)(a.default.mark((function e(){var n,r,s,i,o;return a.default.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return n=t.list,r=t.cateId,s=t.options.id,i=Object.assign({},t.param,{store_id:s,cate_id:r}),e.next=5,t.$api.shop.goodsList(i);case 5:o=e.sent,1==t.param.page||(o.data=n.data.concat(o.data)),t.list=o,t.loading=!1,t.$util.hideAll();case 9:case"end":return e.stop()}}),e)})))()},toSetResHeight:function(){var e=this;return(0,o.default)(a.default.mark((function n(){var r;return a.default.wrap((function(n){while(1)switch(n.prev=n.next){case 0:r=t.createSelectorQuery(),r.select(".shop-store-info").boundingClientRect((function(t){e.shopHeight=t.height})).exec();case 2:case"end":return n.stop()}}),n)})))()},tabChange:function(e,n){var r=this.$util.getDataSet(e),a=r.id,s=r.type,i=r.key;this["".concat(s,"Ind")]=n,this[i]="".concat(i).concat(n),this["".concat(s,"Id")]=a,"cate"==s&&(t.pageScrollTo({scrollTop:0}),this.cateId=a),this.param.page=1,this.getList()},getCarInfo:function(){var t=arguments,e=this;return(0,o.default)(a.default.mark((function n(){var r;return a.default.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return r=t.length>0&&void 0!==t[0]?t[0]:2,n.next=3,e.getShopCarList();case 3:setTimeout((function(){1==r&&e.shopCarList.list.length<1&&e.$refs.show_car_item.close(),e.checkCarIsHave()}),500);case 4:case"end":return n.stop()}}),n)})))()},getGoodsSpec:function(t){var e=this;return(0,o.default)(a.default.mark((function n(){var r,s,i;return a.default.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return e.current=0,e.goodsInd=t,r=e.list.data[t].id,n.next=5,e.$api.shop.goodsInfo({id:r});case 5:if(s=n.sent,s.spe_price.map((function(t){t.is_show=!0})),s.spe_text.map((function(t){t.cate.length<1||(e.selectArr.push(""),e.subIndex.push(-1))})),e.detail=s,e.speImg="",e.shopItemInfo={},e.selectArr=[],e.subIndex=[],e.currentSpecs={},e.checkItem(),e.checkInpath(-1),!(e.shopItemInfo.length<1)){n.next=18;break}return n.abrupt("return");case 18:if(i=e.shopItemInfo[Object.keys(e.shopItemInfo)[0]],i){n.next=22;break}return e.$util.hideAll(),n.abrupt("return");case 22:return e.currentSpecs=i,e.selectArr=i.spe_array_text,e.detail.spe_text.forEach((function(t,n){t.cate.length<1||t.cate.forEach((function(t,r){i.spe_array_text.forEach((function(a,s){a==t.id&&(1==t.is_img&&(e.speImg=t.image),e.subIndex[s]=r,e.checkInpath(n))}))}))})),e.$util.hideAll(),n.next=28,e.checkCarIsHave();case 28:e.$refs.show_spe_item.open();case 29:case"end":return n.stop()}}),n)})))()},skuClick:function(t,e,n){if(t.is_show){var r=this.selectArr[e]!=t.id;this.$set(this.selectArr,e,r?t.id:""),this.$set(this.subIndex,e,r?n:"-1"),1==t.is_img&&(this.speImg=r?t.image:""),this.checkInpath(e),this.countBuy()}},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,a=0;a<r;a++)if(-1==this.subIndex[e]||a!=this.subIndex[e]){var i=(0,s.default)(this.selectArr);this.$set(i,e,this.detail.spe_text[e].cate[a].id);var o=i.filter((function(t){return""!==t&&"undefined"!==typeof t}));this.shopItemInfo.hasOwnProperty(o)?this.$set(this.detail.spe_text[e].cate[a],"is_show",!0):this.$set(this.detail.spe_text[e].cate[a],"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,s.default)(e),[r]))||(t.shopItemInfo[[].concat((0,s.default)(e),[r])]=n),[].concat((0,s.default)(e),[r])})))}),[[]]))}),[[]])},countBuy:function(){var t=this;return(0,o.default)(a.default.mark((function e(){var n,r,s,i,o;return a.default.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return 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,s=r.id,i=void 0===s?0:s,o=r.price,t.totalPrice=i?(o*t.currentNum).toFixed(2):0,e.next=8,t.checkCarIsHave();case 8:case"end":return e.stop()}}),e)})))()},checkCarIsHave:function(){var t=this;return(0,o.default)(a.default.mark((function e(){var n,r,s,i,o,c,u,l,d,f,p,h;return a.default.wrap((function(e){while(1)switch(e.prev=e.next){case 0:n=!1,r=t.currentSpecs,s=r.id,i=void 0===s?0:s,o=r.goods_id,c=void 0===o?0:o,u=r.cart_id,l=void 0===u?0:u,d=t.options.id,f=t.currentNum,p=void 0===f?0:f,t.shopCarList.list.map((function(t){t.farmer_id==d&&t.goods_list.map((function(t){t.goods_id==c&&t.spe_id==i&&(n=!0,p=t.goods_num,l=t.id)}))})),h={id:l,isHave:n},console.log(h,"========carIsHave"),t.$set(t,"carIsHave",h),t.$set(t,"currentNum",p);case 9:case"end":return e.stop()}}),e)})))()},changeNum:function(t){var e=this;return(0,o.default)(a.default.mark((function n(){var r,s,i,o,c,u,l;return a.default.wrap((function(n){while(1)switch(n.prev=n.next){case 0:if(r=e.currentSpecs,s=r.id,r.stock,s){n.next=4;break}return e.$util.showToast({title:"请选择规格"}),n.abrupt("return");case 4:return i=e.detail,o=i.id,c=i.store,u=c[0],l=t>0?o:e.carIsHave.id,n.next=9,e.toUpdateCar(u,l,s,t,2);case 9:case"end":return n.stop()}}),n)})))()},toAddCar:function(){var t=this;return(0,o.default)(a.default.mark((function e(){var n,r,s,i,o;return a.default.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return n=t.detail,r=n.id,s=n.store,i=s[0],o=t.currentSpecs.id,e.next=5,t.toUpdateCar(i,r,o,1,2);case 5:case"end":return e.stop()}}),e)})))()},toUpdateCar:function(t,e,n,r){var s=arguments,i=this;return(0,o.default)(a.default.mark((function o(){var c,u,l;return a.default.wrap((function(a){while(1)switch(a.prev=a.next){case 0:if(c=s.length>4&&void 0!==s[4]?s[4]:1,u=r>0?"addCar":"delCar",l=r>0?{store_id:t,goods_id:e,spe_id:n,goods_num:r}:{id:e,goods_num:1},!i.lockTap){a.next=5;break}return a.abrupt("return");case 5:return i.lockTap=!0,a.prev=6,a.next=9,i.$api.shop[u](l);case 9:return i.lockTap=!1,a.next=12,i.getCarInfo(c);case 12:a.next=17;break;case 14:a.prev=14,a.t0=a["catch"](6),i.lockTap=!1;case 17:case"end":return a.stop()}}),o,null,[[6,14]])})))()},toUpdateStatus:function(t,e){var n=this;return(0,o.default)(a.default.mark((function r(){var s,i,o,c;return a.default.wrap((function(r){while(1)switch(r.prev=r.next){case 0:if(s=n.shopCarList.list[t].goods_list[e],i=s.id,o=s.status,c={id:[i],status:1==o?0:1},!n.lockTap){r.next=4;break}return r.abrupt("return");case 4:return n.lockTap=!0,r.prev=5,r.next=8,n.$api.shop.carUpdate(c);case 8:return n.lockTap=!1,r.next=11,n.getShopCarList();case 11:r.next=16;break;case 13:r.prev=13,r.t0=r["catch"](5),n.lockTap=!1;case 16:case"end":return r.stop()}}),r,null,[[5,13]])})))()},toDelCar:function(){var t=this;return(0,o.default)(a.default.mark((function e(){return a.default.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,t.$api.shop.delSomeCar();case 2:return t.$util.showToast({title:"清空成功"}),t.$refs.show_car_item.close(),e.next=6,t.getCarInfo();case 6:case"end":return e.stop()}}),e)})))()},goDetail:function(t){var e=this.list.data[t].id,n="/shop/pages/detail?id=".concat(e);this.$util.goUrl({url:n})},goOrder:function(){var t=this.shopCarList.car_count;t<1?this.$util.showToast({title:"请选择商品"}):(this.$refs.show_car_item.close(),this.$util.goUrl({url:"/shop/pages/order"}))}})};e.default=d}).call(this,n("543d")["default"])},de0a:function(t,e,n){"use strict";(function(t,e){var r=n("4ea4");n("b03e");r(n("66fd"));var a=r(n("7ba6"));t.__webpack_require_UNI_MP_PLUGIN__=n,e(a.default)}).call(this,n("bc2e")["default"],n("543d")["createPage"])},e8fa:function(t,e,n){"use strict";n.r(e);var r=n("a65c"),a=n.n(r);for(var s in r)["default"].indexOf(s)<0&&function(t){n.d(e,t,(function(){return r[t]}))}(s);e["default"]=a.a},f386:function(t,e,n){"use strict";n.d(e,"b",(function(){return r})),n.d(e,"c",(function(){return a})),n.d(e,"a",(function(){}));var r=function(){var t=this,e=t.$createElement,n=(t._self._c,t.cateList.length),r=t.cateList.length,a=r>0?t.cateList.length:null,s=r>0&&a>0&&t.loading?t.list.current_page>=t.list.last_page&&t.list.data.length>0:null,i=r>0&&a>0?!t.loading&&t.list.data.length<=0&&1==t.list.current_page:null,o=!t.loading&&t.list.data.length<=0&&1==t.list.current_page&&0==t.cateList.length;t._isMounted||(t.e0=function(e){return e.stopPropagation(),t.$util.goUrl({url:"/shop/pages/choose-store"})},t.e1=function(e){return e.stopPropagation(),t.$refs.show_car_item.open()},t.e2=function(e){return e.stopPropagation(),t.$refs.show_spe_item.close()}),t.$mp.data=Object.assign({},{$root:{g0:n,g1:r,g2:a,g3:s,g4:i,g5:o}})},a=[]}},[["de0a","common/runtime","common/vendor"]]]);