optimizationList.vue 10.9 KB
<template>
    <div class="optimization-list-page">

        <!-- H5唤起App组件 -->
        <call-app-box class="call-app-box" ref="callApp" v-if="!isCNLive.value"
            :callApps="$parent.callApps">
        </call-app-box>

        <!-- 后退导航 -->
        <back-box class="back-box" :class="{'hide': $route.query.hideBack == true}" :style="'padding-top: ' + $parent.top.value + 'px'" v-if="isCNLive.value" @back="back"
            :backs="backs">
        </back-box>

        <!-- pl -->
        <div class="pl" :class="{'is-cnlive': isCNLive.value, 'is-open-app': $parent.isOpenApp.value, 'hide': $route.query.hideBack == true}"></div>

        <!-- 主区域 -->
        <div class="main-box">

            <!-- 区块 -->
            <div class="section red-box" :style="{backgroundImage: 'url(' + redBox.bg + ')'}" v-if="redBox">

                <!-- 主区域 -->
                <div class="content-box">

                    <!-- 视频区块 -->
                    <div class="video-box" v-if="redBox.video">
                        <video class="video" controls :poster="redBox.video.poster + SIGN.BIG">
                            <source :src="redBox.video.url" type="video/mp4" />
                        </video>
                    </div>

                    <!-- 列表区块 -->
                    <div class="list-box" v-if="redBox.list">
                        <div class="item" v-for="(item, index) in redBox.list" :key="index" @click="toDetail(item)">
                            <img :src="item.img + SIGN.BIG" class="list-img" />
                        </div>
                    </div>
                </div>
            </div>

            <!-- 区块 -->
            <div class="section blue-box" :style="{backgroundImage: 'url(' + blueBox.bg + ')'}" v-if="blueBox">

                <!-- 主区域 -->
                <div class="content-box">

                    <!-- 视频区块 -->
                    <div class="video-box" v-if="blueBox.video">
                        <video class="video" controls :poster="blueBox.video.poster + SIGN.BIG">
                            <source :src="blueBox.video.url" type="video/mp4" />
                        </video>
                    </div>

                    <!-- 列表区块 -->
                    <div class="list-box" v-if="blueBox.list">
                        <div class="item" v-for="(item, index) in blueBox.list" :key="index" @click="toDetail(item)">
                            <img :src="item.img + SIGN.BIG" class="list-img" />
                        </div>
                    </div>
                </div>
            </div>

            <!-- 区块 -->
            <div class="section green-box" :style="{backgroundImage: 'url(' + greenBox.bg + ')'}" v-if="greenBox">

                <!-- 主区域 -->
                <div class="content-box">

                    <!-- 视频区块 -->
                    <div class="video-box" v-if="greenBox.video">
                        <video class="video" controls :poster="greenBox.video.poster + SIGN.BIG">
                            <source :src="greenBox.video.url" type="video/mp4" />
                        </video>
                    </div>

                    <!-- 列表区块 -->
                    <div class="list-box" v-if="greenBox.list">
                        <div class="item" v-for="(item, index) in greenBox.list" :key="index" @click="toDetail(item)">
                            <img :src="item.img + SIGN.BIG" class="list-img" />
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- 回到顶部按钮 -->
        <goto-top
            :top="parseInt(150)">
        </goto-top>
    </div>
</template>

