index.js 21 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

import { getChannelCode, getGenderCode, getRecPosCode, getRecommandContentCode, getResourceCode,getHomeContentCode} from '../../utils/home';
import { shouldDiscardTap, getGoodDetailParam, getImageUrl, formatImageUrl,getGuangType, getYHStorageSync} from '../../utils/util';
import homeService from './indexService.js'
import { JUMP_BRAND, JUMP_DETAIL, JUMP_PRODUCTPOOL}  from './indexService.js'
import { parseProductListData } from '../../utils/productListUtil';
import router from '../../router/index.js'

//获取应用实例
let app = getApp()
const windowWidth = app.globalData.systemInfo.windowWidth;
const windowHeight = app.globalData.systemInfo.windowHeight;
const pixelRatio = app.globalData.systemInfo.pixelRatio;

let activityItemWidth = 186;
let activityItemHeight = 237;

let CHANNEL = "gender_channel"

Page({
  data: {
    lastTapTimeStamp: 0,
    currentDate:null,
    selectedChannel: 'boy',
    homelist:[],
    newChannels:{
      boy:{
        data:[],//列表list
        isLoading: false,
        recommend: {
          isLoading: false,
          error: null,
          data: null,
        },
      },
      girl:{
        data:[],
        isLoading: false,
        recommend: {
          isLoading: false,
          error: null,
          data: null,
        },
      }
    },
    isShowIndicator: false,
    newCustomer: false,
    fixedFilter: false,
    currentFixedFilterIndex: 0,
    homeTabs: [],
    guangList: {
      page: 0,
      sort_id: 0,
      limit: 20,
      list: [],
      isLast: false,
    },
  },
  onLoad: function (e) {
    this.getLastChannel();
    this.fetchNewHomeData();
    this.getHomeTabList();
    this.getGuangList(false);
    //超过一天
    var currentDate = new Date();
    var pretimestamp = this.getStorage("pretimestamp");
    var preDate;
    if (pretimestamp) {
      preDate = new Date(pretimestamp);
    }
    if (!preDate
    || currentDate.getFullYear() !== preDate.getFullYear()
    || currentDate.getMonth() !== preDate.getMonth()
    || currentDate.getDate() !== preDate.getDate()){
      this.setData({
        currentDate,
      });
      this.showIndexDialog();
    }

    let jumpType = e.jumpType;
    if (jumpType == JUMP_BRAND) {
      let brandId = e.brandId;
      let brandName = e.brandName;
      if (brandId != '' && brandName != '')
        tt.navigateTo({
          url: '../brandStore/brand?brandId=' + brandId + '&brandName=' + brandName + '&page_name=' + 'home' + '&page_param=' + ''
        });
    } else if (jumpType == JUMP_DETAIL) {
      let productSkn = e.productSkn;
      if (productSkn != '') {
        tt.navigateTo({
          url: '../goodsDetail/goodsDetail?productSkn=' + productSkn + '&page_name=' + 'home' + '&page_param=' + ''
        });
      }
    } 
    // else if (jumpType == JUMP_PRODUCTPOOL) {
    //   let productPool = e.productPool;
    //   if (productPool != '') {
    //     tt.navigateTo({
    //       url: '../goodsList/productPool?productPool=' + productPool + '&page_name=' + 'home' + '&page_param=' + ''
    //     });
    //   }
    // }
  },

  onShareAppMessage: function (res) {
    let param = {
      FROM: res.from,
      SHARE_RESUIL: 0,
      TITLE: 'Yoho!Buy有货-潮流购物逛不停',
      PATH: '/pages/index/index',
    }

    // 用户点击右上角分享
    return {
      title: param.TITLE, // 分享标题
      desc: '精选1400+全球潮流品牌,明星潮牌和新锐原创品牌每日上新,100%正品行货。', // 分享描述
      path: param.PATH, // 分享路径
      success: function (res) {
        // param.SHARE_RESUIL = 1
        // logEvent(YB_SHARE_RESULT_L, param);
      },
      fail: function (res) {
        // param.SHARE_RESUIL = 2
        // logEvent(YB_SHARE_RESULT_L, param);
      }
    }
  },

  onPullDownRefresh: function () {
    tt.stopPullDownRefresh();
    this.getLastChannel();
    this.fetchNewHomeData(true);  
    this.getHomeTabList(); 
    this.getGuangList(false); 
  },

  onReachBottom: function () {
    let currentFixedFilterIndex = this.data.currentFixedFilterIndex;
    let homeTabs = this.data.homeTabs;
    let item = homeTabs.length > currentFixedFilterIndex ? homeTabs[currentFixedFilterIndex] : '';
    if (item && item.type == 1) {
      this.getGuangList(true);
    }
  },

  //获取新首页数据
  fetchNewHomeData: function (force) {
    var channel = this.data.selectedChannel;
    let newChannels = this.data.newChannels;
    let currentData = newChannels[channel];
    if (currentData && currentData.data && currentData.data.length > 0 && !force) {
      this.setHomeList();
      return;
    }
    let cotentCode = getHomeContentCode(channel);
    let gender = getGenderCode(channel);
    let yh_channel = getChannelCode(channel);
    if (!force) {
      this.setLoadingHomeData(true);
    }
    let params = {
      content_code: cotentCode,
      gender,
      yh_channel,
      // union_id: app.globalData.WXUnion_ID || this.getStorage('unionID')
    }

    let that = this;
    homeService.getHomeFloorlist(params)
      .then(json => {

        that.setLoadingHomeData(false);

        if (json && json.code && json.code == 200) {
          let homeList = json.data.list;
          homeList = homeService.parseHomeList(homeList, windowWidth, windowHeight, activityItemWidth, activityItemHeight);

          if (!homeList || homeList.length <= 0) {
            tt.showToast({
              title: json.message,
              icon: 'none',
              duration: 1500
            });
          }
          let newChannels = that.data.newChannels;
          let currentData = newChannels[channel];
          currentData.data = homeList;
          newChannels[channel] = currentData;

          that.setData({
            newChannels: newChannels
          })
          that.setHomeList(force);
        } else {
          that.setHomeList(force);
          tt.showToast({
            title: json.message,
            icon: 'none',
            duration: 1500
          });
        }
      })
      .catch(error => {
        that.setLoadingHomeData(false);
        that.setHomeList(force);
        
        tt.showToast({
          title: error.message,
          icon: 'none',
          duration: 1500
        });
      })
  },

  setLoadingHomeData: function (isLoading) {
    let channel = this.data.selectedChannel;
    let _newChannels = this.data.newChannels;
    let currentData = _newChannels[channel];
    if (currentData) {
      currentData.isLoading = isLoading;
    }
    this.setData({
      newChannels: _newChannels,
    })
  },

   //可优化
   setHomeList: function (force) {
    let channel = this.data.selectedChannel;
    let newChannels = this.data.newChannels;
    let currentData = newChannels[channel];
    if (currentData && currentData.data) {
      this.setData({
        homelist: currentData.data,
      })
    }
    this.fetchRecommend(force);
  },

  //请求(男生、女生)猜你喜欢数据
  fetchRecommend: function (force) {
    let currentChannel = this.data.selectedChannel;
    let currentChannelData = this.data.newChannels[currentChannel];
    let recommend = currentChannelData.recommend;
    if (recommend.data && recommend.data.length > 0 && !force) {
      return;
    }

    let param = {};
    let gender = getGenderCode(currentChannel);
    let yh_channel = getChannelCode(currentChannel);
    let content_code = getRecommandContentCode(currentChannel);
    let rec_pos = getRecPosCode(currentChannel);
    param = {
      content_code,
      gender,
      yh_channel,
      rec_pos,
    };

    let newChannelData = Object.assign(currentChannelData, { recommend: Object.assign(recommend, { isLoading: true, }) });
    let newChannels = this.data.newChannels;
    newChannels[currentChannel] = newChannelData;

    this.setData({
      newChannels: newChannels,
    });

    homeService.getProductlist(param)
      .then(json => {
        if (!json || !json.code || json.code != 200) {
          let currentChannel = this.data.selectedChannel;
          let currentChannelData = this.data.newChannels[currentChannel];
          let newChannelData = Object.assign(currentChannelData, { recommend: Object.assign(recommend, { isLoading: false, error: { code: json.code, message: json.message } }) });
          let newChannels = this.data.newChannels;
          newChannels[currentChannel] = newChannelData;

          this.setData({
            newChannels: newChannels,
          });
          return;
        }

        let data = json.data.product_list;
        data = parseProductListData(data);
        let currentChannel = this.data.selectedChannel;
        let currentChannelData = this.data.newChannels[currentChannel];
        let newChannelData = Object.assign(currentChannelData, { recommend: Object.assign(recommend, { isLoading: false, data }) });
        let newChannels = this.data.newChannels;
        newChannels[currentChannel] = newChannelData;

        this.setData({
          newChannels: newChannels,
        });
      })
      .catch(error => {
        let currentChannel = this.data.selectedChannel;
        let currentChannelData = this.data.newChannels[currentChannel];
        let newChannelData = Object.assign(currentChannelData, { recommend: Object.assign(recommend, { isLoading: false, error }) });
        let newChannels = this.data.newChannels;
        newChannels[currentChannel] = newChannelData;

        this.setData({
          newChannels: newChannels,
        });
      });
  },

  /**
   * 首页资源位dialog
   */
  showIndexDialog: function(){
    var app = getApp();
    let that = this;
    homeService.getIndexDialog({})
    .then(json => {
      // console.log(json);
      if (json && json.code && json.code == 200 && json.data[0] && json.data[0].data[0] && json.data[0].data[0].url){
        that.setStorage('pretimestamp', Date.parse(that.data.currentDate));
        that.setData({
          dialogSrc: formatImageUrl(json.data[0].data[0].src, 340 * app.globalData.systemInfo.pixelRatio, 340 * app.globalData.systemInfo.pixelRatio,2),
          dialogUrl: json.data[0].data[0].url,
        });
        that.setStorage('pretimestamp', Date.parse(that.data.currentDate));
        that.dialog.showDialog();
      }
    }).catch(error => { });
  },
  
  getHomeTabList: function () {
    let that = this;

    that.setData({
      homeTabs : [],
      currentFixedFilterIndex: 0
    });

    homeService.getHomeTabList({})
      .then(json => {
        if (json && json.code == 200) {
          let list = json.data;
          let homeTabs = [];
          let currentFixedFilterIndex = 0;
          for (var i = 0; i < list.length;i++) {
            let item = list[i];
            if (item.showFlag == 1 && (item.type == 1 || item.type == 2)){
              homeTabs.push(item);
            }
          }

          for (var i = 0; i < homeTabs.length; i++) {
            let item = homeTabs[i];
            if (item.defaultFlag == 1) {
              currentFixedFilterIndex = i;
            }
          }

          setTimeout(function () {
            that.setData({
              homeTabs,
              currentFixedFilterIndex
            });
          }, 1000);
        }
      })
      .catch(error => {
        // console.log(error)
      })
  },

  // 获取列表数据
  getGuangList: function (isLoadMore) {
    let that = this;
    let guangList = this.data.guangList;
    if (isLoadMore == false) {
      guangList.page = 0;
      guangList.sort_id = 0;
      guangList.limit = 20;
      guangList.list = [];
      guangList.isLast = false;
      that.setData({
        guangList,
      });
    }
    
    let isLast = guangList.isLast;
    if (isLast) {
      return;
    }
    let param = {
      page: guangList.page + 1,
      gender: app.globalData.selectedChannel === 'boy' ? '1,3' : '2,3',
      sort_id: guangList.sort_id,
      limit: guangList.limit,
      uid: app.getUid(),
    };

    homeService.getGuangList(param)
    .then(json => {
        if (json && json.code == 200) {
          let artList = json.data.list.artList;
          let page = json.data.page;
          let totalPage = json.data.totalPage;
          for(var i = 0; i<artList.length; i++){
            let item = artList[i];
            item.src = item.src.replace(/{width}/g, 345 * pixelRatio).replace(/{height}/g, 216 * pixelRatio).replace('{mode}', 2);
            item.type = getGuangType(item.url);
            guangList.list.push(item);
          }
          guangList.page = page;
          guangList.isLast = totalPage == page;

          that.setData({
            guangList,
          });
        }
      })
      .catch(error => {
        // console.log(error)
      })
  },


  /* 
    首次点击,判断是否是新人(默认是新人):
    (1)是新人,弹框授权,跳链接 (2)不是新人,显示提示,不跳转
  */
 getPhoneNumber: function (e) {
  if (this.getStorage('newCustomer')) {
    this.jumpByRuleEvent(e);
    return;
  }
  if (e.detail.errMsg === 'getPhoneNumber:ok') {
    decodePhoneNumber(e.detail.iv, e.detail.encryptedData, '', (result) => {
      if (result.code === 200) { // 首次授权的新人
      //新注册用户
      if (result.is_register){
        that.showZanToast({
          title:'欢迎加入Yoho!Family!新人礼包已发放到个人中心-优惠券,请注意查收',success: function() {
            // 新人楼层标示newCustomer
            this.setStorage('newCustomer', true);
            this.jumpByRuleEvent(e);
        }},1500);
      } else {
        // 新人楼层标示newCustomer
        this.setStorage('newCustomer', true);
        this.jumpByRuleEvent(e);
      }
      } else { // 不是新人,提示
        tt.showModal({
          title: '提示',
          content: '活动仅限新用户参加',
          showCancel: false
        });
      }
    })
  } else { // 取消手机号授权
    tt.navigateTo({
      url: '../bindPhoneNumber/bindPhoneNumber',
    })
  }
},

  //获取上次切换的频道 默认显示上次频道
  getLastChannel: function () {
    let lastChannel = getYHStorageSync(CHANNEL,'index');
    if (lastChannel && (lastChannel === 'boy' || lastChannel === 'girl')) {
      app.globalData.selectedChannel = lastChannel;

      if (lastChannel === 'boy') {
        app.globalData.cid = '1'
      }
      else if (lastChannel === 'girl') {
        app.globalData.cid = '2'
      }
      this.setData({
        selectedChannel: lastChannel
      })
    }
    // let C_ID = app.globalData.cid ? app.globalData.cid : '1';
    // let param = {
    //   C_ID,
    // }
    // logEvent('YB_MAIN_CHANNEL_C', param);
  },

  //是否展开频道选择框
  selectChannel:function(e){
    let _selectChannel = this.data.channelSelect;
    _selectChannel = !_selectChannel;
    this.setData({ channelSelect: _selectChannel})
  },

  hiddenChannel:function(){
    this.setData({
      channelSelect:false,
    })
  },

  //首页频道选择
  channelSelected: function (event) {

    // console.log(event)
    let selectedChannel = event.target.dataset.type;

    if (selectedChannel == this.data.selectedChannel) {
      return;
    }
  
    app.globalData.selectedChannel = selectedChannel;

    if (selectedChannel === 'boy') {
      app.globalData.cid = '1'
    }
    else if (selectedChannel === 'girl') {
      app.globalData.cid = '2'
    }
    // let C_ID = app.globalData.cid;
    // let param={
    //   C_ID,
    // }
    // logEvent('YB_MAIN_CHANNEL_C',param);
    this.setData({
      selectedChannel,
      channelSelect:false
    });

    this.fetchNewHomeData();

    tt.setStorage({
      key: CHANNEL,
      data: this.data.selectedChannel,
    })

    this.backToTop();
  },

  jumpToYohood:function(event){

    router.goUrl("https://ad.yoho.cn/html5/2018/yohood/index.html?share_id=5381&title=YOHOOD2018&openby:yohobuy={\"action\":\"go.h5\",\"params\":{\"title\":\"YOHOOD2018\",\"share_id\":5381,\"url\":\"https://ad.yoho.cn/html5/2018/yohood/index.html?share_id=5381&title=YOHOOD2018\"}}");

    this.setData({
      channelSelect: false
    });
  },

  productCellTapped: function(event) {
    let data = event.currentTarget.dataset.productItem;
    let productSkn = data.product_skn;
    let jumpUrl = '../goodsDetail/goodsDetail?productSkn=' + productSkn + '&page_name=' + 'home' + '&page_param=' + '';

    tt.navigateTo({
      url: jumpUrl
    });

    // let TAB_ID = parseInt(this.data.currentFixedFilterIndex) + 1;
    // let I_INDEX = event.currentTarget.dataset.f_inindex + 1//楼层内index
    // let param = {
    //   TAB_ID,
    //   I_INDEX, 
    //   F_URL: jumpUrl,
    // }
    // logEvent('YB_MAIN_EVENT', param);
    
  },

  tappedGuangArtContent: function (event) {
    let articleId = event.currentTarget.dataset.articleId;
    let jumpUrl = '../guang/detail?id=' + articleId + '&page_name=home&page_param=';
    
    tt.navigateTo({
      url: jumpUrl
    });


    // let TAB_ID = parseInt(this.data.currentFixedFilterIndex) + 1;
    // let I_INDEX = event.currentTarget.dataset.f_inindex + 1//楼层内index
    // let param = {
    //   TAB_ID,
    //   I_INDEX,
    //   F_URL: jumpUrl,
    // }
    // logEvent('YB_MAIN_EVENT', param);

  },

  brandCellTapped: function (event) {
    let data = event.currentTarget.dataset.productItem;
    let shop_id = data.shop_id;
    let shop_name = data.shop_name;

    tt.navigateTo({
      url: '../brandStore/brandStore?shop_id=' + shop_id + '&shop_name' + shop_name + '&page_name=' + 'home' + '&page_param=' + ''
    });
  },

  //formId上报
  formSubmitFromSwitchGender: function (e) {
    // let formId = e.detail.formId;
    // postFormId(formId,"2");
  },


  onPageScroll: function (event) {
    var { scrollTop } = event;
    var isShow = scrollTop > windowHeight * 2 ? true : false;
    if (isShow != this.data.isShowIndicator) {
      this.setData({
        isShowIndicator: isShow
      });
    }
    let pixelRatio = windowWidth/750;
    let that = this;
    tt.createSelectorQuery().select('#fixedFilterViewC').boundingClientRect(function (rect) {
      if(rect) {
        var y = rect.top / pixelRatio;
        let fixedFilter = y >= 88 + 4 ? false : true;
        if (fixedFilter != that.data.fixedFilter){
          that.setData({
            fixedFilter
          });
        }
      }
    }).exec()
  },
  //回到顶部
  backToTop: function () {
    tt.pageScrollTo({
      scrollTop: 0,
    })
  },

  jumpByRuleEvent(event) {
    let dataset = event.currentTarget.dataset;
    if (Object.keys(dataset).length === 0) {
      dataset = event.detail.currentTarget.dataset;
    }
    let url = dataset.jump_rule;
    router.goUrl(url);
  },

  //搜索事件处理函数
  searchTapped: function (event) {
    if (shouldDiscardTap(event.timeStamp, this.data.lastTapTimeStamp)) {
      return;
    }

    this.setData({ lastTapTimeStamp: event.timeStamp });
    let param = {};
    tt.navigateTo({
      url: '../search/search?' + 'page_name=' + 'home' + '&page_param=' + '&param=' + param
    })
  },

  fixedFilterTapped: function (event) {
    let currentFixedFilterIndex = event.currentTarget.dataset.type;

    // if (currentFixedFilterIndex != this.data.currentFixedFilterIndex) {
    //   let params = {
    //     TAB_ID: parseInt(currentFixedFilterIndex) + 1,
    //   };
    //   logEvent(YB_MAIN_STROLL_TAB_C, params);
    // }

    this.setData({ currentFixedFilterIndex });
    
    
    let that = this;
    tt.createSelectorQuery().select('#fixedFilterViewC').boundingClientRect(function (rect) {
      let top0 = rect.top;
      if (top0 <= 44) {
        tt.createSelectorQuery().select('#fixedFilterViewCTop').boundingClientRect(function (rects) {
          let pixelRatio = windowWidth / 750;
          var offset = 88 * pixelRatio;
          let top1 = rects.top;
          let y = top0 - top1 - offset;
          that.backToIndex(y);
        }).exec()
      }
    }).exec()
  },

  backToIndex: function (y) {
    tt.pageScrollTo({
      scrollTop: y,
      duration: 300,
    })
  },
  scanCodeTapped() {

		tt.scanCode({
			success: (res) => {
				let url = res.path;

				if (url) {
					url = url.indexOf('page/subPackage') !== -1 ? '/' + url : url.replace(/pages/g, "..");
					tt.navigateTo({
						url: url,
					});
				} else {
					let hasOpenby = url.indexOf('openby:yohobuy=');

					url = res.result;

					if (hasOpenby < 0) {
						if (url.startsWith('https://m.yohobuy.com/product') || url.startsWith('http://m.yohobuy.com/product') || url.startsWith('https://o.yohobuy.com/mp') || url.startsWith('https://o.yohobuy.com/mp')) {
							tt.navigateTo({
								url: '/pages/goodsDetail/goodsDetail?q=' + url
							});
						} else if (url.startsWith('https://m.yohobuy.com/shop') || url.startsWith('http://m.yohobuy.com/shop')) {
							tt.navigateTo({
								url: '/pages/brandStore/brandStore?q=' + url
							});
						}
					} else {
            router.goUrl(url);
					}
				}

				// logEvent(YB_SCAN_CODE_SUCCESS, {
				// 	PAGE_PATH: url,
				// });
			}
		})
  },
  
   // 清除storage
   removeStorage: function(key) {
    try {
      tt.removeStorageSync(key);
    } catch (e) {
      // console.log(e);
    }
  },
  // 获取storage
  getStorage: function(key) {
    return getYHStorageSync(key,'index');
  },
  // 设置storage
  setStorage: function(key, value) {
    try {
      tt.setStorageSync(key, value);
    } catch (e) {
      // console.error(e);  
    }
  }

})