优化商圈部分功能

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) { success: function(res) {
if (res.statusCode == 200) { if (res.statusCode == 200) {
let _products = res.data.data; resolve(res.data);
resolve(_products);
return; return;
} }
reject(); reject();

View File

@ -1,6 +1,6 @@
<template> <template>
<!-- @scrolltolower="lower" --> <!-- @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)" <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"> indicator-active-color="#FECA49">
<block v-for="(item, index) in categoryList" :key="index"> <block v-for="(item, index) in categoryList" :key="index">

View File

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

View File

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