【商品推荐】

1. 实现功能
pull/1/MERGE
YunaiV 2023-06-25 16:48:23 +08:00
parent 202ee764ba
commit a08e05ea8b
3 changed files with 50 additions and 33 deletions

View File

@ -12,10 +12,10 @@
<view class='text'> <view class='text'>
<view class='line1'>{{ item.name }}</view> <view class='line1'>{{ item.name }}</view>
<view class='money font-color'><text class='num'>{{ fen2yuan(item.price) }}</text></view> <view class='money font-color'><text class='num'>{{ fen2yuan(item.price) }}</text></view>
<view class='vip-money acea-row row-middle' v-if="item.vip_price && item.vip_price > 0">{{item.vip_price || 0}} <view class='vip-money acea-row row-middle' v-if="item.vipPrice > 0">{{ fen2yuan(item.vipPrice || 0) }}
<image src='../../static/images/vip.png'></image><text class='num'>已售{{Number(item.sales) + Number(item.ficti) || 0}}{{item.unitName}}</text> <image src='../../static/images/vip.png'></image><text class='num'>已售{{ item.salesCount }}{{item.unitName}}</text>
</view> </view>
<view class='vip-money acea-row row-middle' v-else><text class='num'>已售{{Number(item.sales) + Number(item.ficti) || 0}}{{item.unitName}}</text></view> <view class='vip-money acea-row row-middle' v-else><text class='num'>已售{{ item.salesCount }}{{item.unitName}}</text></view>
</view> </view>
</view> </view>
<view class='iconfont icon-gouwuche cart-color acea-row row-center-wrapper'></view> <view class='iconfont icon-gouwuche cart-color acea-row row-center-wrapper'></view>

View File

@ -20,16 +20,18 @@
<div class="line"></div> <div class="line"></div>
</div> </div>
<view class="wrapper"> <view class="wrapper">
<GoodList :bastList="goodsList" :is-sort="false"></GoodList> <GoodList :bastList="goodsList" :is-sort="false" />
<view class="txt-bar" v-if="goodsList.length>0 && !isScroll">线~</view> <view class="txt-bar" v-if="goodsList.length>0 && !isScroll">线~</view>
<emptyPage v-if="goodsList.length==0 && !isScroll" title="暂无数据~"></emptyPage> <emptyPage v-if="goodsList.length === 0 && !isScroll" title="暂无数据~"></emptyPage>
</view> </view>
</div> </div>
</template> </template>
<script> <script>
import emptyPage from '@/components/emptyPage.vue' import emptyPage from '@/components/emptyPage.vue'
import GoodList from "@/components/goodList"; import GoodList from "@/components/goodList";
import { getGroomList } from "@/api/store"; import * as ProductSpuApi from '@/api/product/spu.js';
import * as PromotionActivityApi from '@/api/promotion/activity.js';
import * as ProductUtil from '@/utils/product.js';
export default { export default {
name: "HotNewGoods", name: "HotNewGoods",
components: { components: {
@ -39,7 +41,7 @@ export default {
props: {}, props: {},
data: function() { data: function() {
return { return {
imgUrls: [], imgUrls: [], // TODO @ banner
goodsList: [], goodsList: [],
name: "", name: "",
icon: "", icon: "",
@ -48,6 +50,7 @@ export default {
circular: true, circular: true,
interval: 3000, interval: 3000,
duration: 500, duration: 500,
recommendType: '',
page: 1, page: 1,
limit: 8, limit: 8,
isScroll: true isScroll: true
@ -66,41 +69,56 @@ export default {
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title:"精品推荐" title:"精品推荐"
}) })
this.recommendType = 'best';
} else if (this.type === "2") { } else if (this.type === "2") {
this.name = "热门榜单"; this.name = "热门榜单";
this.icon = "icon-remen"; this.icon = "icon-remen";
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title:"热门榜单" title:"热门榜单"
}) })
this.recommendType = 'hot';
} else if (this.type === "3") { } else if (this.type === "3") {
this.name = "首发新品"; this.name = "首发新品";
this.icon = "icon-xinpin"; this.icon = "icon-xinpin";
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title:"首发新品" title:"首发新品"
}) })
this.recommendType = 'new';
} else if (this.type === "4") { } else if (this.type === "4") {
this.name = "促销单品"; this.name = "促销单品";
this.icon = "icon-xinpin"; this.icon = "icon-xinpin";
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title:"促销单品" title:"促销单品"
}) })
this.recommendType = 'benefit';
} }
}, },
/**
* 获得推荐商品列表
*/
getIndexGroomList: function() { getIndexGroomList: function() {
if(!this.isScroll) return if(!this.isScroll) {
let that = this; return
let type = this.type; }
getGroomList(type,{ ProductSpuApi.getSpuPage({
page:this.page, recommendType: this.recommendType,
limit:this.limit pageNo: this.page,
pageSize: this.limit
}).then(res => { }).then(res => {
that.imgUrls = res.data.banner; const good_list = res.data.list;
that.goodsList = that.goodsList.concat(res.data.list); this.isScroll = good_list.length >= this.limit
that.isScroll = res.data.list.length>=that.limit this.page++
that.page++
}) //
.catch(function(res) { const spuIds = good_list.map(item => item.id);
that.$util.Tips({ title: res }); if (spuIds.length > 0) {
PromotionActivityApi.getActivityListBySpuIds(spuIds).then(res => {
ProductUtil.setActivityList(good_list, res.data);
this.goodsList = this.goodsList.concat(good_list); // Vue
});
}
}).catch(res => {
this.$util.Tips({ title: res });
}); });
} }
}, },

View File

@ -534,7 +534,6 @@
this.iSshowH = true this.iSshowH = true
} }
this.loading = true this.loading = true
console.log(this.goodType, '====')
const type = this.goodType === 1 ? 'best' : const type = this.goodType === 1 ? 'best' :
this.goodType === 2 ? 'hot' : this.goodType === 2 ? 'hot' :
this.goodType === 3 ? 'new' : this.goodType === 3 ? 'new' :