57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
// pages/shop/shopcat.js
|
|
var app = getApp();
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
categoryOneList: [],
|
|
categorySeconList: [],
|
|
currentIndex: 0,
|
|
isHidePageLoading: false
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
this.getCategroyList();
|
|
},
|
|
getCategroyList() {
|
|
var _self = this
|
|
app.restAjax.get(app.restAjax.path('{shopUrl}/app/category/listztreerelease', [app.shopUrl]), null, null, function (code, data) {
|
|
if (data.length == 0) {
|
|
app.dialog.msg('暂无数据');
|
|
return;
|
|
}
|
|
console.log(data)
|
|
_self.setData({
|
|
categoryOneList: data,
|
|
categorySeconList: data[0].subList,
|
|
isHidePageLoading: true
|
|
})
|
|
}, function (code, data) {
|
|
app.dialog.msg(data.msg);
|
|
_self.setData({
|
|
isHidePageLoading: true
|
|
})
|
|
}, function () {
|
|
wx.hideLoading();
|
|
})
|
|
},
|
|
chooseOne(event) {
|
|
var index = event.currentTarget.dataset.index
|
|
var _self = this;
|
|
this.setData({
|
|
currentIndex: index,
|
|
categorySeconList: _self.data.categoryOneList[index].subList
|
|
})
|
|
},
|
|
goList(e) {
|
|
var id = e.currentTarget.dataset.id
|
|
wx.navigateTo({
|
|
url: '/subpages/goodslist/goodslist?id=' + id,
|
|
})
|
|
}
|
|
}) |