1 |
- (global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["pages/search/search"],{"1b93":function(t,e,n){},"3ccb":function(t,e,n){"use strict";n.r(e);var i=n("ebc0"),r=n("5b53");for(var o in r)"default"!==o&&function(t){n.d(e,t,(function(){return r[t]}))}(o);n("e2f5");var s,c=n("f0c5"),a=Object(c["a"])(r["default"],i["b"],i["c"],!1,null,"4f2397a8",null,!1,i["a"],s);e["default"]=a.exports},"51c3":function(t,e,n){"use strict";(function(t){n("ecb4");i(n("66fd"));var e=i(n("3ccb"));function i(t){return t&&t.__esModule?t:{default:t}}t(e.default)}).call(this,n("543d")["createPage"])},"5b53":function(t,e,n){"use strict";n.r(e);var i=n("f96a"),r=n.n(i);for(var o in i)"default"!==o&&function(t){n.d(e,t,(function(){return i[t]}))}(o);e["default"]=r.a},e2f5:function(t,e,n){"use strict";var i=n("1b93"),r=n.n(i);r.a},ebc0:function(t,e,n){"use strict";var i;n.d(e,"b",(function(){return r})),n.d(e,"c",(function(){return o})),n.d(e,"a",(function(){return i}));var r=function(){var t=this,e=t.$createElement;t._self._c},o=[]},f96a:function(t,e,n){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var i=n("2f62");function r(t){return a(t)||c(t)||s(t)||o()}function o(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(t,e){if(t){if("string"===typeof t)return u(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(t,e):void 0}}function c(t){if("undefined"!==typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}function a(t){if(Array.isArray(t))return u(t)}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function h(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function d(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?h(Object(n),!0).forEach((function(e){f(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):h(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function f(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var l=function(){Promise.all([n.e("common/vendor"),n.e("components/page-component/app-goods-list/app-goods-list")]).then(function(){return resolve(n("cb83"))}.bind(null,n)).catch(n.oe)},m=1,y=!1,p=!1,g={name:"search",components:{"app-goods-list":l},data:function(){return{searchList:[],searchKey:"",list:[],isSearch:!1,historyList:[],keyword:"",recommend_list:[],mch_id:0}},computed:d(d({},(0,i.mapState)({theme:function(t){return t.mallConfig.theme}})),{},{newList:function(){return this.list.length>0?this.list:this.recommend_list}}),onLoad:function(t){this.mch_id=t.mch_id?t.mch_id:0,m=1,y=!1,p=!1,this.historyList=this.getHistory(),this.mch_id||this.getSearchList(),this.getRecommend()},onReachBottom:function(){p||this.getGoodsList()},watch:{keyword:{handler:function(t){""==t&&this.cancel()},immediate:!0}},methods:{clear:function(){this.keyword=""},getSearchList:function(){var t=this;this.$showLoading(),this.$request({url:this.$api.default.search_list}).then((function(e){t.$hideLoading(),t.searchList=e.data}))},switchSearch:function(t){this.searchKey=t,this.historyList=this.getHistory(),this.reset()},cancel:function(){this.isSearch=!1,this.keyword="",this.list=[]},reset:function(){m=1,this.getGoodsList()},search:function(t){var e=this.keyword;""!==e&&(this.keyword=e.trim(),this.setHistory(),this.reset())},getGoodsList:function(){var e=this;this.keyword&&(y||(y=!0,t.showLoading(),this.$request({url:this.$api.default.goods_list,data:{keyword:this.keyword,sign:this.searchKey,mch_id:this.mch_id,page:m}}).then((function(n){var i;(t.hideLoading(),y=!1,e.isSearch=!0,0===n.code)?(1==m&&(e.list=[]),n.data.list.length>0?((i=e.list).push.apply(i,r(n.data.list)),m++):(p=!0,1===m&&e.getRecommend())):t.showModal({content:n.msg})})).catch((function(){y=!1,t.hideLoading()}))))},setHistory:function(){var e=this.getHistory(),n=this.keyword.trim();e.forEach((function(t,i){t.keyword===n&&e.splice(i,1)})),e.push({keyword:n}),e.length>20&&e.shift(),this.historyList=e,t.setStorageSync("SEARCH_HISTORY_LIST",e)},getHistory:function(){var e=t.getStorageSync("SEARCH_HISTORY_LIST");return e||(e=[]),e},deleteHistory:function(){t.removeStorageSync("SEARCH_HISTORY_LIST"),this.historyList=[]},historyClick:function(t){this.keyword=t.trim(),this.reset()},getRecommend:function(){var t=this;this.mch_id||this.recommend_list.length>0||this.$request({url:this.$api.goods.new_recommend,data:{goods_id:0,type:"goods"}}).then((function(e){0===e.code&&(t.recommend_list=e.data.list)}))}}};e.default=g}).call(this,n("543d")["default"])}},[["51c3","common/runtime","common/vendor"]]]);
|