Files
decode-mini-app-new/wx05cb767e6530b48f/pages/index/index.js
2024-08-22 12:53:28 +08:00

176 lines
4.8 KiB
JavaScript

var t = require("../../@babel/runtime/helpers/defineProperty"), a = getApp();
Page({
data: t({
searchColor: "rgba(0,0,0,0.4)",
searchSize: "15",
searchName: "搜索商品",
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);
});
},
filterTab: function(t) {
this.setData({
tab: !this.data.tab
});
},
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(t.currentTarget.dataset.category_id);
var a = this;
a.setData({
list: {},
page: 1,
cate_id: t.currentTarget.dataset.category_id,
tab: !0
}, function() {
a.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();
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 (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"
};
}
});