style: 后端ES接口返回格式调整,前端字段调整

master
学习很差啦 2023-04-04 16:07:22 +08:00
parent f0dcf473e8
commit c097a423f9
7 changed files with 44 additions and 44 deletions

View File

@ -51,13 +51,13 @@
// //
navigateToDetailPage(item) { navigateToDetailPage(item) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/product/goods?id=${item.content.id}&goodsId=${item.content.goodsId}`, url: `/pages/product/goods?id=${item.id}&goodsId=${item.goodsId}`,
}); });
}, },
// //
navigateToStoreDetailPage(item) { navigateToStoreDetailPage(item) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/product/shopPage?id=${item.content.storeId}`, url: `/pages/product/shopPage?id=${item.storeId}`,
}); });
}, },
}, },

View File

@ -4,24 +4,24 @@
<view class="goods-list" v-if="type == 'twoColumns'"> <view class="goods-list" v-if="type == 'twoColumns'">
<view v-for="(item, index) in res" :key="index" class="goods-item"> <view v-for="(item, index) in res" :key="index" class="goods-item">
<view class="image-wrapper" @click="navigateToDetailPage(item)"> <view class="image-wrapper" @click="navigateToDetailPage(item)">
<u-image :src="item.content.thumbnail" width="100%" height='330rpx' mode="aspectFit"> <u-image :src="item.thumbnail" width="100%" height='330rpx' mode="aspectFit">
<u-loading slot="loading"></u-loading> <u-loading slot="loading"></u-loading>
</u-image> </u-image>
</view> </view>
<view class="goods-detail"> <view class="goods-detail">
<div class="title clamp" v-html="lightSearchStr(keyword,item.content.goodsName)" <div class="title clamp" v-html="lightSearchStr(keyword,item.goodsName)"
@click="navigateToDetailPage(item)"> @click="navigateToDetailPage(item)">
</div> </div>
<view class="price-box" @click="navigateToDetailPage(item)"> <view class="price-box" @click="navigateToDetailPage(item)">
<div class="price" v-if="item.content.price!=undefined"> <div class="price" v-if="item.price!=undefined">
¥<span>{{ $options.filters.goodsFormatPrice(item.content.price )[0] }} </span>.{{ ¥<span>{{ $options.filters.goodsFormatPrice(item.price )[0] }} </span>.{{
$options.filters.goodsFormatPrice(item.content.price )[1] $options.filters.goodsFormatPrice(item.price )[1]
}} }}
</div> </div>
</view> </view>
<div class="promotion" @click="navigateToDetailPage(item)"> <div class="promotion" @click="navigateToDetailPage(item)">
<div v-if="item.content.salesModel == 'WHOLESALE'"> <div v-if="item.salesModel == 'WHOLESALE'">
<span></span> <span></span>
</div> </div>
<div v-for="(promotionItem,promotionIndex) in getPromotion(item)" :key="promotionIndex"> <div v-for="(promotionItem,promotionIndex) in getPromotion(item)" :key="promotionIndex">
@ -31,14 +31,14 @@
</div> </div>
</div> </div>
<div class="count-config" @click="navigateToDetailPage(item)"> <div class="count-config" @click="navigateToDetailPage(item)">
<span>已售 {{ item.content.buyCount || "0" }}</span> <span>已售 {{ item.buyCount || "0" }}</span>
<span>{{ item.content.commentNum || "0" }}条评论</span> <span>{{ item.commentNum || "0" }}条评论</span>
</div> </div>
<div class="store-seller-name" v-if="storeName" @click="navigateToStoreDetailPage(item)"> <div class="store-seller-name" v-if="storeName" @click="navigateToStoreDetailPage(item)">
<div class="text-hidden"> <div class="text-hidden">
<u-tag style="margin-right: 10rpx" size="mini" mode="dark" v-if="item.selfOperated" <u-tag style="margin-right: 10rpx" size="mini" mode="dark" v-if="item.selfOperated"
text="自营" type="error" /> text="自营" type="error" />
<span>{{ item.content.storeName || "暂无" }}</span> <span>{{ item.storeName || "暂无" }}</span>
</div> </div>
<span> <span>
<u-icon name="arrow-right"></u-icon> <u-icon name="arrow-right"></u-icon>
@ -52,21 +52,21 @@
<div v-for="(item, index) in res" :key="index" class="goods-row"> <div v-for="(item, index) in res" :key="index" class="goods-row">
<div class="flex goods-col"> <div class="flex goods-col">
<div class="goods-img" @click="navigateToDetailPage(item)"> <div class="goods-img" @click="navigateToDetailPage(item)">
<u-image width="230rpx" mode="aspectFit" border-radius='16' height="230rpx" :src="item.content.thumbnail"> <u-image width="230rpx" mode="aspectFit" border-radius='16' height="230rpx" :src="item.thumbnail">
<u-loading slot="loading"></u-loading> <u-loading slot="loading"></u-loading>
</u-image> </u-image>
</div> </div>
<div class="goods-detail"> <div class="goods-detail">
<div class="title clamp3" @click="navigateToDetailPage(item)">{{ item.content.goodsName }}</div> <div class="title clamp3" @click="navigateToDetailPage(item)">{{ item.goodsName }}</div>
<view class="price-box" @click="navigateToDetailPage(item)"> <view class="price-box" @click="navigateToDetailPage(item)">
<div class="price" v-if="item.content.price!=undefined"> <div class="price" v-if="item.price!=undefined">
¥<span>{{ $options.filters.goodsFormatPrice(item.content.price )[0] }} </span>.{{ ¥<span>{{ $options.filters.goodsFormatPrice(item.price )[0] }} </span>.{{
$options.filters.goodsFormatPrice(item.content.price )[1] $options.filters.goodsFormatPrice(item.price )[1]
}} }}
</div> </div>
</view> </view>
<div class="promotion" @click="navigateToDetailPage(item)"> <div class="promotion" @click="navigateToDetailPage(item)">
<div v-if="item.content.salesModel == 'WHOLESALE'"> <div v-if="item.salesModel == 'WHOLESALE'">
<span></span> <span></span>
</div> </div>
<div v-for="(promotionItem,promotionIndex) in getPromotion(item)" :key="promotionIndex"> <div v-for="(promotionItem,promotionIndex) in getPromotion(item)" :key="promotionIndex">
@ -76,14 +76,14 @@
</div> </div>
</div> </div>
<div style="overflow: hidden" @click="navigateToDetailPage(item)" class="count-config"> <div style="overflow: hidden" @click="navigateToDetailPage(item)" class="count-config">
<span style="float: left; font-size: 22rpx">已售 {{ item.content.buyCount || '0' }}</span> <span style="float: left; font-size: 22rpx">已售 {{ item.buyCount || '0' }}</span>
<span style="float: right; font-size: 22rpx">{{ item.content.commentNum || '0' }}条评论</span> <span style="float: right; font-size: 22rpx">{{ item.commentNum || '0' }}条评论</span>
</div> </div>
<div style="overflow: hidden" @click="navigateToStoreDetailPage(item)" class="count-config"> <div style="overflow: hidden" @click="navigateToStoreDetailPage(item)" class="count-config">
<div class="text-hidden" v-if="storeName"> <div class="text-hidden" v-if="storeName">
<u-tag style="margin-right: 10rpx" size="mini" mode="dark" v-if="item.selfOperated" <u-tag style="margin-right: 10rpx" size="mini" mode="dark" v-if="item.selfOperated"
text="自营" type="error" /> text="自营" type="error" />
<span class="line1-store-name">{{ item.content.storeName }}</span> <span class="line1-store-name">{{ item.storeName }}</span>
<span class="to-store">进店<u-icon size="24" name="arrow-right" color="#666"></u-icon> <span class="to-store">进店<u-icon size="24" name="arrow-right" color="#666"></u-icon>
</span> </span>
</div> </div>
@ -179,8 +179,8 @@
}, },
// //
getPromotion(item) { getPromotion(item) {
if (item.content ? item.content.promotionMap : item.promotionMap) { if (item ? item.promotionMap : item.promotionMap) {
const fieldList = item.content ? item.content.promotionMap : item.promotionMap const fieldList = item ? item.promotionMap : item.promotionMap
let array = []; let array = [];
Object.keys(fieldList).forEach((child) => { Object.keys(fieldList).forEach((child) => {
if (!array.includes(child.split("-")[0])) { if (!array.includes(child.split("-")[0])) {
@ -193,13 +193,13 @@
// //
navigateToDetailPage(item) { navigateToDetailPage(item) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/product/goods?id=${item.content.id}&goodsId=${item.content.goodsId}`, url: `/pages/product/goods?id=${item.id}&goodsId=${item.goodsId}`,
}); });
}, },
// //
navigateToStoreDetailPage(item) { navigateToStoreDetailPage(item) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/product/shopPage?id=${item.content.storeId}`, url: `/pages/product/shopPage?id=${item.storeId}`,
}); });
}, },
} }

View File

@ -59,11 +59,11 @@ export default {
} }
}); });
let goodsList = await getGoodsList(submit); let goodsList = await getGoodsList(submit);
this.goodsList.push(...goodsList.data.result.content); this.goodsList.push(...goodsList.data.result.records);
}, },
handleClick(item) { handleClick(item) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/product/goods?id=${item.content.id}&goodsId=${item.content.goodsId}`, url: `/pages/product/goods?id=${item.id}&goodsId=${item.goodsId}`,
}); });
}, },
}, },

View File

@ -493,13 +493,13 @@ export default {
// //
navigateToDetailPage(item) { navigateToDetailPage(item) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/product/goods?id=${item.content.id}&goodsId=${item.content.goodsId}` url: `/pages/product/goods?id=${item.id}&goodsId=${item.goodsId}`
}); });
}, },
// //
navigateToStoreDetailPage(item) { navigateToStoreDetailPage(item) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/product/shopPage?id=${item.content.storeId}` url: `/pages/product/shopPage?id=${item.storeId}`
}); });
}, },
loadmore() { loadmore() {
@ -627,14 +627,14 @@ export default {
} }
// #TODO // #TODO
let goodsList = await getGoodsList(this.params); let goodsList = await getGoodsList(this.params);
if (goodsList.data.result.records.length < 10) {
if (goodsList.data.result.content.length < 10) {
this.loadingType = 'noMore'; this.loadingType = 'noMore';
this.empty = true; this.empty = true;
} else { } else {
this.empty = false; this.empty = false;
} }
this.goodsList.push(...goodsList.data.result.content); this.goodsList.push(...goodsList.data.result.records);
this.initSortGoods(); this.initSortGoods();
uni.hideLoading(); uni.hideLoading();
}, },

View File

@ -759,7 +759,7 @@ export default {
storeId: this.goodsDetail.storeId, storeId: this.goodsDetail.storeId,
recommend: true, recommend: true,
}).then((res) => { }).then((res) => {
this.recommendList = res.data.result.content; this.recommendList = res.data.result.records;
}); });
}, },
@ -774,7 +774,7 @@ export default {
category: this.goodsDetail.categoryId, category: this.goodsDetail.categoryId,
keyword: this.goodsDetail.name, keyword: this.goodsDetail.name,
}).then((res) => { }).then((res) => {
this.likeGoodsList = res.data.result.content; this.likeGoodsList = res.data.result.records;
}); });
}, },

View File

@ -24,15 +24,15 @@
<view class="store-recommend-title">商品推荐</view> <view class="store-recommend-title">商品推荐</view>
<view class="recommend-list"> <view class="recommend-list">
<view class="recommend-item" @click="clickGoods(item)" v-for="(item, index) in res" :key="index"> <view class="recommend-item" @click="clickGoods(item)" v-for="(item, index) in res" :key="index">
<u-image class="recommend-item-img" :fade="true" duration="450" :lazy-load="true" :src="item.content.thumbnail" height="218rpx"> <u-image class="recommend-item-img" :fade="true" duration="450" :lazy-load="true" :src="item.thumbnail" height="218rpx">
<u-loading slot="loading"></u-loading> <u-loading slot="loading"></u-loading>
<view slot="error" style="font-size: 24rpx; ">加载失败</view> <view slot="error" style="font-size: 24rpx; ">加载失败</view>
</u-image> </u-image>
<view class="recommend-item-name"> <view class="recommend-item-name">
{{ item.content.goodsName }} {{ item.goodsName }}
</view> </view>
<view class="item-price" v-if="item.price != undefined"> <view class="item-price" v-if="item.price != undefined">
<span class="item-price-blod">{{ $options.filters.goodsFormatPrice(item.content.price)[0] }}</span>.{{ $options.filters.goodsFormatPrice(item.content.price)[1] }} <span class="item-price-blod">{{ $options.filters.goodsFormatPrice(item.price)[0] }}</span>.{{ $options.filters.goodsFormatPrice(item.price)[1] }}
</view> </view>
</view> </view>
</view> </view>
@ -51,7 +51,7 @@ export default {
// //
clickGoods(val) { clickGoods(val) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/product/goods?id=${val.content.id}&goodsId=${val.content.goodsId}`, url: `/pages/product/goods?id=${val.id}&goodsId=${val.goodsId}`,
}); });
}, },

