123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478 |
- <template>
- <view class="content" :style="$store.state.theme.currentMoban">
- <view class="top-fixed">
- <!-- 搜索框 -->
- <view class="search-cont">
- <view class="inner">
- <image class="icon-search" src="../../static/images/search.png" mode=""></image>
- <input type="text" @confirm="goSearch" :value="form.productName"
- :placeholder="storeId ? '搜索店内商品' : '输入商品名称'" placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
- </view>
- <view class="icon-search">
- <image @click="showChange(2)" v-if="showType==1" src="../../static/images/search1.png" mode=""></image>
- <image @click="showChange(1)" v-if="showType==2" src="../../static/images/search2.png" mode=""></image>
- </view>
- </view>
- <!-- 排序框 -->
- <view class="sort-box">
- <view class="item" :class="form.defaultOrder=='desc'?'active':''" @click="searchChange('1')">
- <text class="label">默认</text>
- </view>
- <view class="item" @click="searchChange('2')">
- <text class="label">价格</text>
- <view class="sort-img">
- <image v-if="form.priceOrder==null||form.priceOrder=='desc'" src="../../static/images/price_arrow_up.png" mode="" @click="priceUp(true)"></image>
- <image v-if="form.priceOrder=='asc'" src="../../static/images/price_arrow_up2.png" mode="" @click="priceUp(false)"></image>
- <image v-if="form.priceOrder==null||form.priceOrder=='asc'" src="../../static/images/price_arrow_down.png" mode="" @click="priceDown(true)"></image>
- <image v-if="form.priceOrder=='desc'" src="../../static/images/price_arrow_down2.png" mode="" @click="priceDown(false)"></image>
- </view>
- </view>
- <view class="item" @click="searchChange('3')">
- <text class="label">销量</text>
- <view class="sort-img">
- <image v-if="form.salesOrder==null||form.salesOrder=='desc'" src="../../static/images/price_arrow_up.png" mode="" @click="saleUp(true)"></image>
- <image v-if="form.salesOrder=='asc'" src="../../static/images/price_arrow_up2.png" mode="" @click="saleUp(false)"></image>
- <image v-if="form.salesOrder==null||form.salesOrder=='asc'" src="../../static/images/price_arrow_down.png" mode="" @click="saleDown(true)"></image>
- <image v-if="form.salesOrder=='desc'" src="../../static/images/price_arrow_down2.png" mode="" @click="saleDown(false)"></image>
- </view>
- </view>
- <view class="item" :class="form.newOrder=='desc'?'active':''" @click="searchChange('4')">
- <text class="label">新品</text>
- </view>
- </view>
- </view>
-
- <!-- 数据列表 -->
- <mescroll-body top="190rpx" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
- <view class="medic-list" v-if="showType==1">
- <view v-for="(item,index) in dataList" :key="index" class="item" @click="showDetail(item)">
- <view class="img-box">
- <image :src="item.image" mode="aspectFit"></image>
- </view>
- <view class="info-box">
- <view class="title ellipsis2">{{item.productName}}</view>
- <view class="intro ellipsis">{{item.productInfo}}</view>
- <view class="prce-num">
- <view class="price">
- <text class="unit">¥</text>
- <text class="num">{{item.price.toFixed(2)}} </text>
- </view>
- <view class="cart-img" @click="navgetTo('../shopping/cart')">
- <view class="sale">已售 {{item.sales}} {{item.unitName}}</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="goods-list" v-if="showType==2">
- <view class="item" v-for="(item,index) in dataList" :key="index" @click="showDetail(item)">
- <view class="img-box">
- <image :src="item.image" mode="aspectFill"></image>
- </view>
- <view class="info-box">
- <view class="title ellipsis2">{{item.productName}}</view>
- <view class="price-box">
- <view class="now">
- <text class="unit">¥</text>
- <text class="num">{{item.price.toFixed(2)}}</text>
- </view>
- <view class="old">¥{{item.otPrice.toFixed(2)}}</view>
- </view>
- </view>
- </view>
- </view>
- </mescroll-body>
- </view>
- </template>
- <script>
- import {getProducts} from '@/api/product'
- import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
- export default {
- mixins: [MescrollMixin],
- data() {
- return {
- showType:1,
- form:{
- defaultOrder:'desc',
- newOrder:null,
- priceOrder:null,
- salesOrder:null,
- productName:"",
- storeId: ""
- },
- mescroll:null,
- // 上拉加载的配置
- upOption: {
- onScroll:true,
- use: true, // 是否启用上拉加载; 默认true
- page: {
- num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
- size: 10 // 每页数据的数量,默认10
- },
- noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
- empty: {
- icon:'/static/images/no_data.png',
- tip: '暂无数据'
- },
- textNoMore:"已经到底了",
- },
- // 列表数据
- dataList: [],
- storeId: ""
- };
- },
- onLoad(option) {
- if(option.key!=undefined){
- this.form.productName = option.key
- }
- this.storeId = option.storeId || ""
- this.form.storeId = this.storeId
- },
- methods:{
- goSearch(e) {
- this.form.productName=e.detail.value;
- this.mescroll.resetUpScroll();
- },
- searchChange(type){
- if(type==1){
- this.form.defaultOrder="desc";
- this.form.priceOrder=null;
- this.form.salesOrder=null;
- this.form.newOrder=null;
-
- }
- else if(type==2){
- this.form.defaultOrder=null;
- if(this.form.priceOrder==null){
- this.form.priceOrder="asc"
- }
- else if(this.form.priceOrder=="asc"){
- this.form.priceOrder="desc"
- }
- else if(this.form.priceOrder=="desc"){
- this.form.priceOrder=null;
- }
- this.form.salesOrder=null;
- this.form.newOrder=null;
- }
- else if(type==3){
- this.form.defaultOrder=null;
- this.form.priceOrder=null;
- if(this.form.salesOrder==null){
- this.form.salesOrder="asc"
- }
- else if(this.form.salesOrder=="asc"){
- this.form.salesOrder="desc"
- }
- else if(this.form.salesOrder=="desc"){
- this.form.salesOrder=null;
- }
- this.form.newOrder=null;
-
- }
- else if(type==4){
- this.form.newOrder="desc";
- this.form.defaultOrder=null;
- this.form.priceOrder=null;
- this.form.salesOrder=null;
-
-
- }
- this.mescroll.resetUpScroll();
- },
- showChange(type){
- this.showType=type;
- },
- mescrollInit(mescroll) {
- this.mescroll = mescroll;
- },
- /*下拉刷新的回调 */
- downCallback(mescroll) {
- mescroll.resetUpScroll()
- },
- upCallback(page) {
- //联网加载数据
- var that = this;
- this.form.page=page.num;
- this.form.pageSize=page.size;
- getProducts(this.form).then(res => {
- if(res.code==200){
- //设置列表数据
- if (page.num == 1) {
- that.dataList = res.data.list;
-
- } else {
- that.dataList = that.dataList.concat(res.data.list);
-
- }
- that.mescroll.endBySize(res.data.list.length, res.data.total);
-
- }else{
- uni.showToast({
- icon:'none',
- title: "请求失败",
- });
- that.dataList = null;
- that.mescroll.endErr();
- }
- });
- },
- // 价格升序是否选中
- priceUp(value) {
- this.priceIsUp = value
- this.priceIsDown = false
- },
- // 价格降序是否选中
- priceDown(value) {
- this.priceIsDown = value
- this.priceIsUp = false
- },
- // 销量升序是否选中
- saleUp(value) {
- this.saleIsUp = value
- this.saleIsDown = false
- },
- // 销量降序是否选中
- saleDown(value) {
- this.saleIsDown = value
- this.saleIsUp = false
- },
- // 查看详情
- showDetail(item) {
- uni.navigateTo({
- url: '../shopping/productDetails?productId='+item.productId + `${this.storeId ? '&storeId='+this.storeId : ''}`
- })
- }
- }
- }
- </script>
- <style lang="scss">
- .top-fixed{
- width: 100%;
- position: fixed;
- top: 0;
- left: 0;
- z-index: 10;
- }
- .search-cont{
- padding: 16upx 30upx;
- background-color: #FFFFFF;
- display:flex;
- align-items: center;
- justify-content: space-between;
- .inner{
- box-sizing: border-box;
- width: 100%;
- height: 72upx;
- background: #F7F7F7;
- border-radius: 36upx;
- display: flex;
- align-items: center;
- padding: 0 30upx;
- .icon-search{
- width: 28upx;
- height: 28upx;
- margin-right: 20upx;
- }
- input{
- height: 60upx;
- line-height: 60upx;
- flex: 1;
- }
-
- }
- .icon-search{
- margin-left: 10upx;
- width: 40upx;
- height: 40upx;
- image{
- width: 40upx;
- height: 40upx;
- }
-
- }
- }
- .sort-box{
- height: 88upx;
- background: #FFFFFF;
- padding: 0 100upx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .item{
- display: flex;
- align-items: center;
- justify-content: center;
- &.active .label{
- color: var(--base-color);
- }
- .label{
- font-size: 26upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #666666;
- line-height: 1;
- }
- .sort-img{
- height: 20upx;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- margin: 3upx 0 0 10upx;
- image{
- width: 12upx;
- height: 8upx;
- }
- }
- }
- }
- .medic-list{
- padding: 20upx;
- .item{
- box-sizing: border-box;
- min-height: 285upx;
- background: #FFFFFF;
- border: 4upx solid #FFFFFF;
- border-radius: 16upx;
- margin-bottom: 20upx;
- padding: 40upx 30upx;
- display: flex;
- .img-box{
- width: 200upx;
- height: 200upx;
- margin-right: 30upx;
- image{
- width: 100%;
- height: 100%;
- }
- }
- .info-box{
- width: calc(100% - 210upx);
- .title{
- font-size: 32upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #111111;
- line-height: 40rpx;
- height: 80rpx;
- }
- .intro{
- font-size: 26upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #999999;
- line-height: 1;
- margin-top: 26upx;
- }
-
- .prce-num{
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-top: 30upx;
- .price{
- display: flex;
- align-items: flex-end;
- .unit{
- font-size: 24upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #FF6633;
- line-height: 1.2;
- margin-right: 4upx;
- }
- .num{
- font-size: 36upx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #FF6633;
- line-height: 1;
- }
- }
- .cart-img{
- .sale{
- font-size: 20upx;
- font-family: PingFang SC;
- color: #999999;
- }
-
- }
- }
- }
- }
- }
- .goods-list{
- padding: 20upx;
- display: flex;
- flex-wrap: wrap;
- .item{
- margin-right: 20rpx;
- margin-bottom: 20rpx;
- width: 345rpx;
- background: #FFFFFF;
- box-shadow: 0px 0px 10rpx 4rpx rgba(199, 199, 199, 0.22);
- border-radius: 20rpx;
- overflow: hidden;
- &:nth-child(2n) {
- margin-right: 0;
- }
- .img-box{
- width: 100%;
- height: 334upx;
- image{
- width: 100%;
- height: 100%;
- }
- }
- .info-box{
- box-sizing: border-box;
- height: 182upx;
- padding: 20upx 20upx 30upx;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- .title{
- font-size: 26upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #111111;
- line-height: 40upx;
- }
- .price-box{
- display: flex;
- align-items: flex-end;
- .now{
- display: flex;
- align-items: flex-end;
- margin-right: 20upx;
- .unit{
- font-size: 24upx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #FF6633;
- line-height: 1.2;
- margin-right: 4upx;
- }
- .num{
- font-size: 36upx;
- font-family: PingFang SC;
- font-weight: bold;
- color: #FF6633;
- line-height: 1;
- }
- }
- .old{
- font-size: 26upx;
- font-family: PingFang SC;
- font-weight: 500;
- text-decoration: line-through;
- color: #BBBBBB;
- line-height: 1.1;
- }
- }
- }
- }
- }
- </style>
|