| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788 |
- <template>
- <!-- 促销列表 -->
- <view v-show="!isSortType">
- <common-wrapper :config="configData">
- <view class="index-product-wrapper">
- <view :style="{ height: navBdH + 'px' }" class="nav-bd-box">
- <view
- class="nav-bd"
- :class="{
- 'nav-bd2': dataConfig.styleConfig.tabVal == 1,
- 'nav-bd3': dataConfig.styleConfig.tabVal == 2,
- 'nav-bd4': dataConfig.styleConfig.tabVal == 3,
- 'nav-bd5': dataConfig.styleConfig.tabVal == 4,
- }"
- :style="{
- position: sticky ? 'fixed' : 'static',
- top: positionTop + 'px',
- background: sticky ? '#FFFFFF' : 'none',
- }"
- >
- <scroll-view class="scroll-view" scroll-x="true">
- <view
- class="item"
- v-for="(item, index) in explosiveMoney"
- :key="index"
- :class="{ on: index == ProductNavindex }"
- @click="ProductNavTab(item, index)"
- >
- <view
- v-if="dataConfig.styleConfig.tabVal == 4"
- class="image-wrap"
- >
- <image :src="item.image" class="image"></image>
- </view>
- <view
- class="txt"
- :style="[index == ProductNavindex ? textColor : {}]"
- >{{ item.chiild[0].val }}</view
- >
- <view
- v-if="[1, 2].includes(dataConfig.styleConfig.tabVal)"
- class="line"
- :style="[index == ProductNavindex ? lineColor : {}]"
- ></view>
- <view
- class="label"
- v-if="
- dataConfig.styleConfig.tabVal == 0 && item.chiild[1].val
- "
- :style="[index == ProductNavindex ? decorateColor : {}]"
- >
- {{ item.chiild[1].val }}
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- <goodList
- ref="goodLists"
- v-if="goodDataConfig"
- :dataConfig="goodDataConfig"
- @detail="goDetail"
- ></goodList>
- </view>
- </common-wrapper>
- </view>
- </template>
- <script>
- import commonWrapper from "./commonWrapper.vue";
- // import {
- // getProductslist
- // } from '@/api/store.js';
- import goodList from "./goodList.vue";
- export default {
- name: "promotionList",
- props: {
- dataConfig: {
- type: Object,
- default: () => {},
- },
- isSortType: {
- type: String | Number,
- default: 0,
- },
- productVideoStatus: {
- type: Boolean,
- default: false,
- },
- positionTop: {
- type: Number,
- default: 0,
- },
- },
- components: {
- goodList,
- commonWrapper
- },
- data() {
- return {
- tempArr: [],
- iSshowH: false,
- ProductNavindex: 0,
- explosiveMoney: this.dataConfig.tabConfig.list,
- numConfig: this.dataConfig.tabConfig.list[0].numConfig.val,
- // imgStyle: this.dataConfig.imgStyle.type,
- mbConfig: 0,
- themeColor: "",
- titleShow: 0, //标题是否显示
- opriceShow: 0, //划线价是否显示
- priceShow: 0, //价格是否显示
- couponShow: 0, //优惠券标签是否显示
- titleConfig: 0, //标题位置
- fontColor: "",
- labelColor: "",
- txtColor: "",
- infoColor: "",
- goodType: this.dataConfig.tabConfig.list[0].tabVal,
- loadend: false,
- loading: false,
- limit: this.$config.LIMIT,
- page: 1,
- canPlay: false,
- autoplay: false,
- activeValue: this.dataConfig.tabConfig.list[0],
- goodDataConfig: null,
- sticky: false,
- navBdH: 0,
- };
- },
- computed: {
- configData() {
- return {
- ...this.dataConfig,
- paddingConfig: this.dataConfig.paddingConfig || {
- isAll: false,
- valList: [
- {
- val: this.dataConfig.topConfig
- ? this.dataConfig.topConfig.val
- : 0,
- },
- {
- val: this.dataConfig.prConfig ? this.dataConfig.prConfig.val : 0,
- },
- {
- val: this.dataConfig.bottomConfig
- ? this.dataConfig.bottomConfig.val
- : 0,
- },
- {
- val: this.dataConfig.prConfig ? this.dataConfig.prConfig.val : 0,
- },
- ],
- },
- marginConfig: this.dataConfig.marginConfig || {
- isAll: false,
- valList: [
- {
- val: this.dataConfig.mbConfig ? this.dataConfig.mbConfig.val : 0,
- },
- {
- val: 0,
- },
- {
- val: 0,
- },
- {
- val: 0,
- },
- ],
- },
- };
- },
- decorateColor() {
- if (this.dataConfig.toneConfig.tabVal) {
- let color = this.dataConfig.decorateColor.color;
- let background = `linear-gradient(90deg, ${color[0].item} 0%, ${color[1].item} 100%)`;
- if (this.dataConfig.styleConfig.tabVal == 2) {
- color = this.dataConfig.decorateColor2.color;
- background = color[0].item;
- }
- return {
- background: background,
- };
- } else {
- return {
- background: `linear-gradient(90deg, var(--view-gradient) 0%, var(--view-theme) 100%)`,
- };
- }
- },
- textColor() {
- if (this.dataConfig.toneConfig.tabVal) {
- let color = this.dataConfig.textColor.color[0].item;
- let bgColor = this.dataConfig.decorateColor.color;
- let background = "";
- if ([0, 1, 2].includes(this.dataConfig.styleConfig.tabVal)) {
- color = this.dataConfig.textColor.color[0].item;
- } else if ([3, 4].includes(this.dataConfig.styleConfig.tabVal)) {
- color = "#ffffff";
- background = `linear-gradient(90deg, ${bgColor[0].item} 0%, ${bgColor[1].item} 100%)`;
- } else if (this.dataConfig.styleConfig.tabVal == 1) {
- color = "#282828";
- }
- return {
- color: color,
- background: background,
- };
- } else {
- if (this.dataConfig.styleConfig.tabVal == 1) {
- return {
- color: "#282828",
- };
- } else if ([3, 4].includes(this.dataConfig.styleConfig.tabVal)) {
- return {
- background:
- "linear-gradient(90deg, var(--view-gradient) 0, var(--view-theme) 100%)",
- color: "#ffffff",
- };
- } else {
- return {
- color: "var(--view-theme)",
- };
- }
- }
- },
- // bottomBgColor() {
- // return {
- // padding: `${this.dataConfig.topConfig.val * 2}rpx ${this.dataConfig.prConfig.val * 2}rpx ${this.dataConfig.bottomConfig.val * 2}rpx`,
- // 'margin-top': `${this.dataConfig.mbConfig.val * 2}rpx`,
- // background: this.dataConfig.bottomBgColor.color[0].item
- // };
- // },
- lineColor() {
- let diy = this.dataConfig.toneConfig.tabVal;
- let type = this.dataConfig.styleConfig.tabVal;
- let color = this.dataConfig.decorateColor.color;
- let bgColor = `linear-gradient(90deg, ${color[0].item} 0%, ${color[1].item} 100%)`;
- if (type == 1) {
- return {
- background: diy
- ? bgColor
- : "linear-gradient(90deg, var(--view-gradient) 0, var(--view-theme) 100%)",
- };
- } else if (type == 2) {
- return {
- "border-bottom-color": diy
- ? this.dataConfig.textColor2.color[0].item
- : "var(--view-theme)",
- };
- }
- },
- },
- watch: {
- activeValue: {
- handler(value) {
- let that = this;
- let type = that.goodType == 0 ? 3 : that.goodType;
- let goodDataConfig = {
- styleConfig: {
- tabVal: 1,
- },
- goodsList: this.activeValue.goodsList,
- brandList: this.activeValue.brandConfig,
- classList: {
- classVal: this.activeValue.selectConfig.activeValue,
- },
- goodsLabel: this.activeValue.goodsLabel,
- typeConfig: {
- activeValue: type,
- },
- goodsSort: {
- tabVal: this.activeValue.goodsSort,
- },
- numberConfig: {
- val: that.numConfig,
- },
- bntStyleConfig: this.dataConfig.bntStyleConfig,
- cartConfig: this.dataConfig.cartConfig,
- bntConfig: this.dataConfig.bntConfig,
- filletImg: {
- type: 0,
- val: 8,
- },
- checkboxInfo: {
- type: [0, 1, 2, 3, 4, 5],
- },
- toneConfig: {
- tabVal: 0,
- },
- toneCartConfig: this.dataConfig.toneCartConfig,
- bntBgColor: this.dataConfig.bntBgColor,
- goodsName: {
- tabVal: 1,
- },
- goodsNameColor: {
- color: [
- {
- item: "#333333",
- },
- ],
- },
- goodsPriceColor: {
- color: [
- {
- item: this.dataConfig.toneCartConfig.tabVal
- ? this.dataConfig.goodsPriceColor.color[0].item
- : "var(--view-theme)",
- },
- ],
- },
- topConfig: {
- val: 0,
- },
- prConfig: {
- val: 0,
- },
- bottomConfig: {
- val: 0,
- },
- mbConfig: {
- val: 0,
- },
- bottomBgColor: {
- color: [
- {
- item: "",
- },
- ],
- },
- fillet: this.dataConfig.fillet,
- name: "promotionList",
- };
- that.goodDataConfig = goodDataConfig;
- },
- immediate: true,
- },
- goodType: {
- handler(value) {
- //value !== undefined && this.getGroomList();
- },
- immediate: true,
- },
- tempArr() {
- // #ifndef APP-PLUS
- this.$nextTick(() => {
- if (this.productVideoStatus) {
- uni.getNetworkType({
- success: (res) => {
- if (["wifi", "unknown"].includes(res.networkType)) {
- // 监听
- this.observeVideo();
- }
- if (["2g", "3g", "4g", "5g"].includes(res.networkType)) {
- if (this.$store.state.app.autoplay) {
- // 监听
- this.observeVideo();
- } else {
- this.$eventHub.$emit("confirm_video_status");
- }
- }
- },
- });
- }
- });
- // #endif
- },
- },
- created() {
- // #ifndef APP-PLUS
- this.$eventHub.$on("product_video_observe", () => {
- this.observeVideo();
- });
- // #endif
- // this.getGroomList();
- let that = this;
- let type = that.goodType == 0 ? 3 : that.goodType;
- let goodDataConfig = {
- styleConfig: {
- tabVal: 1,
- },
- goodsList: this.activeValue.goodsList,
- brandList: this.activeValue.brandConfig,
- classList: {
- classVal: this.activeValue.selectConfig.activeValue,
- },
- goodsLabel: this.activeValue.goodsLabel,
- typeConfig: {
- activeValue: type,
- },
- goodsSort: {
- tabVal: this.activeValue.goodsSort,
- },
- numberConfig: {
- val: that.numConfig,
- },
- bntStyleConfig: this.dataConfig.bntStyleConfig,
- cartConfig: this.dataConfig.cartConfig,
- bntConfig: this.dataConfig.bntConfig,
- filletImg: {
- type: 0,
- val: 8,
- },
- checkboxInfo: {
- type: [0, 1, 2, 3, 4, 5],
- },
- toneConfig: {
- tabVal: 0,
- },
- toneCartConfig: this.dataConfig.toneCartConfig,
- bntBgColor: this.dataConfig.bntBgColor,
- goodsName: {
- tabVal: 1,
- },
- goodsNameColor: {
- color: [
- {
- item: "#333333",
- },
- ],
- },
- goodsPriceColor: {
- color: [
- {
- item: this.dataConfig.toneCartConfig.tabVal
- ? this.dataConfig.goodsPriceColor.color[0].item
- : "var(--view-theme)",
- },
- ],
- },
- topConfig: {
- val: 0,
- },
- prConfig: {
- val: 0,
- },
- bottomConfig: {
- val: 0,
- },
- mbConfig: {
- val: 0,
- },
- bottomBgColor: {
- color: [
- {
- item: "",
- },
- ],
- },
- fillet: this.dataConfig.fillet,
- name: "promotionList",
- };
- that.goodDataConfig = goodDataConfig;
- },
- mounted() {
- let view = uni.createSelectorQuery().in(this).select(".nav-bd");
- let views = uni.createSelectorQuery().in(this).select(".nav-bd-box");
- view
- .boundingClientRect((data) => {
- this.navBdH = data.height;
- })
- .exec();
- if (!this.dataConfig.slideConfig.tabVal) {
- uni.$on("onPageScroll", () => {
- views
- .boundingClientRect((data) => {
- this.sticky = data.top <= this.positionTop;
- })
- .exec();
- });
- }
- },
- methods: {
- observeVideo() {
- this.autoplay = true;
- // let observer = uni.createIntersectionObserver(this, { observeAll: true });
- // observer.relativeToViewport().observe('.video', res => {
- // if (res.intersectionRatio) {
- // uni.createVideoContext(res.id, this).play();
- // } else{
- // uni.createVideoContext(res.id, this).pause();
- // }
- // });
- },
- // 促销列表的点击事件;
- changeTab(item) {
- this.goodType = item.tabVal;
- this.activeValue = item;
- // this.tempArr = [];
- // this.page = 1;
- // this.loadend = false;
- // let onloadH = true;
- // this.getGroomList(onloadH);
- },
- // 精品推荐
- getGroomList(onloadH) {
- let that = this;
- let type = that.goodType == 0 ? 3 : that.goodType;
- if (that.loadend) return false;
- if (that.loading) return false;
- if (onloadH) {
- that.$set(that, "iSshowH", true);
- }
- let datas = {
- page: that.page,
- limit: this.numConfig,
- };
- if (type == 1) {
- datas.ids = that.activeValue.goodsList.ids.join();
- } else if (type == 2) {
- datas.brand_id = that.activeValue.brandConfig.brandVal.join();
- } else if (type == 3) {
- datas.cate_id = that.activeValue.selectConfig.activeValue.join();
- } else if (type == 4) {
- datas.store_label_id = that.activeValue.goodsLabel.activeValue.join();
- }
- getProductslist(datas)
- .then(({ data }) => {
- that.$set(that, "iSshowH", false);
- let maxPage = Math.ceil(this.numConfig / this.limit);
- let list = data,
- loadend = list.length < that.limit || that.page >= maxPage;
- let tempArr = that.$util.SplitArray(list, that.tempArr);
- that.$set(that, "tempArr", tempArr.slice(0, this.numConfig));
- that.loadend = loadend;
- that.loadTitle = loadend ? "没有更多内容啦~" : "加载更多";
- that.page = that.page + 1;
- that.loading = false;
- })
- .catch((res) => {
- that.loading = false;
- that.loadTitle = "加载更多";
- });
- },
- // 首发新品切换
- ProductNavTab(item, index) {
- this.ProductNavindex = index;
- this.changeTab(item);
- },
- goDetail(item) {
- this.$emit("detail", item);
- },
- },
- };
- </script>
- <style lang="scss">
- // 这里可以自行配置
- $border-radius: 10px;
- .index-product-wrapper {
- &.on {
- min-height: 1500rpx;
- }
- .nav-bd {
- position: relative;
- top: 0;
- right: 0;
- left: 0;
- z-index: 99;
- &.nav-bd2 {
- .item {
- position: relative;
- padding: 18rpx 0;
- margin-right: 56rpx;
- &:first-child {
- // margin-left: 24rpx;
- }
- &:last-child {
- margin-right: 24rpx;
- }
- &.on {
- .txt {
- font-weight: 500;
- font-size: 32rpx;
- color: #333333;
- }
- // .line {
- // background: linear-gradient(90deg, var(--view-gradient) 0, var(--view-theme) 100%);
- // }
- }
- .txt {
- position: relative;
- z-index: 1;
- font-size: 28rpx;
- line-height: 44rpx;
- }
- .line {
- position: absolute;
- bottom: 22rpx;
- left: 0;
- width: 100%;
- height: 8rpx;
- border-radius: 4rpx;
- }
- }
- }
- &.nav-bd3 {
- .item {
- position: relative;
- padding: 18rpx 0;
- margin-right: 56rpx;
- &:first-child {
- // margin-left: 24rpx;
- }
- &:last-child {
- margin-right: 24rpx;
- }
- &.on {
- .txt {
- font-weight: 500;
- font-size: 32rpx;
- color: #e93323;
- }
- // .line {
- // border-bottom-color: var(--view-theme);
- // }
- }
- .txt {
- font-size: 28rpx;
- line-height: 44rpx;
- }
- .line {
- position: absolute;
- bottom: 8rpx;
- left: 50%;
- width: 64rpx;
- height: 64rpx;
- border: 4rpx solid transparent;
- border-radius: 50%;
- transform: translateX(-50%);
- }
- }
- }
- &.nav-bd4 {
- .item {
- padding: 16rpx 0;
- margin-right: 16rpx;
- &:first-child {
- // margin-left: 20rpx;
- }
- &:last-child {
- margin-right: 20rpx;
- }
- &.on {
- .txt {
- background: linear-gradient(90deg, #ff7931 0%, #e93323 100%);
- font-size: 26rpx;
- color: #ffffff;
- }
- }
- .txt {
- height: 48rpx;
- padding: 0 20rpx;
- border-radius: 24rpx;
- font-size: 28rpx;
- line-height: 48rpx;
- }
- }
- }
- &.nav-bd5 {
- padding-left: 20rpx;
- .item {
- padding: 20rpx 0;
- margin-right: 16rpx;
- &:first-child {
- // margin-left: 24rpx;
- }
- &:last-child {
- margin-right: 24rpx;
- }
- &.on {
- .image-wrap {
- border-color: var(--view-theme);
- background: #ffffff;
- }
- .txt {
- // background: linear-gradient(90deg, #FF7931 0%, #E93323 100%);
- color: #ffffff;
- }
- }
- .image-wrap {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 104rpx;
- height: 104rpx;
- border: 3rpx solid transparent;
- border-radius: 50%;
- margin: 0 auto;
- }
- .image {
- width: 92rpx;
- height: 92rpx;
- border: 1rpx solid #eeeeee;
- border-radius: 50%;
- }
- .txt {
- height: 40rpx;
- padding: 0 12rpx;
- border-radius: 20rpx;
- margin-top: 8rpx;
- font-size: 24rpx;
- line-height: 40rpx;
- color: #333333;
- }
- }
- }
- .scroll-view {
- white-space: nowrap;
- }
- .item {
- display: inline-block;
- padding: 20rpx 0 14rpx;
- margin-right: 66rpx;
- text-align: center;
- &:first-child {
- // margin-left: 36rpx;
- }
- &:last-child {
- margin-right: 36rpx;
- }
- &.on {
- .txt {
- font-weight: 500;
- color: #e93323;
- }
- .label {
- background: linear-gradient(90deg, #ff7931 0%, #e93323 100%);
- font-size: 22rpx;
- color: #ffffff;
- }
- }
- .txt {
- font-size: 30rpx;
- line-height: 42rpx;
- color: #282828;
- }
- .label {
- display: inline-block;
- height: 38rpx;
- padding: 0 12rpx;
- border-radius: 19rpx;
- margin-top: 6rpx;
- font-size: 24rpx;
- line-height: 38rpx;
- color: #999999;
- }
- }
- }
- }
- </style>
|