pointsMall.vue 26.3 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 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844
<template>
  <div rel="pointsMall">
    <!-- H5唤起App组件 -->
    <call-app-box class="call-app-box"
                  :style="'padding-top: ' + $parent.top.value + 'px'"
                  ref="callApp"
                  v-if="!isCNLive.value"
                  :callApps="$parent.callApps">
    </call-app-box>
    <div class="main_box">
      <!-- pl -->
      <div class="pl"
           :style="'padding-top: ' + $parent.top.value + 'px'"
           :class="{'is-open-app': $parent.isOpenApp.value,'is-cnlive': isCNLive.value, 'hide': $route.query.hideBack == true}"></div>
      <div class="share_back-box"
           :style="'background-color: rgba(255, 233, 234,' + opacity + ')'">
        <back-box v-if="isCNLive.value"
                  :class="{'hide': $route.query.hideBack == true}"
                  :style="'padding-top: ' + $parent.top.value + 'px;'"
                  ref="navBox"
                  @back="back"
                  :backs="backs">
        </back-box>
        <!-- 分享下拉选择项 -->
        <van-popup class="popup_box"
                   v-model="showShareItems"
                   @click-overlay="onShowShareItems"
                   :overlay-style="{ top:(parseInt($parent.top.value) + 109)+ 'px' }"
                   :style="'top: ' + (parseInt($parent.top.value) + 76)+ 'px'">
          <share-item :class="{'hide': $route.query.hideBack == true}"
                      @back="back"
                      :backs="backs"
                      :shareItems="shareItems"></share-item>
        </van-popup>
      </div>
      <div class="top_main">
        <!-- 积分 -->
        <div class="left">
          <div class="title_t">我的积分</div>
          <div class="number">{{myGrade || 0}}</div>
        </div>
        <!-- 商品类型 -->
        <div class="item_box"
             v-if="navs && navs.length">
          <div class="item"
               v-for="(item, index) in navs"
               :key="index"
               @click="jumpApp(index+1)">
            <img :src="item.simg"
                 alt="" />
            <div class="text">{{item.title}}</div>
          </div>
        </div>
      </div>
      <!-- 为你推荐商品列表 -->
      <div class="list-box">
        <!-- 排行榜描述 -->
        <div class="ranking_desc"
             @click="jumpApp(4)">
          <div>品质优选 好物随心兑</div>
          <img src="static/img/pointsMall/right_icon2.png"
               alt="" />
        </div>
        <!-- 商品展示样式 2 -->
        <div class="ranking_box">
          <goods-item-2 class="item"
                        v-for="(item, index) in goodsLists"
                        :key="index"
                        @jump="toDetail"
                        :item="item"
                        pid="5">
            <!-- 添加flag -->
            <flag slot="flag"
                  v-if="flags && flags.icon && flags.icon[index]"
                  :flag="flags.icon[index]"
                  :position="flags.position"
                  :width="flags.width">
            </flag>
          </goods-item-2>
        </div>
      </div>

      <!-- 满减红包 -->
      <div v-if="redEnvelopeFull && redEnvelopeFull.list && redEnvelopeFull.list.length"
           ref="fullReductionBox">
        <div class="tab_item_box">
          <div class="item active">满减红包</div>
          <!-- 分割线 -->
          <div class="line"> </div>
          <div class="item">满减红包 精品推荐</div>
          <div @click="toMore(2)"
               class="more">更多<img src="static/img/icon_more_arrow_right.png"
                 class=""
                 alt="" /></div>
        </div>
        <div class="list-box2">
          <!-- 商品样式 7 列表 -->
          <goods-item-2 class="item"
                        v-if="parseInt(index)<3"
                        v-for="(item, index) in redEnvelopeFull.list"
                        :key="index"
                        @jump="toDetail"
                        :item="item"
                        pid="5">
          </goods-item-2>
        </div>
        <!-- <column-list-box class="column-list-box"  @jump="toDetail" 
                    :lists="redEnvelopeFull"
                    com="7" company="1">
                </column-list-box> -->
      </div>

      <!-- 实物商品 -->
      <div>
        <div class="tab_item_box">
          <div class="item active">好物兑换</div>
          <!-- 分割线 -->
          <div class="line"> </div>
          <div class="item">实物商品 分值浏览</div>
          <!-- <div @click="toMore(1)" class="more">更多<img src="static/img/icon_more_arrow_right.png" alt=""/></div> -->
        </div>
        <!-- 筛选按钮 -->
        <card-tabs :tags="tags"
                   :phyicalGoods="phyicalGoods"
                   @tabChange="tabChange"
                   @loadMore="loadMore"
                   @toDetail="toDetail">
        </card-tabs>
      </div>
    </div>
    <!-- 回到顶部按钮 -->
    <goto-top class="goto_top_box"
              :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 goodsItem2 from "@/components/goodsItem_2/goodsItem_2";
