Files
AGuestSaas/pages/mall/mall_classify/mall_classify.js
2020-12-28 09:16:11 +08:00

85 lines
1.8 KiB
JavaScript

/*
* 手太欠
* 企获客商城
*/
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
stairIndex : 0, //左侧下标默认
firstList : [], //左侧数据列表
stairTitle : '', //右侧分类标题名
categoryId : 0, //右侧传参id
secondList : [], //右侧数据列表
},
/**
* 生命周期函数--监听页面加载
*/
onLoad (options) {
// 获取商城左侧数据
this.mallFirst();
},
/**
* 商城左侧数据
*/
mallFirst () {
wx.$api.mall.first().then(res=>{
this.setData({
firstList : res,
categoryId : res[0].category_id,
stairTitle : res[0].title
})
// 获取商城右侧数据
this.mallSecond();
})
},
/**
* 商城右侧数据
*/
mallSecond () {
wx.$api.mall.second({
category_id : this.data.categoryId
}).then(res=>{
this.setData({
secondList : res
})
})
},
/**
* 更新左侧分类
*/
stairNav(e){
let categoryid = e.currentTarget.dataset.id,
index = e.currentTarget.dataset.index,
firstNew = this.data.firstList
if(this.data.categoryId != categoryid){
this.setData({
stairTitle: firstNew[index].title,
categoryId: categoryid
})
// 获取商城右侧数据
this.mallSecond();
}
},
/**
* 页面跳转
*/
jumpUrl(e){
let id = e.currentTarget.dataset.id
wx.navigateTo({
url: '/pages/mall_goods/mall_goods?sort=' + id,
})
}
})