index.js 3.19 KB
Newer Older
1 2 3 4 5 6 7 8
let app = getApp()
const { spokesmanApi, DFSImg, $themeToLink } = app;
const componentOptions = {
  // 组件选项
  options: {
    multipleSlots: true
  },
  behaviors: [],
张卓 committed
9 10 11 12 13
  properties: {
    getDistributorHomepageName: {
      type: String
    }
  },
14 15 16 17 18 19 20
  // 组件数据
  data: {
    isPageHidden: false,
    showPop: false,
    showSetMoreDiscountPrice: false,
    distributionPrice1: 0,
    showBaiFen: false,
张卓 committed
21
    spokesmanInfo: {},
22 23 24 25 26 27 28
  },
  // 数据监听器
  observers: {},
  // 组件生命周期
  lifetimes: {
    created() {},
    ready() {
张卓 committed
29
      this.setData({ spokesmanInfo: app.fenxiaoModel.spokesmanInfo });
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
    },
    moved() {},
    detached() {}
  },
  attached() {
  },
  definitionFilter() {},
  onPageScroll() {
    // console.log(e,444444444444);
  },
  // 页面生命周期
  pageLifetimes: {
    // 页面被展示
    show() {

    },
    // 页面被隐藏
    hide() {
    },
    // 页面尺寸变化时
    resize() {}
  },
  // 组件方法
  methods: {
    toMyBusinessCard() {
      // this.setData(showPop)
      this.setData({ showPop: true });
    },
侯体倬 committed
58 59
    setNewShop(e) {
      app.trackCpn(e, '分销商组件')
60
        // window.sessionStorage.setItem(getTokenTwo()+'currentState',0)
张卓 committed
61 62
        app.fenxiaoModel.getDistributorHomepage().then(res=>{
            console.log(res,888888888)
张卓 committed
63
            if(!this.data.spokesmanInfo.parentId) {
64 65
                this.initShopDetail()
                return
张卓 committed
66
            }
张卓 committed
67
            if(!(res&&res.id)) {
张卓 committed
68
              this.setData({ showPop: true });
张卓 committed
69
            }else if(res&&res.id){
70 71 72 73 74
                this.initShopDetail()
            }
        })
    },
    copyShop() {
张卓 committed
75 76
        app.fenxiaoModel.oneClickShopQuickCopy({grossProfitMargin: parseFloat(this.data.distributionPrice1)}).then(res=>{
            if(res == 'true') {
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
                this.initShopDetail()
            }
        })
    },
    closePopuop1() {
      this.setData({ showPop: false });
    },
    closePopuop2() {
      this.setData({ showSetMoreDiscountPrice: false });
    },
    initShopDetail() {
      let linkVal = '/personalCenter/spokesmanCenter/mine/spokesmanHomePage?fromSpokesmanCenter=1'
      $themeToLink({
        type: 1,
        link:linkVal,
      });
    },
    checkedBtn() {
      this.setData({ showPop: false });
      this.setData({ showSetMoreDiscountPrice: true });
    },
    focus(){
      // this.setData({ distributionPrice1: parseFloat(this.data.distributionPrice1) });
    },
    blur() {
      // if(!(this.data.distributionPrice1-0)){
      //   this.setData({ distributionPrice1: 0 });
      // }else {
      //   this.setData({ distributionPrice1: distributionPrice1 });
      // }
    },
    setProfit(val) {
      if(val.detail!==0&&!(val.detail.toString())) {
        return
      }
      console.log(val.detail,val)
      if(val.detail-0<0 || !(val.detail-0)) {
        this.setData({ distributionPrice1: 0 });
        return
      }
      if((val.detail-0).toString().indexOf('.')!=-1&&(val.detail-0).toString().substring((val.detail-0).toString().indexOf('.')+1).length>2) {
        this.setData({ distributionPrice1: (val.detail-0).toFixed(2)-0 });
        return
      }
      this.setData({ distributionPrice1: val.detail-0 });
    },
  }
};

Component(componentOptions);