import columnListBox from "@/components/columnListBox/columnListBox";
import shareItem from "@/components/shareItem/shareItem";
import flag from "@/components/flag/flag";
import cardTabs from "@/components/cardTabs/cardTabs";
import gotoTop from "@/components/gotoTop/gotoTop";
export default {
  name: 'pointsmall',
  data () {
    return {
      opacity: 0,             // 透明度  
      title: "",              // 标题
      backs: null,            // 后退按钮组
      navs: null, // 导航
      myGrade: 0, // 我的积分
      goodsLists: null,  // 为你推荐商品
      phyicalGoods: [], // 实物商品
      tabIndex: 0,  // tab点击的位置
      virtualGoods: { list: null },   // 虚拟商品
      redEnvelopeFull: { list: null }, // 满减红包
      shareItems: null, // 分享下拉菜单
      showShareItems: false, // 非向下拉菜单显示隐藏
      flags: null,         // 产品排名flag
      tags: {
        list: null,
        value: null,
      }, // tabs数据
      refreshGrade: false, // 是否刷新积分
      version: this.$route.query.version, //长版本号(ios)
      ver: this.$route.query.version //短版本号(Android)
    }
  },
  //部件
  components: {
    callAppBox,
    backBox,
    goodsItem2,
    columnListBox,
    shareItem,
    flag,
    cardTabs,
    gotoTop
  },
  //静态
  props: [
  ],
  //对象内部的属性监听,也叫深度监听
  watch: {
  },
  //属性的结果会被缓存,除非依赖的响应式属性变化才会重新计算。主要当作属性来使用;
  computed: {
  },
  //方法表示一个具体的操作,主要书写业务逻辑;
  methods: {
    /**
  * tab切换筛选
  */
    tabChange (index) {
      if (this.isCNLive.value) {
        this.tabIndex = index;
        // 获取商品列表数据tab切换只获取一次数据
        if (!this.phyicalGoods[this.tabIndex].isCall) {
          this.getIntegralNewGoodsList(this.phyicalGoods[index].page);
        }
      } else {
        this.$parent.callApp();
      }
    },
    /**
    * 上拉加载
    */
    loadMore () {
      if (this.phyicalGoods[this.tabIndex].loading === false && this.phyicalGoods[this.tabIndex].isMore === false) {
        this.$set(this.phyicalGoods[this.tabIndex], "page", ++this.phyicalGoods[this.tabIndex].page);
        this.getIntegralNewGoodsList(this.phyicalGoods[this.tabIndex].page);
      }
    },
    /**
     * 加载积分商城商品更多
     * @param {int} page [页码]
     * @param  {int}type [类型1为实物 2为虚拟物品 3为红包]
     */
    getIntegralNewGoodsList (page) {
      // 加载中
      this.$set(this.phyicalGoods[this.tabIndex], "loading", true);

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

      // 请求接口
      this.http("/Api/" + (this.getApiVersion().LuckDraw) + "/integralNewGoodsList", {
        type: 1,
        // uid: this.getStore("uid"),
        page: page || 1,
        tags_value: this.tags.value // 筛选
      }, this.getIntegralNewGoodsListCallback, {
          method: "POST"
        });
    },

    /**
     * 礼品专区详情页回调
     * @param {object} res [服务器返回数据]
     * @param {object} ext [扩展参数]
     */
    getIntegralNewGoodsListCallback (res, ext) {

      // 加载完成
      // Indicator.close();
      // 证明调用过接口
      this.phyicalGoods[this.tabIndex].isCall = true;
      // 返回处理
      if (res.code == 200) {
        // 解构数据
        let { data: datas } = res;
        /*设置标题 */
        // this.$set(this, "title", datas.title);
        // this.$set(this.backs, 'title', datas.title);
        /* 获取商品数据 开始 */
        if (datas.goods && datas.goods.length) {
          // 设置列表
          this.$set(this.phyicalGoods[this.tabIndex], "list", [...this.phyicalGoods[this.tabIndex].list, ...datas.goods]);
          // 设置还有需要加载的内容
          this.$set(this.phyicalGoods[this.tabIndex], "loading", false);
        } else {
          this.phyicalGoods[this.tabIndex].isMore = true; // 没有更多了
          // 没有需要加载的内容,停止上拉加载
          this.$set(this.phyicalGoods[this.tabIndex], "loading", true);
        }
        /* 获取抽奖记录数据 结束 */
        // let item = {
        //         ref: 'physicalGoodsBox',
        //         simg: 'static/img/pointsMall/icon01.png',
        //         title: '赚积分'
        // }
        // let _this = this;
        // // 定位到好物兑换标题栏
        // this.$nextTick(() =>{
        //     _this.anchor(item);
        // })
      } else if (res.code == 400) {

        // 获取抽奖记录失败
        Toast(res.message);
      } else {

        // 获取抽奖记录失败
        Toast("获取专区礼包失败");
      }
    },
    /**
    * @param {Object} type [数据类型]
    * 1赚取积分2我的收藏3我的订单4兑换排行榜
     */
    jumpApp (type) {
      if (this.isCNLive.value) {
        if (type == 1) {
          this.jumpClientIntegralList();
        } else if (type == 2) {
          this.toExchangeOrder(1)
        } else if (type == 3) {
          this.toExchangeOrder(2);
        } else if (type == 4) {
          this.toExchangeOrder(3);
        }
      } else {
        this.$parent.callApp();
      }
    },
    /**
    * @param {Object} type [数据类型]
    * 1平台客服2分享好友3积分规则
     */
    jumpType (item) {
      if (this.$parent.checkLogin()) {
        this.showShareItems = false;
        if (item.params == 1) {
          let options;
          if (this.isAndroid.value) {
            if (this.ver != "") {
              var ver = this.ver ? this.ver.replace(/\.*/g, "") : "";
            }
            var isVer = 1910;
            if (ver > isVer) {
              // (判断app内是否有该方法)
              if (window.obj && window.obj.jumpCustomerService) {
                // 跳转到原生的客服页面
                window.obj.jumpCustomerService();
              }
            } else {
              // 提示用积分兑换兑换
              options = {
                message: "当前版本过旧,请升级最新版本",
                messageAlign: "center",
                confirmButtonText: "去更新",
                confirmButtonCallback: this.appUpdate,
                showCancelButton: true,
                cancelButtonText: "取消"
              };
            }
          } else if (this.isiPhone.value || this.isiPad.value) {
            if (this.version != "") {
              var version = this.version ? this.version.replace(/\.*/g, "") : "";
            }
            if (this.mode == "prod") {
              var isVer = 205;
            } else {
              var isVer = 205;
            }
            if (version > isVer) {
              // (判断app内是否有该方法)
              if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.jumpCustomerService) {
                // 跳转到原生的客服页面
                window.webkit.messageHandlers.jumpCustomerService.postMessage({ body: {} });
              }
            } else {
              // 提示用积分兑换兑换
              options = {
                message: "当前版本过旧,请升级最新版本",
                messageAlign: "center",
                confirmButtonText: "去更新",
                confirmButtonCallback: this.appUpdate,
                showCancelButton: true,
                cancelButtonText: "取消"
              };
            }
          }
          // 调用showModal层参数
          this.$set(this.$parent, "showOptions", options);
          // 显示通用浮层
          this.$parent.$refs.showModal.showLayer();
        } else if (item.params == 2) {
          // 判断分享
          if (typeof this.$parent.toShare === 'function') {
            this.$parent.toShare(45, "1", "");
          }
        } else if (item.params == 3) {
          // 通用跳转跳转到商品详情页新打开webview
          if (typeof this.$parent.gotoDetail === 'function') {
            // 设置跳转参数
            let params = {
              type: '34',
              to: 'http://wjjh5' + (this.mode == 'prod' ? '' : 'test') + '.cnlive.com/integralRules.html?type=web',
              shop_type: ''
            };
            // 页面跳转
            this.$parent.gotoDetail(params);
          }
        }
      }
    },
    // App升级跳转
    appUpdate () {
      if (this.isiPhone.value || this.isiPad.value) {
        window.location.href = "http://itunes.apple.com/cn/app/id1337575478?mt=8";
      } else if (this.isAndroid.value) {
        if (this.mode == "prod") {
          window.location.href = "http://wjj.vods1.cnlive.com/download/ac/1911/strike-1.9.1.1-release.apk";
        } else {
          window.location.href = "http://wjjtest.vods1.cnlive.com/download/debug_ac/1911/strike-1.9.1.1-debug.apk";
        }
      }
    },
    /**
     * 显示分享弹框
     */
    onShowShareItems () {
      this.showShareItems = !this.showShareItems;
    },
    /**
      * 锚点定位
      * @param {Object} item [数据对象]
      */
    anchor (item) {
      if (this.isCNLive.value) {
        // 判断锚点是否存在
        if (item.ref && typeof this.$refs === 'object' && typeof this.$refs[item.ref] === 'object') {

          // 根据头部设置锚点位置
          let safeDistance = 0;

          // 判断是否有callApp组件
          if (typeof this.$refs.callApp === 'object') {
            safeDistance += this.$refs.callApp.$el.clientHeight;
          }

          // 判断是否有backBox组件
          if (typeof this.$refs.backBox === 'object') {
            safeDistance += this.$refs.backBox.$el.clientHeight;
          }

          document.documentElement.scrollTop = document.body.scrollTop = this.$refs[item.ref].offsetTop - safeDistance - (20 * ((document.documentElement.clientWidth || document.body.clientWidth) / 750)) - (this.$parent.top.value + 60);
        }
      } else {
        this.$parent.callApp();
      }
    },
    /**
    * 跳转到兑换记录详情页
    * @param {Object} item [数据对象]
    * type 1我的收藏 2我的订单3兑换排行榜
    */
    toExchangeOrder (type) {
      if (this.isCNLive.value) {
        // 校验登录
        if (this.$parent.checkLogin()) {
          if (type == 1) {
            this.$router.push({
              path: '/pointsMyCollection',
              query: {
                uid: this.getStore("uid"),
                type: 3 // 1亲子嘉年华 2 康疫健步 3 积分商城 4 脐橙 7 健康商城
              }
            });
          } else if (type == 2) {
            this.$router.push({
              path: '/pointsExchangeRecords',
              query: {
                uid: this.getStore("uid"),
                type: 3 // 1亲子嘉年华 2 康疫健步 3 积分商城 4 脐橙 7 健康商城
              }
            });
          } else if (type == 3) {
            this.$router.push({
              path: '/exchangeRanking',
              query: {
                uid: this.getStore("uid")
              }
            });
          }
        }
      } else {
        this.$parent.callApp();
      }
    },
    /**
    * 跳转赚取积分页面
    * @param {Object} item [数据对象]
    */
    jumpClientIntegralList () {
      // 判断APP内
      if (this.isCNLive.value) {
        // 校验登录
        if (this.$parent.checkLogin()) {
          // (判断app内是否有该方法)
          if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers.jumpClientIntegralList) {
            // 跳转到原生的任务列表
            window.webkit.messageHandlers.jumpClientIntegralList.postMessage({ body: {} });
          } else if (window.obj && window.obj.jumpClientIntegralList) {
            // 跳转到原生的任务列表
            window.obj.jumpClientIntegralList();
          }
        }
      } else {
        this.$parent.callApp();
      }
    },
    /**
    * 跳转商品详情
    * @param {Object} item [数据对象]
    */
    toDetail (item) {
      if (this.isCNLive.value) {
        // 校验登录
        if (this.$parent.checkLogin()) {
          // 通用跳转跳转到商品详情页新打开webview
          if (typeof this.$parent.gotoDetail === 'function') {

            // 设置跳转参数
            let params = {
              type: '5',
              to: window.location.origin + '/html/select_good/1/#/goodDetails?goodsId=' + item.id,
              shop_type: ''
            };

            // 页面跳转
            this.$parent.gotoDetail(params);
          }
        }
      } else {
        this.$parent.callApp();
      }
    },
    /**
    * 跳转商品更多页
    * @param {Object} type [数据对象1实物品 2虚拟商品 3满减红包]
    */
    toMore (type) {
      if (this.isCNLive.value) {
        // this.$router.push({
        //   path: "/goodDetails",
        //   query: {
        //     goodsId: item.id,
        //     uid: this.getStore("uid")
        //   }
        // })
        // 通用跳转跳转到商品详情页新打开webview
        if (typeof this.$parent.gotoDetail === 'function') {

          // 设置跳转参数
          let params = {
            type: '5',
            to: window.location.origin + '/html/select_good/1/#/morePoints?type=' + type,
            shop_type: ''
          };

          // 页面跳转
          this.$parent.gotoDetail(params);
        }
      } else {
        this.$parent.callApp();
      }
    },
    /**
     * 后退
     */
    back () {

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

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

        // 后退
        window.history.go(-1);
      }
    },
    // 积分商场首页
    /**
     * 获取积分商场首页信息
     * * @param {string} uid [用户id]
     */
    integralMallIndex () {

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

      // 请求接口
      this.http("/Api/" + (this.getApiVersion().LuckDraw) + "/integralNewIndex", {
        uid: this.getStore("uid"),
        goods_id: this.$route.query.user_selected_goods_id || 0 // 记录从优选库那个商品点击进入进来的
      }, this.integralMallIndexCallback, {
          method: "POST"
        });
    },

    /**
     * 获取积分商场首页信息
     * @param {object} res [服务器返回数据]
     * @param {object} ext [扩展参数]
     */
    integralMallIndexCallback (res, ext) {

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

      // 返回处理
      if (res.code == 200) {
        // 解构数据
        let { data: datas } = res;
        this.info = datas
        /* 积分商场首页信息 开始 */
        if (this.refreshGrade == true) {
          /*用户信息 */
          this.$set(this, "myGrade", datas.grade);
        } else {
          /*用户信息 */
          this.$set(this, "myGrade", datas.grade);
          /*为你推荐 */
          this.$set(this, "goodsLists", datas.hot_goods);
          /*tabs数据 */
          this.$set(this.tags, "list", datas.tags);
          for (var i = 0; i <= this.tags.list.length; i++) {
            this.$set(this.phyicalGoods, i,
              {
                loading: true,
                distance: 50,
                page: 1,
                isCall: false, // 是否调用接口
                isMore: false,
                list: [],
              });
          }
          // 获取商品列表全部商品数据
          this.getIntegralNewGoodsList(this.phyicalGoods[0].page);
          /*满减红包商品 */
          this.$set(this.redEnvelopeFull, "list", datas.goods2);
          /*虚拟商品 */
          this.$set(this.virtualGoods, "list", datas.goods3);
        }
      } else if (res.code == 400) {

        // 获取积分商场首页信息失败
        Toast(res.message || "获取积分商场首页信息失败");
      } else {
        // 获取积分商场首页信息失败
        Toast(res.message);
      }
    },

    /**
* 滚动条滚动/touchmove监听处理
* @param {object} e [滚动条对象]
* @param {boolean} isTimeout [是否为setTimeout方法调用]
*/
    onPageScrollFun (e, isTimeout = false) {

      // 获取滚动条位置,浏览器兼容处理
      let scrollTop = (document.documentElement.scrollTop || document.body.scrollTop) || 0;

      // 滚动控制高度
      let maxHeight = 200;

      // 动态获取百分比分配比例
      if (typeof this.$refs === "object" && typeof this.$refs.navBox === "object" && typeof this.$refs.navBox.clientHeight === "number") {
        maxHeight = (this.$refs.navBox.clientHeight + this.$parent.top.value) * 2;
      }

      if (scrollTop >= 0 && scrollTop <= maxHeight) {
        this.opacity = scrollTop / maxHeight;
      } else if (scrollTop > maxHeight) {
        this.opacity = 1;
      } else {
        this.opacity = 0;
      }

      if (!isTimeout) {

        if (this.timer) {
          clearTimeout(this.timer);
        }

        // 倒计时校正滚动条位置
        this.timer = setTimeout(function (options) {

          // 递归
          options.context.onPageScrollFun(options.e, true);
        }, 1000, { e, context: this });
      }
    }
  },
  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");
      }
    }
  },
  //请求数据
  created () {
    // 设置标题
    this.$set(this, "title", "积分商城");

    // 设置锚点定位数据
    this.$set(this, 'navs', [
      {
        ref: 'physicalGoodsBox',
        simg: 'static/img/pointsMall/icon01.png',
        title: '赚积分'
      },
      {
        ref: 'virtualGoodsBox',
        simg: 'static/img/pointsMall/icon02.png',
        title: '我的收藏'
      },
      {
        ref: 'fullReductionBox',
        simg: 'static/img/pointsMall/icon03.png',
        title: '我的订单'
      }
    ]);

    // 设置产品排名flag对象
    this.$set(this, 'flags', {
      icon: [
        'static/img/icon_n1.png',
        'static/img/icon_n2.png',
        'static/img/icon_n3.png'
      ],
      position: {
        top: -6,
        left: 20
      }
    });
    // 判断是否在App内
    if (this.isCNLive.value) {

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

      // 设置标题
      this.$set(this.backs, 'title', '积分商城');
      // 右上角三个点下拉菜单
      this.$set(this, 'shareItems', [
        {
          simg: 'static/img/pointsMall/share01.png',
          title: '平台客服',
          icon: 'static/img/pointsMall/right_icon.png',
          func: this.jumpType,
          params: 1,
        },
        {
          simg: 'static/img/pointsMall/share02.png',
          title: '分享好友',
          icon: 'static/img/pointsMall/right_icon.png',
          func: this.jumpType,
          params: 2,
        },
        {
          simg: 'static/img/pointsMall/share03.png',
          title: '积分规则',
          icon: 'static/img/pointsMall/right_icon.png',
          func: this.jumpType,
          params: 3,
        }
      ]);
    }
    // 获取积分商城商品信息接口
    this.integralMallIndex();
    // 获取商品列表数据
    // this.$set(this.phyicalGoods, 0, {
    //          loading: true,
    //          distance: 50,
    //          page: 1,
    //          isCall: false, // 是否调用接口
    //          isMore: false,
    //          list: [],
    //       });
    // this.getIntegralNewGoodsList(this.phyicalGoods[0].page);
  },
  mounted () {
    // 如果是App外,设置唤起App和微信内分享参数
    if (!this.isCNLive.value) {
      // 设置积分首页唤起app参数
      if (typeof this.$parent.getOpenApp === "function") {
        this.$parent.getOpenApp({
          type: 45,
          id: this.$route.query.id || 1,
          url: ""
        });
      }
      // 分享详情页
      if (typeof this.$parent.getShareData === "function") {
        this.$parent.getShareData({
          type: 45,
          id: this.$route.query.id || 1,
          url: ""
        });
      }
    }

    // 监听滚动条,设置滚动条推动渐变颜色和图片
    window.addEventListener("scroll", this.onPageScrollFun, true);

    // 页面显示监听
    document.addEventListener('visibilitychange', () => {

      // 页面显示出来了
      if (document.hidden === false) {
        // 只刷新积分
        this.refreshGrade = true;
        // 获取积分商城商品信息接口
        this.integralMallIndex();
      }
    });
  }
}
</script>

<style rel="stylesheet/less" lang='less' scoped>
@import 'pointsMall';
</style>
<style>
.goto_top_box {
  z-index: 2 !important;
}
</style>