|
@@ -2,11 +2,12 @@ const _Http = getApp().globalData.http;
|
|
|
|
|
|
Page({
|
|
|
data: {
|
|
|
+ brand: {}, //当前品牌
|
|
|
brandList: [], //品牌列表
|
|
|
+ typeList: [],
|
|
|
+ cType: {},
|
|
|
loading: true,
|
|
|
"content": {
|
|
|
- "brandids": [1],
|
|
|
- "itemclassids": [1],
|
|
|
"pageNumber": 1,
|
|
|
"pageTotal": 1,
|
|
|
"where": {
|
|
@@ -14,28 +15,27 @@ Page({
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
-
|
|
|
- getList(init) {
|
|
|
- if (init.detail != undefined) init = init.detail;
|
|
|
- let content = this.data.content;
|
|
|
- if (init) content.pageNumber = 1;
|
|
|
- if (content.pageNumber > content.pageTotal) return;
|
|
|
- _Http.basic({
|
|
|
- "id": 20220924163802,
|
|
|
- content
|
|
|
- }).then(res => {
|
|
|
- this.selectComponent('#ListBox').RefreshToComplete();
|
|
|
- console.log("商品列表", res)
|
|
|
- })
|
|
|
- },
|
|
|
onLoad(options) {
|
|
|
- setTimeout(() => {
|
|
|
- this.setData({
|
|
|
- loading: false
|
|
|
- })
|
|
|
- }, 1000)
|
|
|
this.getBrand()
|
|
|
},
|
|
|
+ /* 切换分类 */
|
|
|
+ typeChange({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ let typeList = this.data.typeList;
|
|
|
+ if (typeList.length - 1 != detail.rowIndex) typeList = typeList.slice(0, detail.rowIndex + 1);
|
|
|
+ typeList[detail.rowIndex].active = detail.index
|
|
|
+ if (detail.item.subdep.length) typeList.push({
|
|
|
+ active: -1,
|
|
|
+ list: detail.item.subdep
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ cType: detail.item,
|
|
|
+ typeList
|
|
|
+ });
|
|
|
+ this.setListHeight();
|
|
|
+ this.getList(true);
|
|
|
+ },
|
|
|
/* 获取品牌 */
|
|
|
getBrand() {
|
|
|
_Http.basic({
|
|
@@ -45,14 +45,55 @@ Page({
|
|
|
}
|
|
|
}).then(res => {
|
|
|
console.log("查询品牌", res)
|
|
|
+ if (res.data.length) this.setData({
|
|
|
+ brandList: res.data,
|
|
|
+ brand: res.data[0],
|
|
|
+ });
|
|
|
+ this.getTypeList();
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 获取分类 */
|
|
|
+ getTypeList() {
|
|
|
+ _Http.basic({
|
|
|
+ "id": "20220922110403",
|
|
|
+ "content": {
|
|
|
+ "sa_brandid": this.data.brand.sa_brandid
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("营销类别", res)
|
|
|
+ if (res.data[0].ttemclass) this.setData({
|
|
|
+ ['typeList[0]']: {
|
|
|
+ active: 0,
|
|
|
+ list: res.data[0].ttemclass
|
|
|
+ },
|
|
|
+ "cType": res.data[0].ttemclass[0]
|
|
|
+ });
|
|
|
+ this.getList(true);
|
|
|
+ this.setListHeight()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 获取产品 */
|
|
|
+ getList(init) {
|
|
|
+ if (init.detail != undefined) init = init.detail;
|
|
|
+ let content = this.data.content;
|
|
|
+ if (init) content.pageNumber = 1;
|
|
|
+ if (content.pageNumber > content.pageTotal) return;
|
|
|
+ content.brandids = [this.data.brand.sa_brandid];
|
|
|
+ content.itemclassids = [this.data.cType.itemclassid];
|
|
|
+ _Http.basic({
|
|
|
+ "id": 20220924163802,
|
|
|
+ content
|
|
|
+ }).then(res => {
|
|
|
+ console.log("商品列表", res)
|
|
|
+ this.selectComponent('#ListBox').RefreshToComplete();
|
|
|
this.setData({
|
|
|
- brandList: res.data
|
|
|
+ list: res.data,
|
|
|
+ "content.pageNumber": res.pageNumber + 1,
|
|
|
+ "content.pageTotal": res.pageTotal,
|
|
|
+ loading: false
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
onReady() {
|
|
|
this.setListHeight()
|
|
|
},
|
|
@@ -68,6 +109,6 @@ Page({
|
|
|
},
|
|
|
/* 设置页面高度 */
|
|
|
setListHeight() {
|
|
|
- this.selectComponent("#ListBox").setHeight(".head", this);
|
|
|
+ this.selectComponent("#ListBox").setHeight(".division", this);
|
|
|
},
|
|
|
})
|