192 lines
5.4 KiB
JavaScript
192 lines
5.4 KiB
JavaScript
var t = require("../../@babel/runtime/helpers/defineProperty"), a = getApp();
|
|
|
|
Page({
|
|
data: t({
|
|
searchColor: "rgba(0,0,0,0.4)",
|
|
searchSize: "15",
|
|
searchName: "搜索商品",
|
|
pageTriggered: !1,
|
|
scrollHeight: null,
|
|
showView: !1,
|
|
arrange: "arrange",
|
|
sortType: "all",
|
|
sortPrice: !1,
|
|
sortColour: !1,
|
|
option: {},
|
|
list: {},
|
|
noList: !0,
|
|
no_more: !1,
|
|
page: 1,
|
|
searchValue: "",
|
|
cateList: [],
|
|
cate_id: 0,
|
|
colourList: [],
|
|
colour_id: 0,
|
|
hideNotice: !1,
|
|
storeInfo: {},
|
|
tabTxt: "成色",
|
|
tab: !0
|
|
}, "colour_id", 0),
|
|
onLoad: function(t) {
|
|
a.setTitle();
|
|
var e = this;
|
|
e.setListHeight(), e.getCategoryList(), e.getColourList(), e.getStoreInfo(), e.setData({
|
|
option: t
|
|
}, function() {
|
|
e.getGoodsList(!0);
|
|
});
|
|
},
|
|
onPullDownRefresh: function() {
|
|
var t = this;
|
|
wx.showLoading({
|
|
title: "刷新中..."
|
|
}), setTimeout(function() {
|
|
t.onRefresh();
|
|
}, 1e3), wx.showNavigationBarLoading(), this.setData({
|
|
pageTriggered: !0,
|
|
page: 1
|
|
});
|
|
},
|
|
onRefresh: function() {
|
|
var t = this;
|
|
t.getGoodsList(!0), setTimeout(function() {
|
|
wx.hideLoading(), wx.hideNavigationBarLoading(), t.setData({
|
|
pageTriggered: !1
|
|
});
|
|
}, 500);
|
|
},
|
|
filterTab: function(t) {
|
|
console.log(111), this.setData({
|
|
tab: !this.data.tab,
|
|
page: 1
|
|
});
|
|
},
|
|
filter: function(t) {
|
|
var a = t.currentTarget.dataset.id, e = t.currentTarget.dataset.txt, o = this.data.tabTxt;
|
|
o = e, this.setData({
|
|
tab: !0,
|
|
tabTxt: o,
|
|
colour_id: a,
|
|
jiage_txt: e
|
|
}), this.getGoodsList(!0);
|
|
},
|
|
getCategoryList: function() {
|
|
var t = this;
|
|
a._get("category/lists", {}, function(a) {
|
|
var e = a.data;
|
|
e.list.unshift({
|
|
category_id: 0,
|
|
name: "全部"
|
|
}), t.setData({
|
|
cateList: e.list
|
|
});
|
|
});
|
|
},
|
|
getStoreInfo: function() {
|
|
var t = this;
|
|
a._get("index/getStoreInfo", {}, function(a) {
|
|
var e = a.data;
|
|
console.log(e), t.setData({
|
|
storeInfo: e.store
|
|
});
|
|
});
|
|
},
|
|
switchNotice: function() {
|
|
this.setData({
|
|
hideNotice: !0
|
|
});
|
|
},
|
|
getColourList: function() {
|
|
var t = this;
|
|
a._get("goods/getColourList", {}, function(a) {
|
|
var e = a.data;
|
|
t.setData({
|
|
colourList: e.list
|
|
});
|
|
});
|
|
},
|
|
getSearchContent: function(t) {
|
|
this.data.searchValue = t.detail.value;
|
|
},
|
|
search: function() {
|
|
this.getGoodsList(!0);
|
|
},
|
|
searchCate: function(t) {
|
|
console.log("栏目ID"), console.log(t.currentTarget.dataset.category_id), this.setData({
|
|
cate_id: t.currentTarget.dataset.category_id,
|
|
page: 1
|
|
}), this.getGoodsList(!0);
|
|
},
|
|
getGoodsList: function(t, e) {
|
|
wx.showLoading({
|
|
title: "刷新中..."
|
|
}), console.log(this.data.searchValue);
|
|
var o = this;
|
|
a._get("goods/lists", {
|
|
page: e || 1,
|
|
sortType: o.data.sortType,
|
|
sortPrice: o.data.sortPrice ? 1 : 0,
|
|
sortColour: o.data.sortColour ? 1 : 0,
|
|
category_id: o.data.cate_id || 0,
|
|
colour_id: o.data.colour_id || 0,
|
|
search: o.data.searchValue || ""
|
|
}, function(a) {
|
|
wx.hideLoading(), console.log(a);
|
|
var e = a.data.list, i = o.data.list;
|
|
!0 === t || void 0 === i.data ? o.setData({
|
|
list: e,
|
|
noList: !1
|
|
}) : o.setData({
|
|
"list.data": i.data.concat(e.data)
|
|
});
|
|
});
|
|
},
|
|
setListHeight: function() {
|
|
var t = this;
|
|
wx.getSystemInfo({
|
|
success: function(a) {
|
|
t.setData({
|
|
scrollHeight: a.windowHeight - 160
|
|
});
|
|
}
|
|
});
|
|
},
|
|
switchSortType: function(t) {
|
|
var a = this, e = t.currentTarget.dataset.type, o = "price" !== e || !a.data.sortPrice, i = "colour" !== e || !a.data.sortColour;
|
|
a.setData({
|
|
list: {},
|
|
page: 1,
|
|
sortType: e,
|
|
sortPrice: o,
|
|
sortColour: i,
|
|
tab: !0
|
|
}, function() {
|
|
a.getGoodsList(!0);
|
|
});
|
|
},
|
|
toSynthesize: function(t) {
|
|
wx.navigateTo({
|
|
url: "../category/screen?objectId="
|
|
});
|
|
},
|
|
onChangeShowState: function() {
|
|
this.setData({
|
|
showView: !this.data.showView,
|
|
arrange: this.data.arrange ? "" : "arrange"
|
|
});
|
|
},
|
|
bindDownLoad: function() {
|
|
if (console.log("this.data.page", this.data.page), console.log("this.data.list.last_page", this.data.list.last_page),
|
|
this.data.page >= this.data.list.last_page) return this.setData({
|
|
no_more: !0
|
|
}), !1;
|
|
this.getGoodsList(!1, ++this.data.page);
|
|
},
|
|
onShareAppMessage: function() {
|
|
return {
|
|
title: "小程序首页",
|
|
desc: "",
|
|
path: "/pages/index/index"
|
|
};
|
|
}
|
|
}); |