var t = function(t) { return t && t.__esModule ? t : { default: t }; }(require("../../../utils/LoadMore.js")), e = getApp(), a = new t.default(), oo = e.globalData.setting, ut = require("../../../utils/util.js"); Page({ data: { url: e.globalData.setting.imghost, resourceUrl: e.globalData.setting.resourceUrl, iurl: e.globalData.setting.imghost, currentPage: 1, requestData: null, allData: null, openFilterModal: !1, baseUrl: "/api/weshop/goods/page?1=1", requestUrl: "", tabname:"goods_id", //排序的字段 adname:"desc", //升降的字段 is_new:0, is_hot:0, }, onLoad: function(t) { var th=this; a.init(this, "", "requestData"); var url = this.data.baseUrl; this.data.is_new=t.is_new; this.data.is_hot=t.is_hot; if (0 != t.cat_id && t.cat_id != undefined) { url += "&cat_id=" + t.cat_id; if (t.pid == undefined || t.pid == null){ url += "&parent_id=0"; }else{ if(t.pid!="three"){ url += "&parent_id="+t.pid; } } } if (0 != t.brand_id && t.brand_id != undefined) { url += "&brand_id=" + t.brand_id; } if (0 != t.nation_id && t.nation_id != undefined) { url += "&nation_id=" + t.nation_id; } if (0 != t.group_id && t.group_id != undefined) { url += "&group_id=" + t.group_id; } if (0 != t.gid && t.gid != undefined) { url += "&group_id=" + t.gid; } if (0 != t.max_price && t.max_price != undefined) { url += "&min_pirce=" + t.min_pirce + "&max_price=" + t.max_price; } if (0 != t.is_new && t.is_new != undefined) { url += "&is_new=" + t.is_new; } if (0 != t.is_hot && t.is_hot != undefined) { url += "&is_hot=" + t.is_hot; } this.requestGoodsList(url); getApp().getConfig2(function(rs){ //计算等级价相关 var swithc_list=rs.switch_list; var sw_arr=JSON.parse(swithc_list); //---如果后台又开等级卡的开关--- if(sw_arr.rank_switch && sw_arr.rank_switch=="2"){ th.setData({rank_switch:true}); var user=getApp().globalData.userInfo; var ti=setInterval(function(){ if(!user) return false; clearInterval(ti); //---回调卡的列表--- th.getPlusCardType(function(ob){ th.setData({card_list:ob.card_list}); if(user.card_field ){ var str = user['card_expiredate'].replace(/-/g, '/'); var end = new Date(str); end = Date.parse(end) / 1000; var now = ut.gettimestamp(); //--- 判断是等级会员,且在有效期范围内 --- if(user.card_field && now4) card_name=card_name.substring(0,4); th.setData({card_field:user.card_field,card_name:card_name,card_list:ob.card_list}); } } }) },500) } }); }, changeTab: function(t) { var ord = t.currentTarget.dataset.href; var ad = t.currentTarget.dataset.ad; var url = this.data.requestUrl; if (this.data.tabname!=ord){ this.setData({ tabname: ord, adname: "desc" }); }else{ ad = ad == "desc" ? "asc" :"desc"; this.setData({adname: ad }); } this.resetData(), this.requestGoodsList(url); }, requestGoodsList: function(t) { var e = this; this.data.requestUrl = t; //不是商品分组的,不是默认排序的 if(t.indexOf("group_id")==-1 || e.data.tabname!="goods_id" ){ t += "&orderField=" + e.data.tabname; t += "&orderType=" + e.data.adname; } t +="&page=" + e.data.currentPage; a.request(t, function(t) { e.setData({is_go:1}); e.data.currentPage++, null == e.data.allData && (e.data.allData = Object.assign({}, t.data.result)), wx.stopPullDownRefresh(); }, null, { is_mainshow: 1, isonsale: 1, store_id: oo.stoid} ); }, onReachBottom: function() { a.canloadMore() && this.requestGoodsList(this.data.requestUrl); }, onPullDownRefresh: function() { this.resetData(), this.requestGoodsList(this.data.requestUrl); }, openFilterModal: function() { this.setData({ openFilterModal: !0 }); }, closeFilterModal: function() { this.setData({ openFilterModal: !1 }); }, filterGoods: function(t) { this.resetData(), this.requestGoodsList(t.currentTarget.dataset.href), this.closeFilterModal(); }, resetData: function() { a.resetConfig(), this.data.requestData = null, this.data.currentPage = 1; }, //---回复最初的设置--- restoreData: function() { this.setData({ requestData: null, }); this.data.currentPage = 2; }, //---------分享配置-------- onShareAppMessage: function (e) { return { title: "商品列表", } }, //---图片失败,默认图片--- bind_bnerr2: function (e) { var _errImg = e.target.dataset.errorimg; var _errurl = e.target.dataset.url; var ii = _errurl.indexOf(oo.imghost); if (ii != -1) { var _errObj = {}; _errObj[_errImg] = this.data.iurl+"/miniapp/images/default_g_img.gif"; this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; } }, //--- 获取卡类列表 --- getPlusCardType: function (func) { var storid = oo.stoid; var th = this; getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => { var plusCard = res.data.data; var arr = [1219, 2089, 3031]; var new_arr = new Array(); var card_name_map=new Map(); var user = getApp().globalData.userInfo; for (var i = 0; i < plusCard.length; i++) { if ((user.card_field==null || user.card_field=="") && (plusCard[i].IsStopBuy==true)) { continue; } var name="card"+plusCard[i].CorrPrice.toLowerCase(); card_name_map.set(name,plusCard[i].CardName); new_arr.push(plusCard[i]); } var ob={"card_list":new_arr,"name_map":card_name_map}; func(ob); }) }, });