search.vue 12.5 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
<template>
    <div class="search-box">
            
            <!-- nav -->
            <div class="nav" :style="'padding-top: ' + ($parent.top.value) + 'px'">

                <!-- 搜索组件 -->
                <search-com @cancel="doCancel"
                    :searchs="searchs">
                </search-com>
            </div>

            <!-- pl占位 -->
            <div class="pl" :style="'padding-top: ' + ($parent.top.value) + 'px'"></div>

            <!-- 搜索结果-商品 -->
            <list-com @jump="toDetail" @primary="toShop"
                :lists="commoditys">

                <!-- 标题 -->
                <text-title-box slot="title" @more="more"
                    :titles="{
                        title: '苹果-商品',
                        more: true,
                        style: '2'
                    }">
                </text-title-box>
            </list-com>

            <!-- 搜索结果-达人 -->
            <list-com @jump="toDarenProfile" @primary="fansShop"
                :lists="darenLists">

                <!-- 标题 -->
                <text-title-box slot="title" @more="more"
                    :titles="{
                        title: '苹果-达人',
                        more: true,
                        style: '2'
                    }">
                </text-title-box>
            </list-com>

            <!-- 搜索结果-美食 -->
            <list-com @jump="toFood"
                :lists="foodList">

                <!-- 标题 -->
                <text-title-box slot="title" @more="more"
                    :titles="{
                        title: '苹果-美食',
                        more: true,
                        style: '2'
                    }">
                </text-title-box>
            </list-com>





    </div>
</template>

<script>

    // 引入组件
    import { Toast, Indicator } from "mint-ui";
    import searchCom from "@/components/searchCom/searchCom";
    import textTitleBox from "@/components/textTitleBox/textTitleBox";
    import listCom from "@/components/listCom/listCom";





    export default {
        name: 'search',
        data () {
            return {
                title: "",
                searchs: {
                    backgroundColor: "#FAFBFD",
                    borderColor: "#FC1541"
                },
                commoditys: {
                    style: "4",
                    backgroundColor: "#FFFFFF",
                    list: [
                        {
                            simg: "static/img/9.png",
                            title: "覆盆子苹果礼盒套装",
                            price: "299.90"
                        },
                        {
                            simg: "static/img/9.png",
                            title: "覆盆子苹果礼盒套装",
                            price: "299.90"
                        },
                        {
                            simg: "static/img/9.png",
                            title: "覆盆子苹果礼盒套装",
                            price: "299.90"
                        }
                    ]
                },
                darenLists: {
                    style: "daren-list",
                    backgroundColor: "#FFFFFF",
                    list: [
                        {
                            user_img: "static/img/6.png",
                            title: "万能苹果",
                            fans: "222",
                            is_fans: "0"
                        },
                        {
                            user_img: "static/img/6.png",
                            title: "全球小苹果",
                            fans: "999",
                            is_fans: "0"
                        },
                        {
                            user_img: "static/img/6.png",
                            title: "健身小苹果",
                            fans: "222",
                            is_fans: "0"
                        },
                        {
                            user_img: "static/img/6.png",
                            title: "全球小苹果",
                            fans: "10",
                            is_fans: "1"
                        },
                        {
                            user_img: "static/img/6.png",
                            title: "健身小苹果",
                            fans: "1000",
                            is_fans: "1"
                        }
                    ]
                },
                foodList: {
                    style: "5",
                    backgroundColor: "#FFFFFF",
                    list: [
                        {
                            simg: "static/img/9.png",
                            title: "食色天香(外文大厦店)",
                            evaluate: "4.6",
                            count: "1234",
                            flag: "网家家城市推荐TOP 100",
                            distance: "456m"
                        },
                        {
                            simg: "static/img/9.png",
                            title: "食色天香(外文大厦店)",
                            evaluate: "4.6",
                            count: "1234",
                            flag: "网家家城市推荐TOP 100",
                            distance: "456km"
                        },
                        {
                            simg: "static/img/9.png",
                            title: "食色天香(外文大厦店)",
                            evaluate: "4.6",
                            count: "1234",
                            flag: "",
                            distance: "456m"
                        }
                    ]
                },







            }
        },
        components: {
            searchCom,
            textTitleBox,
            listCom,






        },
        created() {

            // 设置标题
            this.$set(this, "title", "搜索");
        },
        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();

                // 下拉刷新结束
                this.$set(this, "isLoading", false);

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

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

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

                    // 获取“达人列表数据”
                    if (datas.list && datas.list.length) {

                        // 设置“达人列表数据”数据
                        this.$set(this, "dresserList", datas.list);
                    }

                    // 获取“热销商品”
                    if (datas.hotGoods && datas.hotGoods.length) {

                        // 设置“热销商品”数据
                        this.$set(this, "hotGoods", datas.hotGoods);

                        // 判断“热销商品”更多
                        if (datas.hotGoodsMore) {

                            // 设置“热销商品”更多
                            this.$set(this, "hotGoodsMore", datas.hotGoodsMore);
                        }
                    }

                    // 获取“最新上架”
                    if (datas.newGoods && datas.newGoods.length) {

                        // 设置“最新上架”数据
                        this.$set(this, "newGoods", datas.newGoods);

                        // 判断“最新上架”更多
                        if (datas.newGoodsMore) {

                            // 设置“最新上架”更多
                            this.$set(this, "newGoodsMore", datas.newGoodsMore);
                        }
                    }

                    // 获取“最近购买”
                    if (datas.newBuyGoods && datas.newBuyGoods.length) {

                        // 设置“最近购买”数据
                        this.$set(this, "newBuyGoods", datas.newBuyGoods);
                    }

                    // 获取“猜你喜欢”
                    if (datas.recommendGoods && datas.recommendGoods.length) {

                        // 设置“猜你喜欢”数据
                        this.$set(this, "recommendGoods", datas.recommendGoods);
                    }

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

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

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

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

            /**
             * 更多
             * @param {object} item [数据对象]
             */
            more(item) {



                console.log("more", item);
                


                // 判断并调用通用跳转
                if (typeof this.$parent.gotoDetail === "function") {
                    this.$parent.gotoDetail(item);
                }
            },

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



                console.log("toDetail", item);
                



                // 判断并调用通用跳转
                if (typeof this.$parent.gotoDetail === "function") {

                    // 构造跳转详情页参数
                    let options = {
                        type: "2",
                        to: item.id,
                        shop_type: item.shop_type
                    }

                    this.$parent.gotoDetail(options);
                }
            },

            /**
             * 进入店铺
             * @param {object} item [数据对象]
             */
            toShop(item) {


                console.log("toShop", item);
                



            },

            /**
             * 进入达人个人主页
             * @param {object} item [数据对象]
             */
            toDarenProfile(item) {


                console.log("toDarenProfile", item);
                



            },

            /**
             * 关注/取消关注达人
             * @param {object} item [数据对象]
             */
            fansShop(item) {


                console.log("fansShop", item);
                



            },

            /**
             * 进入美食
             * @param {object} item [数据对象]
             */
            toFood(item) {


                console.log("toFood", item);
                



            },






            /**
             * 搜索框取消按钮,销毁WebView
             */
            doCancel() {

                // 判断destroy函数是否存在
                if (typeof this.$parent.destroy === "function") {
                    this.$parent.destroy();
                } 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");
                }
            }
        }
    }
</script>

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