优化商圈部分功能

This commit is contained in:
wuxw 2022-12-02 18:29:56 +08:00
parent b334cfe674
commit bb1615c42b
4 changed files with 67 additions and 49 deletions

View File

@ -56,8 +56,7 @@ export function queryPhoneMainCategoryProduct(dataObj) {
//动态数据
success: function(res) {
if (res.statusCode == 200) {
let _products = res.data.data;
resolve(_products);
resolve(res.data);
return;
}
reject();

View File

@ -1,6 +1,6 @@
<template>
<!-- @scrolltolower="lower" -->
<scroll-view class="scroll-restaurants-list " scroll-y="true" style="height:300upx">
<scroll-view class="scroll-restaurants-list " scroll-x="true" style="height:300upx">
<swiper class=" padding-top-xs margin-top-sm bg-white c-radius" style="height: 280upx;" indicator-dots="true" indicator-color="rgba(228,228,228,1)"
indicator-active-color="#FECA49">
<block v-for="(item, index) in categoryList" :key="index">

View File

@ -3,7 +3,8 @@
<view>
<view class="text-left ">
<scroll-view scroll-x class="nav" scroll-with-animation>
<view class="cu-item" :class="item.mainCategoryId==curCategoryId?'text-catagory-select ':'text-catagory'"
<view class="cu-item"
:class="item.mainCategoryId==curCategoryId?'text-catagory-select ':'text-catagory'"
v-for="(item,index) in mainCatagorys" :key="index" @tap="_doSelect(item)" :data-id="index">
{{item.categoryName}}
</view>
@ -15,9 +16,9 @@
@tap="_toGoodsDetail(product)">
<view v-if="product.coverPhoto">
<image class="goods-image c-radius" :src="product.coverPhoto"></image>
</view>
<view v-else>
<image class="goods-image c-radius" :src="noPic"></image>
</view>
<view v-else>
<image class="goods-image c-radius" :src="noPic"></image>
</view>
<view class="margin-top-sm text-left">
<text>{{product.prodName}}</text>
@ -39,8 +40,8 @@
<script>
import {
getRecommendProduct,
queryMainCategory,
getRecommendProduct,
queryMainCategory,
queryPhoneMainCategoryProduct
} from '../../api/goods/goodsApi.js'
import conf from '../../conf/config.js'
@ -49,61 +50,74 @@
} from '../../api/community/communityApi.js';
export default {
data() {
return {
curCategoryId:'-1',
return {
curCategoryId: '-1',
mainCatagorys: [{
categoryName: "为你推荐",
mainCategoryId: "-1"
}],
products: [],
communityId: "",
noPic:''
communityId: "",
noPic: '',
pagesize: 10,
pagefrom: 1,
}
},
mounted() {
this._loadMainCatagory();
this.noPic = this.imgUrl+'/h5/images/noPic.png'
mounted() {
this._loadMainCatagory();
this.noPic = this.imgUrl + '/h5/images/noPic.png'
},
methods: {
_loadMainCatagory: function() {
let _that = this;
let _data = {
page: 1,
row: 10
methods: {
_loadMainCatagory: function() {
let _that = this;
let _data = {
page: 1,
row: 10
}
queryMainCategory(_data)
.then((products) => {
if(!products || products.length <1){
return ;
}
_that.mainCatagorys = products;
_that.curCategoryId = products[0].mainCategoryId;
}).then(()=>{
_that._loadRecommendProdcut();
})
this.products=[];
this.pagefrom =1;
queryMainCategory(_data)
.then((products) => {
if (!products || products.length < 1) {
return;
}
_that.mainCatagorys = products;
_that.curCategoryId = products[0].mainCategoryId;
}).then(() => {
_that._loadRecommendProdcut();
})
},
_loadRecommendProdcut: function() {
let _that = this;
_that.communityId = getMallCommunityId();
let _data = {
page: 1,
row: 10,
communityId: _that.communityId,
page: this.pagefrom,
row: this.pagesize,
communityId: _that.communityId,
mainCategoryId: _that.curCategoryId
}
queryPhoneMainCategoryProduct(_data)
.then((products) => {
_that.products = products;
.then((_data) => {
_that.products = _that.products.concat(_data.data);
if (_that.pagefrom <= _data.records) {
_that.pagefrom = _that.pagefrom + 1;
} else {
_that.loadingText = "已经到底了";
}
})
},
_toGoodsDetail: function(_product) {
this.vc.navigateToMall({
url: '/pages/goods/goods?productId=' + _product.productId + "&shopId=" + _product.shopId
}, true);
},
_doSelect:function(item){
},
_doSelect: function(item) {
this.curCategoryId = item.mainCategoryId;
this._loadRecommendProdcut();
this.pagefrom =1;
this.products=[];
this._loadRecommendProdcut();
}
}
}
@ -121,14 +135,16 @@
.goods-image {
height: 180upx;
}
.text-catagory{
color: #656565;
font-size: 28upx;
}
.text-catagory-select{
color: #000000;
font-size: 40upx;
}
.text-catagory {
color: #656565;
font-size: 28upx;
}
.text-catagory-select {
color: #000000;
font-size: 40upx;
}
</style>

View File

@ -97,6 +97,9 @@
}
this.shopTypeId = 0
},
onReachBottom() {
this.$refs.vcRecommendRef._loadRecommendProdcut();
},
methods: {
selectType(index) {
let shopTypeId = this.navList[index].shopTypeId;