Browse Source

工具查询

zhaoxiaohai 2 years ago
parent
commit
7d4c897b1d

+ 177 - 0
packageA/tool/index.js

@@ -0,0 +1,177 @@
+const _Http = getApp().globalData.http;
+
+Page({
+  data: {
+    brand: {}, //当前品牌
+    brandList: [], //品牌列表
+    typeList: [],
+    cType: {},
+    loading: true,
+    "content": {
+      "pageNumber": 1,
+      "pageTotal": 1,
+      "tradefield": "",
+      "istool": 1,
+      "where": {
+        "condition": ""
+      },
+      sort: []
+    },
+
+    filter: [{
+      label: "标准",
+      index: null,
+      showName: "value", //显示字段
+      valueKey: "name", //返回Key
+      selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
+      value: "", //选中值
+      list: []
+    }]
+  },
+  onLoad(options) {
+    this.getBrand()
+    // this.getNum();
+    this.getOptionTypeSelect();
+  },
+  /* 获取系统分类 */
+  getOptionTypeSelect() {
+    _Http.basic({
+      "classname": "sysmanage.develop.optiontype.optiontype",
+      "method": "optiontypeselect",
+      "content": {
+        "pageNumber": 1,
+        "pageSize": 999,
+        "typename": "itemstandards",
+        "parameter": {
+          "siteid": wx.getStorageSync('userMsg').siteid
+        }
+      }
+    }, false).then(res => {
+      console.log("系统标准列表", res)
+      if (res.msg == '成功') this.setData({
+        "filter[0].list": res.data
+      })
+    })
+  },
+  /* 处理筛选 */
+  handleFilter({
+    detail
+  }) {
+    console.log(detail)
+  },
+  /* 切换分类 */
+  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.getList(true);
+  },
+  /* 获取品牌 */
+  getBrand() {
+    _Http.basic({
+      "id": 20220924163702,
+      "content": {
+        "pageSize": 999,
+      }
+    }).then(res => {
+      console.log("查询品牌", res)
+      if (res.data.length) this.setData({
+        brandList: res.data,
+        brand: res.data[0],
+      });
+      this.getTypeList();
+    })
+  },
+  /* 获取分类 */
+  getTypeList() {
+    _Http.basic({
+      "id": "20220926095202",
+      "istool": 1, //默认0,不是工具,1表示工具
+      "pageSize": 1000,
+      "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);
+    })
+  },
+  /* 获取产品 */
+  getList(init = false) {
+    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({
+        list: res.data,
+        "content.pageNumber": res.pageNumber + 1,
+        "content.pageTotal": res.pageTotal,
+        "content.sort": res.sort,
+        loading: false
+      })
+      this.setListHeight()
+    })
+  },
+  startFiltration() {
+    /* _Http.basic().then(res => {
+    	console.log("获取领域", res)
+    }) */
+  },
+  /* 搜索 */
+  onSearch({
+    detail
+  }) {
+    this.setData({
+      "content.where.condition": detail
+    });
+    this.getList(true)
+  },
+  onReady() {
+    this.setListHeight()
+  },
+  /* 设置页面高度 */
+  setListHeight() {
+    this.selectComponent("#ListBox").setHeight(".division", this);
+  },
+  /* 获取购物车数量 */
+  getNum() {
+    _Http.basic({
+      "id": 20220927093202,
+      "content": {}
+    }).then(res => {
+      console.log("购物车数量", res)
+      getApp().globalData.num = res.data.num;
+      this.selectComponent("#Float").setNum(res.data.num)
+    });
+  },
+  onShow() {
+    if (getApp().globalData.num) this.selectComponent("#Float").setNum(getApp().globalData.num)
+  }
+})

+ 6 - 0
packageA/tool/index.json

@@ -0,0 +1,6 @@
+{
+  "usingComponents": {
+    "Tabs": "../market/modules/tabs/index",
+    "List": "./modules/list/index"
+  }
+}

+ 21 - 0
packageA/tool/index.scss

@@ -0,0 +1,21 @@
+.brand-box {
+	margin-left: 30rpx;
+	padding-bottom: 20rpx;
+
+	.brand-tab-class {
+		height: 52rpx;
+		line-height: 52rpx;
+		font-size: 24rpx;
+		color: #666666;
+	}
+
+	.brand-active-class {
+		border-radius: 26rpx;
+		background-color: #FAFAFA;
+	}
+}
+
+.division{
+	height: 10rpx;
+	background-color: #F4F5F7;
+}