View File

@ -13,17 +13,17 @@
<view class="scroll-con"> <view class="scroll-con">
<view v-if="nomsg"></view> <view v-if="nomsg"></view>
<view v-else class="con" v-for="(item,index) in goodsList" :key="index" @click="goDetail(item)"> <view v-else class="con" v-for="(item,index) in goodsList" :key="index" @click="goDetail(item)">
<image :src="item.content.thumbnail" mode=""></image> <image :src="item.thumbnail" mode=""></image>
<view class="nowrap">{{item.content.name}}</view> <view class="nowrap">{{item.name}}</view>
<view> <view>
<text>{{item.content.price | unitPrice}} <text>{{item.price | unitPrice}}
<!-- <text v-if="item.point">+{{item.point || 0}}</text> --> <!-- <text v-if="item.point">+{{item.point || 0}}</text> -->
</text> </text>
<text>{{item.content.mktprice}}</text> <text>{{item.mktprice}}</text>
</view> </view>
<view> <view>
<text>已售{{item.content.buy_count}}</text> <text>已售{{item.buy_count}}</text>
<text>{{item.content.grade}}%好评</text> <text>{{item.grade}}%好评</text>
</view> </view>
</view> </view>
</view> </view>
@ -74,7 +74,7 @@
}, },
goDetail(item) { goDetail(item) {
uni.navigateTo({ uni.navigateTo({
url: '/pages/product/goods?id=' + item.content.id + "&goodsId=" +item.content.goodsId url: '/pages/product/goods?id=' + item.id + "&goodsId=" +item.goodsId
}) })
}, },
loadData() { loadData() {