需求:三级分类,然后有加减号添加数量,选择数量好了下单,但不知道表的分类怎么设置,用的是CMS管理后台,下面网上找的代码,如何把下面代码放到CMS的表里,是不是也分别设置三个类型表?然后从表动态读取出来,如何写这代码呢?一级,二级,三级,怎么设置到表里,然后像下面一样的读取到cateltems 这集合里呢?
Page({
/**
* 页面的初始数据
*/
data: {
//一级
cateItems:[
{
cate_id:1,
cate_name:‘女装’,
//二级
children: [
{
child_id: 1,
name: ‘猜你喜欢’,
//三级
son:[
{
son_id:1,
name:‘牛仔裙’,
image:’…/…/images/jeanskirt.png’
},
{
son_id:2,
name:‘短外套’,
image:’…/…/images/overcoa.png’
},
{
son_id:3,
name:‘吊带裙’,
image:’…/…/images/dress.png’
},
{
son_id:4,
name:‘连衣裙’,
image:’…/…/images/dress(1).png’
},
{
son_id:5,
name:‘时尚套装’,
image:’…/…/images/suit.png’
},
{
son_id:6,
name:‘衬衫’,
image:’…/…/images/shirt.png’
},
{
son_id:7,
name:‘T恤’,
image:’…/…/images/Tshirt.png’
},
{
son_id:8,
name:‘卫衣’,
image:’…/…/images/sweater.png’
},
{
son_id:9,
name:‘休闲裤’,
image:’…/…/images/pants.png’
}
]
},
{
child_id: 2,
name: ‘流行趋势’,
son:[
{
son_id:1,
name:‘方领连衣裙’,
image:’…/…/images/squarecollardress.png’
},
{
son_id:2,
name:‘泡泡袖’,
image:’…/…/images/puffdress.png’
},
{
son_id:3,
name:‘西装连衣裙’,
image:’…/…/images/westerndress.png’
},
{
son_id:4,
name:‘洛丽塔’,
image:’…/…/images/Lolita.png’
},
{
son_id:5,
name:‘JK制服’,
image:’…/…/images/jkdress.png’
},
{
son_id:6,
name:‘束脚裤’,
image:’…/…/images/anklepants.png’
}
]
},
{
child_id: 3,
name: ‘女裙’,
son:[
{
son_id:1,
name:‘连衣裙’,
image:’…/…/images/dress(1).png’
},
{
son_id:2,
name:‘半身裙’,
image:’…/…/images//jkdress.png’
},
{
son_id:3,
name:‘旗袍’,
image:’…/…/images/chipao.png’
},
]
},
{
child_id: 4,
name: ‘外套’,
son:[
{
son_id:1,
name:‘短外套’,
image:’…/…/images/suit.png’
},
{
son_id:2,
name:‘风衣’,
image:’…/…/images/windbreaker.png’
},
{
son_id:3,
name:‘西装’,
image:’…/…/images/westerndress.png’
},
{
son_id:4,
name:‘毛呢大衣’,
image:’…/…/images/clothes.png’
},
{
son_id:5,
name:‘棉衣棉服’,
image:’…/…/images/clothes.png’
},
{
son_id:6,
name:‘羽绒服’,
image:’…/…/images/clothes.png’
},
{
son_id:7,
name:‘皮草’,
image:’…/…/images/clothes.png’
},
{
son_id:8,
name:‘皮衣’,
image:’…/…/images/clothes.png’
},
{
son_id:9,
name:‘皮衣’,
image:’…/…/images/clothes.png’
}
]
},
{
child_id: 5,
name: ‘上装’,
son:[
{
son_id:1,
name:‘T恤’,
image:’…/…/images/clothes.png’
},
{
son_id:2,
name:‘衬衫’,
image:’…/…/images/clothes.png’
},
{
son_id:3,
name:‘雪纺衫’,
image:’…/…/images/clothes.png’
},
{
son_id:4,
name:‘卫衣’,
image:’…/…/images/clothes.png’
},
{
son_id:5,
name:‘毛衣’,
image:’…/…/images/clothes.png’
},
{
son_id:6,
name:‘马甲’,
image:’…/…/images/clothes.png’
},
],
},
{
child_id: 6,
name: ‘特色女装’,
son:[
{
son_id:1,
name:‘中老年女装’,
image:’…/…/images/clothes.png’
},
{
son_id:2,
name:‘大码女装’,
image:’…/…/images/clothes.png’
},
{
son_id:3,
name:‘皮衣’,
image:’…/…/images/clothes.png’
}
]
},
{
child_id: 7,
name: ‘女裤’,
son:[
{
son_id:1,
name:‘休闲裤’,
image:’…/…/images/clothes.png’
},
{
son_id:2,
name:‘牛仔裤’,
image:’…/…/images/clothes.png’
},
{
son_id:3,
name:‘打底裤’,
image:’…/…/images/clothes.png’
},
{
son_id:4,
name:‘西装裤’,
image:’…/…/images/clothes.png’
},
{
son_id:5,
name:‘棉裤羽绒裤’,
image:’…/…/images/clothes.png’
},
{
son_id:6,
name:‘皮衣’,
image:’…/…/images/clothes.png’
}
]
},
{
child_id: 8,
name: ‘套装’,
son:[
{
son_id:1,
name:‘时尚套装’,
image:’…/…/images/clothes.png’
},
{
son_id:2,
name:‘运动套装’,
image:’…/…/images/clothes.png’
},
{
son_id:3,
name:‘皮衣’,
image:’…/…/images/clothes.png’
}
]
},
{
child_id: 9,
name: ‘服饰服务’,
son:[
{
son_id:1,
name:‘洗衣服务’,
image:’…/…/images/clothes.png’
},
]
},
]
},
{
cate_id:2,
cate_name:‘美妆’,
children: [
{
child_id: 1,
name: ‘猜你喜欢’,
son:[
{
son_id:1,
name:‘彩妆套装’,
image:’…/…/images/makeup.png’
},
{
son_id:2,
name:‘粉饼’,
image:’…/…/images/makeup.png’
},
{
son_id:3,
name:‘甲片’,
image:’…/…/images/makeup.png’
},
{
son_id:4,
name:‘指甲贴’,
image:’…/…/images/makeup.png’
},
{
son_id:5,
name:‘粉底液’,
image:’…/…/images/makeup.png’
},
{
son_id:6,
name:‘美甲’,
image:’…/…/images/makeup.png’
},
{
son_id:7,
name:‘防晒霜’,
image:’…/…/images/makeup.png’
},
{
son_id:8,
name:‘口红’,
image:’…/…/images/makeup.png’
},
{
son_id:9,
name:‘面膜’,
image:’…/…/images/makeup.png’
},
]
},
{
child_id: 2,
name: ‘美容美体’,
son:[
{
son_id:1,
name:‘彩妆套装’,
image:’…/…/images/makeup2.png’
},
{
son_id:2,
name:‘粉饼’,
image:’…/…/images/makeup2.png’
},
{
son_id:3,
name:‘甲片’,
image:’…/…/images/makeup2.png’
},
{
son_id:4,
name:‘指甲贴’,
image:’…/…/images/makeup2.png’
},
{
son_id:5,
name:‘粉底液’,
image:’…/…/images/makeup2.png’
},
{
son_id:6,
name:‘美甲’,
image:’…/…/images/makeup2.png’
},
{
son_id:7,
name:‘防晒霜’,
image:’…/…/images/makeup2.png’
},
{
son_id:8,
name:‘口红’,
image:’…/…/images/makeup2.png’
},
{
son_id:9,
name:‘面膜’,
image:’…/…/images/makeup2.png’
},
]
},
{
child_id: 3,
name: ‘彩妆’,
son:[
{
son_id:1,
name:‘彩妆套装’,
image:’…/…/images/makeup3.png’
},
{
son_id:2,
name:‘粉饼’,
image:’…/…/images/makeup3.png’
},
{
son_id:3,
name:‘甲片’,
image:’…/…/images/makeup3.png’
},
{
son_id:4,
name:‘指甲贴’,
image:’…/…/images/makeup3.png’
},
{
son_id:5,
name:‘粉底液’,
image:’…/…/images/makeup3.png’
},
{
son_id:6,
name:‘美甲’,
image:’…/…/images/makeup3.png’
},
{
son_id:7,
name:‘防晒霜’,
image:’…/…/images/makeup3.png’
},
{
son_id:8,
name:‘口红’,
image:’…/…/images/makeup3.png’
},
{
son_id:9,
name:‘面膜’,
image:’…/…/images/makeup3.png’
},
]
}
]
},
{
cate_id:3,
cate_name:‘饰品’
},
{
cate_id: 4,
cate_name: ‘百货’
},
{
cate_id: 5,
cate_name: ‘医药’
},
{
cate_id: 6,
cate_name: ‘进口’
},
{
cate_id: 7,
cate_name: ‘手机’
},
{
cate_id: 8,
cate_name: ‘箱包’
},
{
cate_id: 9,
cate_name: ‘鞋靴’
},
{
cate_id: 10,
cate_name: ‘内衣’
},
{
cate_id: 11,
cate_name: ‘母婴’
},
{
cate_id: 12,
cate_name: ‘男装’
},
{
cate_id: 13,
cate_name: ‘食品’
}
],
curNav:1,
curIndex:0,
},
switchRightTab:function(e){
let id = e.target.dataset.id,index=e.target.dataset.index;
this.setData({
curNav:id,
curIndex:index,
})
},
/**
* 生命周期函数–监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数–监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数–监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数–监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数–监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数–监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})