goodsList.js
3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
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;
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) {
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.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);
},
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,
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;
},
//---图片失败,默认图片---
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) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
}
}
});