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

85 lines
2.2 KiB
JavaScript

var t = getApp();
Page({
data: {
searchColor: "rgba(0,0,0,0.4)",
searchSize: "15",
searchName: "搜索商品",
scrollHeight: 0,
curIndex: -1,
curCateId: 0,
categoryList: [],
goodsList: [],
noMore: !1,
isLoading: !0,
page: 1
},
onLoad: function() {
this.setListHeight(), this.getCategoryList();
},
onShow: function() {},
setListHeight: function() {
var t = this;
wx.getSystemInfo({
success: function(a) {
t.setData({
scrollHeight: a.windowHeight - 47
});
}
});
},
getCategoryList: function() {
var a = this;
t._get("category/index", {}, function(t) {
var o = t.data;
a.setData({
categoryList: o.categoryList,
goodsList: o.goodsList
});
});
},
getGoodsList: function(a, o) {
var s = this;
t._get("goods/lists", {
page: o || 1,
category_id: s.data.curCateId
}, function(t) {
var o = t.data.list, e = s.data.goodsList;
1 == a ? s.setData({
"goodsList.data": e.data.concat(o.data),
isLoading: !1
}) : s.setData({
goodsList: o,
isLoading: !1
});
});
},
onTargetGoods: function(t) {
wx.navigateTo({
url: "../goods/index?goods_id=" + t.detail.target.dataset.id
});
},
onSelectNav: function(t) {
var a = t.currentTarget.dataset.index;
this.setData({
curIndex: a,
curCateId: a > -1 ? this.data.categoryList[a].category_id : 0,
goodsList: [],
page: 1,
noMore: !1,
isLoading: !0
}), this.getGoodsList();
},
onDownLoad: function() {
if (this.data.page >= this.data.goodsList.last_page) return this.setData({
noMore: !0
}), !1;
this.getGoodsList(!0, ++this.data.page);
},
onShareAppMessage: function() {
return {
title: "全部商品",
path: "/pages/category/index"
};
}
});