vr-shopxo-uniapp/components/magic-list/magic-list.vue

246 lines
13 KiB
Vue
Raw Normal View History

2023-09-05 09:38:15 +00:00
<template>
2023-11-06 11:43:27 +00:00
<view :class="theme_view">
<view v-if="(data_goods_list || null) != null && data_goods_list.length > 0">
2024-04-23 16:52:22 +00:00
<view v-for="(item, index) in data_goods_list" :key="index" class="plugins-magic-content border-radius-main oh spacing-mb">
<view v-if="(item.data || null) != null && item.data.length > 0" :style="(item.bg_images || null) !== null ? 'background-image: url(' + item.bg_images + ');background-size: auto 100%;' : (((item.is_text_white || null) != null) ? 'background: linear-gradient(180deg, '+theme_color+' 0%, '+theme_color_light+' 80%);' : 'background: #fff;')">
2024-04-23 14:33:08 +00:00
<!-- 上下滚动 -->
2024-04-23 16:52:22 +00:00
<view v-if="item.show_style == 0" class="hot-list flex-row flex-warp padding-vertical-main">
<block v-for="(items, indexs) in item.data" :key="indexs">
2024-04-23 14:33:08 +00:00
<block v-if="(items.data || null) != null && items.data.length > 0">
<view :class="items.data.length % 2 == 0 ? 'flex-width-half' : items.data.length === indexs + 1 ? 'wh-auto' : 'flex-width-half'">
<view class="padding-horizontal-main">
<view class="flex-row align-c margin-bottom-xs" :data-value="items.url" @tap="url_event">
2024-04-23 16:52:22 +00:00
<text :class="'text-size fw-b single-text cr-'+(((item.is_text_white || null) != null) ? 'white' : 'black')">{{ items.title }}</text>
2024-04-23 14:33:08 +00:00
<view class="hot-go margin-left-sm">
<block v-if="(items.icon || null) !== null">
2024-04-23 16:52:22 +00:00
<image :src="items.icon" mode="heightFix" class="ht-auto"></image>
2024-04-23 14:33:08 +00:00
</block>
</view>
</view>
2024-04-23 16:52:22 +00:00
<view :class="'text-size-xs margin-bottom-sm cr-'+(((item.is_text_white || null) != null) ? 'white' : 'grey-9')">{{ items.describe }}</view>
2024-04-23 14:33:08 +00:00
<swiper :class="items.data.length % 2 == 0 ? 'swiper-2' : items.data.length === indexs + 1 ? 'swiper-1' : 'swiper-2'" circular :autoplay="(items.rolling_time || null) !== null ? true : false" :vertical="propVertical" :interval="(items.rolling_time || null) !== null ? Number(items.rolling_time) * 1000 : '6000'" :duration="propDuration">
<swiper-item v-for="(itemss, indexss) in items.data" :key="indexss">
<view class="swiper-item">
<view class="flex-row">
<view v-for="(gv, gi) in itemss" :key="gi" :class="item.data.length % 2 == 0 ? 'flex-width-half' : items.data.length === indexs + 1 ? 'flex-width-half-2' : 'flex-width-half'">
<view class="tc" :data-index="index" :data-indexs="indexs" :data-indexss="indexss" :data-gi="gi" :data-value="(gv.goods_url || null) !== null ? gv.goods_url : ''" @tap="goods_event">
<image :src="(gv.images || null) !== null ? gv.images : ''" mode="heightFix" class="swiper-img border-radius-sm"> </image>
<view v-if="(gv.show_field_price_status || 0) == 1" class="price tc single-text">
<text class="sales-price va-m text-size-xss va-b">{{ gv.show_price_symbol }}</text>
<text class="sales-price va-m text-size-xs">{{ gv.min_price }}</text>
2024-04-23 16:52:22 +00:00
<text :class="'va-m text-size-xss cr-'+(((item.is_text_white || null) != null) ? 'price' : 'grey')">{{ gv.show_price_unit }}</text>
2024-04-23 14:33:08 +00:00
</view>
</view>
2023-11-06 11:43:27 +00:00
</view>
2023-10-30 05:49:55 +00:00
</view>
2023-10-11 08:07:02 +00:00
</view>
2024-04-23 14:33:08 +00:00
</swiper-item>
</swiper>
</view>
</view>
</block>
</block>
</view>
<!-- 1切换滚动2切换九宫格3切换滚动 -->
2024-04-23 16:52:22 +00:00
<view v-else-if="item.show_style == 1 || item.show_style == 2 || item.show_style == 3" class="switch-tabs-item-list pr padding-top-main">
2024-04-23 14:33:08 +00:00
<view class="scroll-view-horizontal padding-left-main">
<scroll-view :scroll-x="true" :show-scrollbar="false" :scroll-with-animation="true" :scroll-into-view="'switch-tabs-item-' + show_style1_active_index">
<block v-for="(items, indexs) in item.data" :key="indexs">
<view :class="'tc cp dis-inline-block '+(indexs > 0 ? 'margin-left-xxl' : '')" :id="'switch-tabs-item-' + indexs" :data-indexs="indexs" @tap="switch_tabs_event">
<image v-if="(items.icon || null) != null" :src="items.icon" class="switch-tabs-item-icon va-m margin-right-xs" mode="aspectFit"></image>
2024-04-23 16:52:22 +00:00
<text :class="'text-size-md va-m cr-'+(((item.is_text_white || null) != null) ? 'white' : 'black')+' '+(show_style1_active_index == indexs ? 'text-size cr-'+(((item.is_text_white || null) != null) ? 'white' : 'main') : '')">{{ items.title }} </text>
2024-04-23 14:33:08 +00:00
<view class="lh-xs">
2024-04-23 16:52:22 +00:00
<iconfont name="icon-down-mark" size="36rpx" :color="show_style1_active_index == indexs ? (((item.is_text_white || null) != null) ? '#fff' : theme_color) : 'transparent'" propClass="lh-xs"></iconfont>
2024-04-23 14:33:08 +00:00
</view>
</view>
</block>
</scroll-view>
</view>
<block v-for="(items, indexs) in item.data" :key="indexs">
<view v-if="show_style1_active_index == indexs">
2024-04-23 16:52:22 +00:00
<view v-if="(items.url || null) != null" :data-value="items.url" @tap="url_event" class="padding-right cp pa top-xxxxxl right-0 padding-top-xs">
<text :class="'cr-'+(((item.is_text_white || null) != null) ? 'white' : 'grey')">{{ $t('common.more') }}</text>
<iconfont name="icon-arrow-right" :color="((item.is_text_white || null) != null) ? '#f5f5f5' : '#999'"></iconfont>
2024-04-23 14:33:08 +00:00
</view>
2024-04-23 16:52:22 +00:00
<view v-if="(items.describe || null) != null" :class="'text-size-xs single-text padding-vertical-sm padding-horizontal-main cr-'+(((item.is_text_white || null) != null) ? 'white' : 'grey')">{{items.describe}}</view>
2024-04-23 14:33:08 +00:00
<view :class="(item.show_style == 1 || item.show_style == 2) ? 'padding-horizontal-main padding-top-sm' : (item.show_style == 3 ? 'padding-top-xs padding-bottom-main' : '')">
<component-goods-list :propData="{ style_type: parseInt(item.show_style)-1, goods_list: items.goods_list }" :propLabel="propLabel" :propCurrencySymbol="propCurrencySymbol" :propIsAutoPlay="(items.rolling_time || null) != null" :propIsCartParaCurve="true" propSource="index" propStyleTypeTowClass="border-radius-main padding-horizontal-main padding-top-xs"></component-goods-list>
</view>
2023-11-06 11:43:27 +00:00
</view>
</block>
2023-10-11 08:07:02 +00:00
</view>
2024-04-23 16:52:22 +00:00
</view>
2023-10-11 08:07:02 +00:00
</view>
</view>
</view>
2023-09-05 09:38:15 +00:00
</template>
<script>
2023-10-11 08:07:02 +00:00
const app = getApp();
2024-04-23 14:33:08 +00:00
import componentGoodsList from '@/components/goods-list/goods-list';
2023-10-11 08:07:02 +00:00
export default {
name: 'recommend-hot',
data() {
return {
theme_view: app.globalData.get_theme_value_view(),
2024-04-23 14:33:08 +00:00
theme_color: app.globalData.get_theme_color(),
theme_color_light: app.globalData.get_theme_color(null, true),
data_goods_list: [],
2024-04-23 14:33:08 +00:00
show_style1_active_index: 0,
};
},
2023-10-11 08:07:02 +00:00
props: {
propCurrencySymbol: {
type: String,
2023-12-04 08:05:31 +00:00
default: app.globalData.currency_symbol(),
},
2023-10-11 08:07:02 +00:00
propData: {
2023-10-30 05:49:55 +00:00
type: Object,
default: () => {
return {};
},
2023-10-11 08:07:02 +00:00
},
propVertical: {
type: Boolean,
default: true,
},
propDuration: {
type: Number,
default: 1000,
},
2024-04-23 14:33:08 +00:00
// 标签数据
propLabel: {
type: [Array, Object, String],
default: null,
}
},
components: {
componentGoodsList
2023-10-11 08:07:02 +00:00
},
// 属性值改变监听
watch: {
// 数据
propData(value, old_value) {
this.set_data(value);
}
2023-10-11 08:07:02 +00:00
},
mounted() {
this.set_data(this.propData);
},
methods: {
// 商品事件
goods_event(e) {
// 商品数据缓存处理
var index = e.currentTarget.dataset.index;
var indexs = e.currentTarget.dataset.indexs;
var indexss = e.currentTarget.dataset.indexss;
var gi = e.currentTarget.dataset.gi;
var goods = this.data_goods_list[index]['data'][indexs]['data'][indexss][gi];
app.globalData.goods_data_cache_handle(goods.id, goods);
// 调用公共打开url地址
app.globalData.url_event(e);
},
2023-10-30 05:49:55 +00:00
// url事件
url_event(e) {
app.globalData.url_event(e);
2023-10-11 08:07:02 +00:00
},
2024-04-23 14:33:08 +00:00
// tabs切换
switch_tabs_event(e) {
this.setData({
show_style1_active_index: e.currentTarget.dataset.indexs
});
},
2023-10-11 08:07:02 +00:00
// 轮播数据处理
set_data(data) {
2023-10-30 05:49:55 +00:00
let goods = data.goods;
goods.forEach((item) => {
2024-04-23 14:33:08 +00:00
switch(parseInt(item.show_style || 0)) {
// 上下滚动数据处理
case 0 :
item.data.forEach((items, indexs) => {
let swiper_data = [];
if (item.data.length % 2 == 0) {
// 偶数
swiper_data = app.globalData.group_arry(items.goods_list, 2);
} else {
// 奇数
if (item.data.length === indexs + 1) {
swiper_data = app.globalData.group_arry(items.goods_list, 4);
} else {
swiper_data = app.globalData.group_arry(items.goods_list, 2);
}
}
items.data = swiper_data;
});
break;
}
2023-10-30 05:49:55 +00:00
});
this.setData({
2023-10-30 10:01:05 +00:00
data_goods_list: goods,
2023-10-11 08:07:02 +00:00
});
},
},
};
2023-09-05 09:38:15 +00:00
</script>
<style scoped>
2024-04-23 16:52:22 +00:00
.plugins-magic-content .hot-list {
2024-04-23 14:33:08 +00:00
gap: 10rpx 0;
}
2024-04-23 16:52:22 +00:00
.plugins-magic-content .hot-list > .flex-width-half {
2023-11-02 11:04:53 +00:00
margin-bottom: 0;
2023-11-02 10:46:28 +00:00
}
2024-04-23 16:52:22 +00:00
.plugins-magic-content .hot-list > .flex-width-half:nth-last-of-type(1),
.plugins-magic-content .hot-list > .flex-width-half:nth-last-of-type(2) {
2023-11-02 10:46:28 +00:00
margin-bottom: 0;
}
2024-04-23 16:52:22 +00:00
.plugins-magic-content .hot-list > .flex-width-half:nth-child(even) {
2023-11-02 10:46:28 +00:00
position: relative;
}
2024-04-23 16:52:22 +00:00
.plugins-magic-content .hot-list > .flex-width-half:nth-child(even)::before {
2023-11-02 10:46:28 +00:00
content: '';
height: 80%;
width: 2rpx;
2024-04-23 16:52:22 +00:00
border-left: 2rpx dashed #f5f5f5;
2023-11-02 10:46:28 +00:00
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
}
2024-04-23 16:52:22 +00:00
.plugins-magic-content .hot-list .swiper-2 {
2023-11-02 11:04:53 +00:00
height: 176rpx;
2023-10-11 09:52:24 +00:00
}
2024-04-23 16:52:22 +00:00
.plugins-magic-content .hot-list .swiper-2 .swiper-img {
height: 124rpx;
}
2024-04-23 16:52:22 +00:00
.plugins-magic-content .hot-list .swiper-1 {
2023-11-02 11:04:53 +00:00
height: 187rpx;
2023-10-11 08:07:02 +00:00
}
2024-04-23 16:52:22 +00:00
.plugins-magic-content .hot-list .swiper-1 .swiper-img {
height: 135rpx;
}
2024-04-23 16:52:22 +00:00
.plugins-magic-content .hot-go {
2023-10-30 05:49:55 +00:00
height: 34rpx;
line-height: 34rpx;
2023-10-11 08:07:02 +00:00
}
2024-04-23 16:52:22 +00:00
.plugins-magic-content .flex-width-half-2 {
2023-10-30 07:09:56 +00:00
width: 25%;
}
2024-04-23 14:33:08 +00:00
/**
* 切换滚动切换九宫格切换滚动
*/
2024-04-23 16:52:22 +00:00
.plugins-magic-content .switch-tabs-item-list > .scroll-view-horizontal {
2024-04-23 14:33:08 +00:00
padding-right: 140rpx;
}
2024-04-23 16:52:22 +00:00
.plugins-magic-content .switch-tabs-item-list .switch-tabs-item-icon {
2024-04-23 14:33:08 +00:00
width: 32rpx !important;
height: 32rpx !important;
}
2023-10-11 08:07:02 +00:00
</style>