| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- <template>
- <view class="hot">
- <view
- class="head-item"
- @click="goDetail('/pages/tabtar/goodsType', false, true)"
- :style="{ backgroundImage: `url(${bgImage || ''})` }"
- >
- <view class="top-left">
- <view class="top-left-title">热门推荐</view>
- <view class="top-left-tip">精选好物推荐</view>
- </view>
- <view class="top-right" style="color: #db7d75">
- 查看更多
- <!-- <text class="iconfont u-font24"></text> -->
- <uv-icon name="arrow-right" size="24rpx" color="#db7d75"></uv-icon>
- </view>
- </view>
- <view
- class="hot-item u-skeleton-fillet"
- v-if="(recommendList && recommendList.length > 0) || skeletonShow"
- >
- <view
- class="item"
- v-for="item in recommendList.length > 0 ? recommendList : 2"
- :key="item.id"
- @click="
- goProductDetails('/pages/shop/goodsDetails?id=' + item.productId)
- "
- >
- <!-- ?x-oss-process=style/w_350 -->
- <image
- v-if="item && item.coverImage"
- :src="`${item.coverImage}`"
- mode="aspectFill"
- ></image>
- <div class="title-price">
- <view class="hot-introduce" v-if="item && item.title">{{
- item.title
- }}</view>
- <view class="hot-number">
- <view class="hot-large">
- <rich-text
- :nodes="$mUtil.priceBigSmall(item.minSalePrice)"
- ></rich-text>
- </view>
- <view class="hot-small">¥{{ item.maxSalePrice }}</view>
- </view>
- </div>
- </view>
- </view>
- <noData v-else :config="{ top: 1, content: '暂无商品~' }"></noData>
- </view>
- </template>
- <script setup>
- import { ref, onMounted } from "vue";
- import { shopProductList_Api } from "@/api/shop";
- const props = defineProps({
- skeletonShow: {
- type: Boolean,
- default: false
- },
- bgImage: {
- type: String,
- default: ''
- }
- });
- const emit = defineEmits(['goDetail', 'goProductDetails']);
- const recommendList = ref([]); //推荐
- const goDetail = (url, isNeedLogin, tabShow) => {
- emit('goDetail', url, isNeedLogin, tabShow);
- };
- const goProductDetails = (url) => {
- emit('goProductDetails', url);
- };
- /**热门推荐 */
- const recommend = () => {
- shopProductList_Api({
- limit: 6,
- recommendStatus: 1,
- }).then((res) => {
- if (res && res.code == 200) {
- recommendList.value = res.data;
- }
- });
- };
- onMounted(() => {
- recommend();
- });
- defineExpose({
- init: recommend,
- });
- </script>
- <style scoped lang="scss">
- .hot {
- background: #ffe7e7;
- box-sizing: border-box;
- border-radius: 10rpx;
- overflow: hidden;
- .hot-item {
- display: flex;
- overflow: scroll;
- white-space: nowrap;
- padding: 0 30rpx 40rpx 30rpx;
- box-sizing: border-box;
- margin-top: 27rpx;
- .hot-number {
- display: flex;
- align-items: flex-end;
- margin-top: 20rpx;
- }
- .hot-large {
- color: #00bf5a;
- font-size: 36rpx;
- font-weight: Bold;
- line-height: 24rpx;
- }
- .hot-small {
- font-size: 22rpx;
- font-weight: Medium;
- line-height: 24rpx;
- color: #cccccc;
- margin-left: 16rpx;
- text-decoration: line-through;
- }
- .title-price {
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- height: 140rpx;
- }
- .hot-introduce {
- overflow: hidden;
- word-break: break-all;
- margin-top: 24rpx;
- font-size: 24rpx;
- font-weight: Regular;
- line-height: 34rpx;
- color: #333333;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- word-wrap: break-word;
- white-space: normal !important;
- width: 252rpx;
- }
- .item {
- padding: 20rpx;
- background-color: #ffffff;
- border-radius: 16rpx;
- margin-right: 20rpx;
- image {
- width: 252rpx;
- height: 252rpx;
- border-radius: 16rpx;
- }
- }
- }
- }
- .head-item {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 27rpx 30rpx;
- box-sizing: border-box;
- overflow: hidden;
- background-size: 100% 100%;
- background-repeat: no-repeat;
- .top-left {
- .top-left-title {
- font-size: 36rpx;
- font-family: PingFang SC, PingFang SC-Bold;
- font-weight: 700;
- }
- .top-left-tip {
- font-size: 24rpx;
- font-family: PingFang SC, PingFang SC-Regular;
- font-weight: 400;
- margin-top: 5rpx;
- }
- }
- .top-right {
- width: 165rpx;
- height: 67rpx;
- line-height: 67rpx;
- background: #ffffff;
- border-radius: 34rpx;
- box-sizing: border-box;
- font-size: 24rpx;
- font-family: PingFang SC, PingFang SC-Regular;
- font-weight: 400;
- text-align: center;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- }
- </style>
|