+ 15 - 0
packageA/tool/index.wxml

@@ -0,0 +1,15 @@
+<Yl_HeadNav styleType="1" sort='{{content.sort}}' bindonSearch="onSearch" />
+<!-- 品牌列表 -->
+<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' />
+<view class="division" />
+<Yl_ListBox id='ListBox' bind:getlist='getList'>
+	<List list="{{list}}" />
+</Yl_ListBox>
+
+<!-- 筛选条件 -->
+<Yl_Filtrate id='Filtrate' list="{{filter}}" bind:handle="handleFilter" dateRange='{{false}}' />
+
+<!-- 购物车按钮 -->
+<Float id="Float" />

+ 5 - 0
packageA/tool/modules/list/index.js

@@ -0,0 +1,5 @@
+Component({
+  properties: {
+    list: Array
+  }
+})

+ 4 - 0
packageA/tool/modules/list/index.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 98 - 0
packageA/tool/modules/list/index.scss

@@ -0,0 +1,98 @@
+.product {
+	display: flex;
+	width: 100vw;
+	padding: 20rpx 30rpx;
+	background: #fff;
+	border-bottom: 1rpx solid #ddd;
+	box-sizing: border-box;
+	overflow: hidden;
+
+	.image-box {
+		font-size: 0;
+		width: 176rpx;
+		height: 176rpx;
+		border-radius: 16rpx;
+		overflow: hidden;
+		margin-right: 30rpx;
+		flex-shrink: 0;
+
+		.text {
+			display: inline-block;
+			width: 176rpx;
+			height: 176rpx;
+			line-height: 172rpx;
+			font-size: 24rpx;
+			text-align: center;
+			color: #666;
+			border: 1rpx solid #ddd;
+			border-radius: 16rpx;
+			box-sizing: border-box;
+		}
+	}
+
+	.right-box {
+		width: 480rpx;
+
+		.title {
+			height: 40rpx;
+			line-height: 40rpx;
+			font-size: 28rpx;
+			font-weight: 600;
+			color: #333333;
+		}
+
+		.type {
+			height: 34rpx;
+			line-height: 34rpx;
+			font-size: 24rpx;
+			color: #888888;
+			margin-top: 8rpx;
+		}
+
+		.tags {
+			display: flex;
+			height: 32rpx;
+			margin-top: 8rpx;
+			width: 100%;
+
+			>view {
+				flex-shrink: 0;
+				height: 32rpx;
+				line-height: 32rpx;
+				padding: 0 10rpx;
+				font-size: 20rpx;
+				color: #FFFFFF;
+				margin-right: 8rpx;
+				border-radius: 6rpx;
+			}
+		}
+
+		.price {
+			display: flex;
+			width: 100%;
+			height: 40rpx;
+			align-items: center;
+			justify-content: space-between;
+			margin-top: 14rpx;
+
+			view {
+				font-size: 28rpx;
+				font-family: PingFang SC-Medium, PingFang SC;
+				font-weight: 550;
+				color: #3874F6;
+			}
+
+			text {
+				font-size: 24rpx;
+				color: #888888;
+			}
+		}
+	}
+}
+
+.line-1 {
+	overflow: hidden;
+	white-space: nowrap;
+	text-overflow: ellipsis;
+	word-break: break-all;
+}

+ 28 - 0
packageA/tool/modules/list/index.wxml

@@ -0,0 +1,28 @@
+<navigator class="product" url="/packageA/market/detail?id={{item.sa_itemgroupid}}&itemno={{item.itemno}}" wx:for="{{list}}" wx:key="index">
+	<view class="image-box">
+		<van-image width="100%" wx:if="{{item.attinfos[0]}}" 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>
+		<text class="text" wx:else>暂无图片</text>
+	</view>
+	<view class="right-box">
+		<view class="title line-1">{{item.itemname||'--'}}</view>
+		<view class="type line-1">型号:{{item.model||'--'}} <text style="margin-left: 16rpx;">规格:{{item.spec||'--'}}</text></view>
+		<view class="tags">
+			<view style="background: #FA8C16;">
+				{{item.brandname}}
+			</view>
+			<view wx:for="{{item.tradefield}}" wx:key="tradefield" style="background: #FF3B30;">
+				{{item.tradefield}}
+			</view>
+		</view>
+		<view class="price">
+			<view>
+				¥ {{item.gradeprice}}
+			</view>
+			<text>× {{item.unitname}}</text>
+		</view>
+	</view>
+</navigator>
+<Yl_Empty wx:if="{{list.length === 0}}" />