<script>

    // 引入组件
    import { Toast, Indicator } from "mint-ui";
    import callAppBox from "@/components/callAppBox/callAppBox";
    import backBox from "@/components/backBox/backBox";
    import gotoTop from "@/components/gotoTop/gotoTop";

    export default {
        name: 'optimizationListPage',
        data () {
            return {
                title: "",          // 标题
                backs: null,        // 后退按钮组
                redBox: null,       // 红色区块
                blueBox: null,      // 蓝色区块
                greenBox: null,     // 绿色区块

                


            }
        },
        components: {
            callAppBox,
            backBox,
            gotoTop
        },
        created() {

            // 设置标题
            this.$set(this, "title", "品质优选");

            // 判断是否在App内
            if (this.isCNLive.value) {

                // 添加后退按钮组“后退”和“分享”按钮
                this.$set(this, 'backs', {
                    funcs: {
                        back: {
                            icon: "static/img/icon_back.png"
                        },
                        funcArray: [
                            {
                                icon: "static/img/icon_share.png",
                                func: this.toShare
                            }
                        ]
                    }
                });

                // 设置标题
                this.$set(this.backs, 'title', '品质优选');
            }



            // 优选页面接口
            // this.fansShopMessageList();




            // 临时,设置各区块头部图片地址
            this.$set(this, 'redBox', {
                bg: 'static/img/o_bg_01.png',
                video: {
                    poster: 'static/img/o_01_video.png'
                },
                list: [
                    {
                        img: 'static/img/o_01_01.png'
                    },
                    {
                        img: 'static/img/o_01_02.png'
                    }
                ]
            });
            this.$set(this, 'blueBox', {
                bg: 'static/img/o_bg_02.png',
                video: {
                    poster: 'static/img/o_02_video.png'
                },
                list: [
                    {
                        img: 'static/img/o_02_01.png'
                    },
                    {
                        img: 'static/img/o_02_02.png'
                    }
                ]
            });
            this.$set(this, 'greenBox', {
                bg: 'static/img/o_bg_03.png',
                list: [
                    {
                        img: 'static/img/o_03_01.png'
                    },
                    {
                        img: 'static/img/o_03_02.png'
                    }
                ]
            });




        },
        methods: {

            /**
             * 优选页面接口
             */
            fansShopMessageList() {

                // 校验登录
                if (this.$parent.checkLogin()) {

                    // 加载中提示
                    Indicator.open("加载中...");

                    // 获取证书请求接口
                    this.http("/Api/" + this.getApiVersion().dynamic + "/fansShopMessageList", {
                        uid: this.getStore("uid")
                    }, this.fansShopMessageListCallback, {
                        method: "POST"
                    });
                }
            },

            /**
             * 优选页面接口回调
             * @param {Object} res [服务器返回数据]
             * @param {Object} ext [扩展参数]
             */
            fansShopMessageListCallback(res, ext) {

                // 加载完成
                Indicator.close();

                // 返回处理
                if (res.code == 200) {

                    // 解构数据
                    let { data: datas } = res;

                    /* 获取优选库“优选”数据 开始 */

                    

                    /* 获取优选库“优选”数据 结束 */

                } else if (res.code == 400) {

                    // 获取优选失败
                    Toast(res.message);
                } else {

                    // 获取优选失败
                    Toast("获取优选失败");
                }
            },

            /**
             * 跳转商品详情
             * @param {Object} item [数据对象]
             */
            toDetail(item) {

                // 判断通用跳转函数是否存在
                if (typeof this.$parent.gotoDetail === 'function') {


                    console.log('toDetail', item);


                    // 通用跳转
                    this.$parent.gotoDetail(item);
                }
            },
            
            /**
             * 列表附件按钮事件
             * @param {Object} item [数据对象]
             */
            primary(item) {
                this.toDetail(item);
            },







            /**
             * 分享
             */
            toShare() {

                // 判断分享
                if (typeof this.$parent.toShare === 'function') {
                    this.$parent.toShare(38, this.$route.query.id || 0);
                }
            },

            /**
             * 后退
             */
            back() {
                
                // 判断是否有处理函数
                if (typeof this.$parent.back === 'function') {

                    // 后退
                    this.$parent.back();
                } else {

                    // 后退
                    window.history.go(-1);
                }
            }
        },
        head: {
            title () {
                return {
                    inner: this.title
                }
            }
        },
        watch: {

            // 设置页面标题
            title(newVal) {
                if (this.$store.state.browser.toLowerCase() == "qq" && this.$store.state.deviceType.toLowerCase() == "iphone") {
                    this.$iFrame.insertIFrame(newVal);
                } else {
                    this.$emit("updateHead");
                }
            }
        },
        mounted() {
            
            // 如果是App外,设置唤起App和微信内分享参数
            if (!this.isCNLive.value) {

                // 唤起详情页
                if (typeof this.$parent.getOpenApp === "function") {
                    this.$parent.getOpenApp({
                        type: 38,
                        id: this.$route.query.id || 1,
                        url: ""
                    });
                }
    
                // 分享详情页
                if (typeof this.$parent.getShareData === "function") {
                    this.$parent.getShareData({
                        type: 38,
                        id: this.$route.query.id || 1,
                        url: ""
                    });
                }
            }
        }
    }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style rel="stylesheet/less" lang='less' scoped>
    @import "optimizationList";
</style>