tabBar.js 1.67 KB
// components/book/tabBar/tabBar.js
import util from '../../../../utils/util'
import App from '../../../../utils/api';
import gl from '../../../global'
const {regeneratorRuntime} = global
Component({
  /**
   * 组件的属性列表
   */
  properties: {},

  /**
   * 组件的初始数据
   */
  data: {
    pi: 0,
    dot:0,
    hasEditorFlag:false,//添加预订
    hasReserveOrder:false,//运营处理在线预订
    tabsHidden:true,
  },
  attached(){
    let pages = getCurrentPages();
    let p = pages[pages.length - 1];
    let pr=p.route.split('/')
    this.setData({
      pi: pr[pr.length-1]
    })
  },
  ready(){
    this.VerificationIsAdmin()
    this.hasDot()
    this.hasEditor();
  },
  /**
   * 组件的方法列表
   */
  methods: {
    redirectTo(e){
      let url = util.attr(e, 'url');
      let pages = getCurrentPages();
      let p = pages[pages.length - 1];
      if (url.indexOf(p.route) < 0) {
        wx.reLaunch({
          url: url,
        })
      }
    },
    hasDot(){
      App.Reserve.GetNewCustomerTotal().then(res => {
        let dot=res.data.total||0
        this.setData({
          dot:dot
        })
        this.triggerEvent('NewCustomer',{total:dot})
      });
    },
    hasEditor(){
      gl.getHasEditorFlag().then(()=>{
        this.setData({
          hasEditorFlag:true,
          tabsHidden:false,
        })
      }).catch(()=>{
        this.setData({
          tabsHidden:false,
        })
      })
    },
    VerificationIsAdmin(){
      gl.VerificationIsAdmin().then(()=>{
        this.setData({
          hasReserveOrder:true,
        })
      }).catch(()=>{
        this.setData({
          hasReserveOrder:false,
        })
      })
    },
  }
})