问题
补充,或者是否可以告诉我在下面代码如何修改后,使其跳转到相应cat.wxml列表,对应的分类标签亮红
是不是就是传多参数,参数1跳转cat.wxml 参数2该分类(cat.wxml列表的调用)这样说是否好理解哈
或者只要跳转到cat.wxml页(指定的分类产皮显示后,顶部把各个分类调出来也行),
<navigator bindtap="hideGetCoupon" class="flex-y-center" url="/pages/cat/cat?cat_id={{cat.id}}">
如何将下列代码
相关代码
将首页分类跳转调整后,无法看到分类的效果,只显示了对应的分类产品,缺少如上图的分类
<navigator bindtap="hideGetCoupon" class="flex-y-center" url="/pages/cat/cat?cat_id={{cat.id}}">
<text>更多</text>
<image src="{{__wxapp_img.store.jiantou_r.url}}"></image>
</navigator>
修改后可以跳转到下列代码的页面效果,下列代码为正常分类页面的效果
正常应该是下面的效果(下面效果为该cat.wxml)
<view bindtap="goodsAll" class="scroll-view-item {{item.active?'active':''}}" data-index="{{index}}" id="{{item.id}}" wx:for="{{cat_list}}" wx:key="unique">{{item.name}}</view>
cat.js如下
Page({
data: {
cat_list: [],
sub_cat_list_scroll_top: 0,
scrollLeft: 0,
page: 1,
cat_style: 0,
height: 0,
catheight: 120
},
onLoad: function(t) {
e.pageOnLoad(this, t);
var a = wx.getStorageSync("store"), s = t.cat_id;
void 0 !== s && s && (this.data.cat_style = a.cat_style = -1, wx.showLoading({
title: "正在加载",
mask: !0
}), this.childrenCat(s)), this.setData({
store: a
});
onShow: function() {
wx.hideLoading(), e.pageOnShow(this), -1 !== this.data.cat_style && this.loadData();
},
loadData: function(t) {
var s = this;
if ("" == s.data.cat_list || 5 != wx.getStorageSync("store").cat_style && 4 != wx.getStorageSync("store").cat_style && 2 != wx.getStorageSync("store").cat_style) {
var i = wx.getStorageSync("cat_list");
i && s.setData({
cat_list: i,
current_cat: null
}), e.request({
url: a.default.cat_list,
success: function(t) {
0 == t.code && (s.data.cat_list = t.data.list, 5 === wx.getStorageSync("store").cat_style && s.goodsAll({
currentTarget: {
dataset: {
index: 0
}
}
}), 4 !== wx.getStorageSync("store").cat_style && 2 !== wx.getStorageSync("store").cat_style || s.catItemClick({
currentTarget: {
dataset: {
index: 0
}
}
}), 1 !== wx.getStorageSync("store").cat_style && 3 !== wx.getStorageSync("store").cat_style || (s.setData({
cat_list: t.data.list,
current_cat: null
}), wx.setStorageSync("cat_list", t.data.list)));
},
complete: function() {
wx.stopPullDownRefresh();
}
});
} else s.setData({
cat_list: s.data.cat_list,
current_cat: s.data.current_cat
});
},
childrenCat: function(t) {
var i = this;
s = !1;
i.data.page;
e.request({
url: a.default.cat_list,
success: function(a) {
if (0 == a.code) {
var e = !0;
for (var s in a.data.list) {
a.data.list[s].id == t && (e = !1, i.data.current_cat = a.data.list[s], a.data.list[s].list.length > 0 ? (i.setData({
catheight: 100
}), i.firstcat({
currentTarget: {
dataset: {
index: 0
}
}
})) : i.firstcat({
currentTarget: {
dataset: {
index: 0
}
}
}, !1));
for (var c in a.data.list[s].list) a.data.list[s].list[c].id == t && (e = !1, i.data.current_cat = a.data.list[s],
i.goodsItem({
currentTarget: {
dataset: {
index: c
}
}
}, !1));
}
e && i.setData({
show_no_data_tip: !0
});
}
},
complete: function() {
wx.stopPullDownRefresh(), wx.createSelectorQuery().select("#cat").boundingClientRect().exec(function(t) {
i.setData({
height: t[0].height
});
});
}
});
},
catItemClick: function(t) {
var a = this, e = t.currentTarget.dataset.index, s = a.data.cat_list, i = null;
for (var c in s) c == e ? (s[c].active = !0, !1, i = s[c]) : s[c].active = !1;
a.setData({
cat_list: s,
sub_cat_list_scroll_top: 0,
current_cat: i
});
},
firstcat: function(t) {
var a = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1], e = this.data.current_cat;
this.setData({
page: 1,
goods_list: [],
show_no_data_tip: !1,
current_cat: a ? e : []
}), this.list(e.id, 2);
},
goodsItem: function(t) {
var a = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1], e = this, s = t.currentTarget.dataset.index, i = e.data.current_cat, c = 0;
for (var o in i.list) s == o ? (i.list[o].active = !0, c = i.list[o].id) : i.list[o].active = !1;
e.setData({
page: 1,
goods_list: [],
show_no_data_tip: !1,
current_cat: a ? i : []
}), this.list(c, 2);
},
goodsAll: function(a) {
var e = this, s = a.currentTarget.dataset.index, i = e.data.cat_list, c = null;
for (var o in i) o == s ? (i[o].active = !0, c = i[o]) : i[o].active = !1;
if (e.setData({
page: 1,
goods_list: [],
show_no_data_tip: !1,
cat_list: i,
current_cat: c
}), void 0 === ("undefined" == typeof my ? "undefined" : t(my))) {
var r = a.currentTarget.offsetLeft, n = e.data.scrollLeft;
n = r - 80, e.setData({
scrollLeft: n
});
} else i.forEach(function(t, s, c) {
t.id == a.currentTarget.id && (s >= 1 ? e.setData({
toView: i[s - 1].id
}) : e.setData({
toView: i[s].id
}));
});
this.list(c.id, 1), wx.createSelectorQuery().select("#catall").boundingClientRect().exec(function(t) {
e.setData({
height: t[0].height
});
});
},
list: function(t, i) {
var c = this;
wx.showLoading({
title: "正在加载",
mask: !0
}), s = !1;
var o = c.data.page || 2;
e.request({
url: a.default.goods_list,
data: {
cat_id: t,
page: o
},
success: function(a) {
0 == a.code && (wx.hideLoading(), 0 == a.data.list.length && (s = !0), c.setData({
page: o + 1
}), c.setData({
goods_list: a.data.list
}), c.setData({
cat_id: t
})), c.setData({
show_no_data_tip: 0 == c.data.goods_list.length
});
},
complete: function() {
1 == i && wx.createSelectorQuery().select("#catall").boundingClientRect().exec(function(t) {
c.setData({
height: t[0].height
});
});
}
});
},
onReachBottom: function() {
var t = this;
s || 5 != wx.getStorageSync("store").cat_style && -1 != t.data.cat_style || t.loadMoreGoodsList();
},
loadMoreGoodsList: function() {
var t = this;
if (!i) {
t.setData({
show_loading_bar: !0
}), i = !0;
var c = t.data.cat_id || "", o = t.data.page || 2;
e.request({
url: a.default.goods_list,
data: {
page: o,
cat_id: c
},
success: function(a) {
0 == a.data.list.length && (s = !0);
var e = t.data.goods_list.concat(a.data.list);
t.setData({
goods_list: e,
page: o + 1
});
},
complete: function() {
i = !1, t.setData({
show_loading_bar: !1
});
}
});
}
}
});
分类列表显示样式为
我不知道理解的对不对:
1、首页
2、分类列表页
在cat.js中onload接收参数