.NET经销商实战(十)——根据物品小类筛选数据
2022/5/25 23:20:03
本文主要是介绍.NET经销商实战(十)——根据物品小类筛选数据,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
productList.ts代码如下:
点击查看代码
<template> <div> <div class="search-pad"> <input type="text" name="" id="" @focus="searchFocus()" @blur="searchBlur()" /> <button v-show="isShowSearchBtn">搜索</button> <button v-show="!isShowSearchBtn" @click="showRight()">筛选</button> </div> <div class="system-pad"> <div v-for="belongType in belongTypes" :key="belongType.sysNo" :class="[ 'system-item', { 'system-select': systemIndex == belongType.sysNo }, ]" @click="getSystemProduct(belongType.sysNo)" > <span>{{ belongType.belongTypeName }}</span> </div> </div> <div class="product-list"> <ul> <li v-for="product in products" :key="product.id"> <img :src="product.productPhoto?.productPhotoUrl" alt="" /> <div> <p class="p-name">{{ product.productName }}</p> <p class="p-type">类别:{{ product.typeName }}</p> <p class="p-price"> ¥{{ tranPrice(product.productSale?.salePrice) }}/张 </p> </div> </li> </ul> <div :class="['left-menu', { 'left-menu-show': isShowLeft }]"> <div class="left-switch" @click="showLeft()"> <img src="/img/dealerImgs/up.png" alt="" /> </div> <ul> <li v-for="productType in productTypes" :key="productType.typeNo" @click="selectType(productType.typeNo)" :class="{ 'left-item-select': typeSelected == productType.typeNo }" > {{ productType.typeName }} </li> </ul> </div> </div> <div class="right-pad"> <ul class="f-type-list"> <li> <p>颜色</p> <ul class="f-item-list"> <li><span>胡桃色</span></li> <li><span class="prop-select">胡桃色</span></li> <li><span>胡桃色</span></li> <li><span>胡桃色</span></li> <li><span>胡桃色</span></li> </ul> <div class="clear-tag"></div> </li> <li> <p>颜色</p> <ul class="f-item-list"> <li><span>胡桃色</span></li> <li><span>胡桃色</span></li> <li><span>胡桃色</span></li> <li><span>胡桃色</span></li> <li><span>胡桃色</span></li> </ul> <div class="clear-tag"></div> </li> <li> <p>颜色</p> <ul class="f-item-list"> <li><span>胡桃色</span></li> <li><span>胡桃色</span></li> <li><span>胡桃色</span></li> <li><span>胡桃色</span></li> <li><span>胡桃色</span></li> </ul> <div class="clear-tag"></div> </li> </ul> <div class="right-edit"> <button @click="confirmFilter()" style="background-color: rgb(188, 0, 0); color: #fff" > 确定 </button> <button @click="hideRight()">取消</button> </div> </div> <div class="cover" v-show="isShowCover" @click="hideRight()"></div> </div> </template> <script lang="ts"> import { ref, onMounted, reactive, toRefs } from 'vue' import { getProduct, getBelongType, getProductType, } from '@/httpRequests/ProductListRequest' import { IProductInfo } from '@/Interfaces/ProductList' export default { setup() { const pageController = reactive({ isShowLeft: ref(false), isShowCover: ref(false), isShowSearchBtn: ref(false), }) //IProductInfo const productInfo: IProductInfo = reactive({ systemIndex: '1', products: [], belongTypes: [], productTypes: [], typeSelected: '', /** * 获取物品 */ getProducts: async ( systemIndex: string, productType: string | null = null ) => { productInfo.products = await getProduct({ systemNo: systemIndex, productType: productType, sort: 'ProductName', pageIndex: 1, }) console.log(productInfo.products) }, tranPrice: (price: number) => { if (price == null) { return '0.00' } else { return price.toFixed(2).toString() } }, getBelongType: async () => { productInfo.belongTypes = await getBelongType() console.log(productInfo.belongTypes) }, getProductType: async (belongTypeName: string) => { productInfo.productTypes = await getProductType(belongTypeName) }, getSystemProduct: async (index: string) => { productInfo.systemIndex = index await productInfo.getProducts(index, null) await productInfo.getProductType(index) }, selectType: async (typeNo: string) => { if (productInfo.typeSelected == typeNo) { productInfo.typeSelected = '' } else { productInfo.typeSelected = typeNo } await productInfo.getProducts( productInfo.systemIndex, productInfo.typeSelected ) console.log('productInfo.typeSelected: ' + productInfo.typeSelected) }, }) const showLeft = () => { pageController.isShowLeft = !pageController.isShowLeft } const searchFocus = () => { pageController.isShowSearchBtn = true } const searchBlur = () => { pageController.isShowSearchBtn = false } const confirmFilter = () => {} const showRight = () => { pageController.isShowCover = true var dom = document.querySelector('.right-pad') as HTMLElement dom.style.right = '0' } const hideRight = () => { pageController.isShowCover = false var dom = document.querySelector('.right-pad') as HTMLElement dom.style.right = '-85%' } onMounted(async () => { await productInfo.getProducts('bc', null) await productInfo.getBelongType() await productInfo.getProductType('1') }) return { ...toRefs(pageController), ...toRefs(productInfo), showLeft, searchFocus, searchBlur, confirmFilter, showRight, hideRight, } }, } </script> <style lang="scss" scoped> .i-search:after { background-color: #b70101 !important; } .search-pad { z-index: 10; position: fixed; width: 100%; padding: 6px 20px; background-color: #f0f0f0; display: flex; input { height: 28px; box-sizing: border-box; border: 1px solid #ddd; border-radius: 3px; flex: 1; outline: none; } button { background-color: transparent; width: 56px; border: 0 none; font-size: 14px; font-weight: bold; color: #333; outline: none; } } .system-pad { z-index: 10; position: fixed; width: 100%; top: 40px; background-color: #fff; display: flex; .system-item { flex: 1; text-align: center; border-bottom: 1px #ddd solid; border-right: 1px transparent solid; border-left: 1px transparent solid; span { border: 0 none !important; background-color: #f0f2f5; margin: 6px 5px; font-size: 12px; font-weight: normal; text-align: center; border-radius: 4px; padding: 6px 0; display: block; height: 20px; line-height: 12px; } } .system-select { border-bottom: 1px transparent solid; border-right: 1px #ddd solid; border-left: 1px #ddd solid; span { background-color: transparent; } } } .product-list { padding-top: 75px; ul { background-color: #fff; li { list-style: none; height: 88px; padding-left: 108px; position: relative; img { height: 66px; width: 66px; background-color: #ccc; position: absolute; left: 28px; top: 11px; } div { padding: 10px 0; border-bottom: 1px solid #f0f0f0; padding-bottom: 12px; text-align-last: left; .p-name { font-size: 13px; } .p-type { font-size: 12px; color: #666; margin-top: 8px; } .p-price { font-size: 13px; color: #f23030; margin-top: 8px; } } } } .left-menu { position: fixed; height: calc(100% - 116px); left: -106px; width: 125px; background-color: #fff; top: 76px; border-radius: 0 18px 0 0; border: 1px solid #d7d7d7; overflow: hidden; transition: 0.5s; margin-bottom: 120px; .left-switch { width: 20px; background-color: #fff; position: absolute; right: 0; height: 100%; img { position: absolute; top: 42%; left: 2px; width: 20px; transform: rotate(90deg); transition: 0.5s; } } ul { position: absolute; height: 100%; width: 106px; background-color: #f0f0f0; overflow: auto; li { width: 106px; height: 50px; text-align: center; line-height: 50px; border-bottom: 1px solid #d7d7d7; padding: 0; font-size: 12px; color: #333; } li.left-item-select { background-color: #fff; } } } .left-menu-show { left: 0; .left-switch { img { transform: rotate(-90deg); } } } } .right-pad { position: fixed; /* right: -85%; */ right: -85%; top: 0; width: 85%; height: 100%; background-color: #f7f7f7; z-index: 103; transition: 580ms; z-index: 101; ul { list-style: none; overflow: hidden; } .f-type-list { overflow: hidden; > li { padding: 10px; background-color: #fff; margin-bottom: 10px; .f-item-list { overflow: hidden; display: flex; flex-wrap: wrap; li { flex-basis: 33.3%; span { display: block; margin-top: 10px; margin-right: 10px; background: #eee; border: 1px solid #eee; padding: 5px 0; text-align: center; border-radius: 6px; font-size: 13px; } .prop-select { border: 1px solid red; background: #fff; color: red; } } } p { font-size: 14px; } } } .right-edit { position: absolute; bottom: 0; left: 0; width: 100%; button { float: left; height: 40px; width: 50%; line-height: 40px; text-align: center; border: 0px none; } } } .cover { position: fixed; height: 100%; width: 100%; left: 0; top: 0; background-color: rgba(51, 51, 51, 0.36); } </style>
本章主要调整前端界面样式,css的调整,固定查询搜索框,及商品类别的调整,从刚开始的整个页面都是死数据,现在已经改造成了除了查询条件是死数据,其余都是真实数据了
这篇关于.NET经销商实战(十)——根据物品小类筛选数据的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2022-03-01沐雪多租宝商城源码从.NetCore3.1升级到.Net6的步骤
- 2024-12-06使用Microsoft.Extensions.AI在.NET中生成嵌入向量
- 2024-11-18微软研究:RAG系统的四个层次提升理解与回答能力
- 2024-11-15C#中怎么从PEM格式的证书中提取公钥?-icode9专业技术文章分享
- 2024-11-14云架构设计——如何用diagrams.net绘制专业的AWS架构图?
- 2024-05-08首个适配Visual Studio平台的国产智能编程助手CodeGeeX正式上线!C#程序员必备效率神器!
- 2024-03-30C#设计模式之十六迭代器模式(Iterator Pattern)【行为型】
- 2024-03-29c# datetime tryparse
- 2024-02-21list find index c#
- 2024-01-24convert toint32 c#