let app = getApp() const { spokesmanApi, DFSImg, $themeToLink } = app; const componentOptions = { // 组件选项 options: { multipleSlots: true }, behaviors: [], properties: { getDistributorHomepageName: { type: String } }, // 组件数据 data: { isPageHidden: false, showPop: false, showSetMoreDiscountPrice: false, distributionPrice1: 0, showBaiFen: false, spokesmanInfo: {}, }, // 数据监听器 observers: {}, // 组件生命周期 lifetimes: { created() {}, ready() { this.setData({ spokesmanInfo: app.fenxiaoModel.spokesmanInfo }); }, moved() {}, detached() {} }, attached() { }, definitionFilter() {}, onPageScroll() { // console.log(e,444444444444); }, // 页面生命周期 pageLifetimes: { // 页面被展示 show() { }, // 页面被隐藏 hide() { }, // 页面尺寸变化时 resize() {} }, // 组件方法 methods: { toMyBusinessCard() { // this.setData(showPop) this.setData({ showPop: true }); }, setNewShop(e) { app.trackCpn(e, '分销商组件') // window.sessionStorage.setItem(getTokenTwo()+'currentState',0) app.fenxiaoModel.getDistributorHomepage().then(res=>{ console.log(res,888888888) if(!this.data.spokesmanInfo.parentId) { this.initShopDetail() return } if(!(res&&res.id)) { this.setData({ showPop: true }); }else if(res&&res.id){ this.initShopDetail() } }) }, copyShop() { app.fenxiaoModel.oneClickShopQuickCopy({grossProfitMargin: parseFloat(this.data.distributionPrice1)}).then(res=>{ if(res == 'true') { 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);