zhaoxiaohai 2 vuotta sitten
vanhempi
commit
705bbad202

+ 67 - 26
packageA/market/index.js

@@ -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);
 	},
 })

+ 4 - 3
packageA/market/index.scss

@@ -47,7 +47,6 @@
 		}
 	}
 }
-
 .brand-box {
 	margin-left: 30rpx;
 	padding-bottom: 20rpx;
@@ -64,8 +63,6 @@
 		background-color: #FAFAFA;
 	}
 }
-
-
 .corner-mark {
 	position: absolute;
 	display: inline-block;
@@ -78,4 +75,8 @@
 	top: -45rpx;
 	left: 0rpx;
 	z-index: 9999;
+}
+.division{
+	height: 10rpx;
+	background-color: #F4F5F7;
 }

+ 4 - 1
packageA/market/index.wxml

@@ -12,6 +12,8 @@
 </view>
 <!-- 品牌列表 -->
 <Tabs list="{{brandList}}" box-class='brand-box' tab-class='brand-tab-class' active-class='brand-active-class' />
+<!-- 产品列表 -->
+<Tabs wx:for="{{typeList}}" active="{{item.active}}" wx:key="{{index}}" rowIndex="{{index}}" list="{{item.list}}" bind:onChange="typeChange" name='itemclassname' box-class='brand-box' tab-class='brand-tab-class' active-class='brand-active-class' />
 
 <Yl_FloatingButton useSlot>
 	<view>
@@ -20,6 +22,7 @@
 	</view>
 </Yl_FloatingButton>
 
+<view class="division" />
 <Yl_ListBox id='ListBox' bind:getlist='getList'>
-	<List />
+	<List list="{{list}}" />
 </Yl_ListBox>

+ 7 - 11
packageA/market/modules/list/index.wxml

@@ -1,31 +1,27 @@
-<navigator class="product" url="/packageA/market/detail" wx:for="{{5}}" wx:key="index">
+<navigator class="product" url="/packageA/market/detail" wx:for="{{list}}" wx:key="index">
 	<view class="image-box">
-		<van-image width="100%" height="100%" fit="cover" src="https://img.yzcdn.cn/vant/cat.jpeg" use-loading-slot use-error-slot lazy-load>
+		<van-image width="100%" height="100%" fit="cover" src="{{item.attinfos[0].subfiles[0].url||''}}" use-loading-slot use-error-slot lazy-load>
 			<van-loading slot="loading" type="spinner" size="20" vertical />
 			<text slot="error">加载失败</text>
 		</van-image>
 	</view>
 	<view class="right-box">
-		<view class="title line-1">煞风景撒化肥的萨达萨达阿斯蒂芬阿斯蒂芬奥斯蒂芬萨达asdf23423423lkj4ho2i34j2io3423o423423uihb</view>
-		<view class="type line-1">煞风景撒化肥的萨达萨达阿斯蒂芬阿斯蒂芬奥斯蒂芬萨达asdf23423423lkj4ho2i34j2io3423o423423uihb</view>
+		<view class="title line-1">{{item.itemname}}</view>
+		<view class="type line-1">{{item.itemno}}</view>
 		<view class="tags">
 			<view style="background: #FF3B30;">
 				欧标
 			</view>
 			<view style="background: #FA8C16;">
-				班尼戈
+				{{item.brandname}}
 			</view>
 		</view>
 		<view class="price">
 			<view>
 				¥ 1100.00~2356.12
 			</view>
-			<text>× </text>
+			<text>× {{item.unitname}}</text>
 		</view>
 	</view>
 </navigator>
-
-
-
-
-<!-- <Yl_Empty /> -->
+<Yl_Empty wx:if="{{list.length === 0}}" />

+ 10 - 7
packageA/market/modules/tabs/index.js

@@ -9,7 +9,11 @@ Component({
       type: String,
       value: 0
     },
-    onChenge: Function
+    rowIndex: {
+      type: Number,
+      value: 0
+    },
+    onChange: Function
   },
   externalClasses: [
     "box-class", "tab-class", "active-class"
@@ -27,17 +31,16 @@ Component({
         this.setData({
           active: index
         });
-        this.triggerEvent("onChenge", {
+        this.triggerEvent("onChange", {
           item,
-          index
+          index,
+          rowIndex: this.data.rowIndex
         })
-        this.setActive();
+        this.setActive(index);
       }
     },
-
-    setActive() {
+    setActive(active) {
       const that = this,
-        active = this.data.active,
         query = wx.createSelectorQuery().in(this)
       query.select('#active' + active).boundingClientRect(function (res) {
         that.setData({

+ 1 - 1
packageA/market/modules/tabs/index.wxml

@@ -1,4 +1,4 @@
-<scroll-view class="scroll-box" scroll-x scroll-left='{{scrollLeft}}' scroll-with-animation enable-passive>
+<scroll-view class="scroll-box" scroll-x scroll-left='{{scrollLeft}}' scroll-with-animation enable-passive enhanced show-scrollbar='{{false}}'>
 	<view class="box box-class">
 		<view wx:for="{{list}}" class="item tab-class {{active==index?'active active-class':''}}" id='{{"active"+index}}' wx:key="index" data-item="{{item}}" data-index="{{index}}" bindtap="onClick">
 			{{item[name]}}