phone.js 1.64 KB
// components/actionSheet/phone.js
import util from '../../utils/util';
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    //items: Array,//电话列表
    //seller:Object,//商家信息
    hasTip:{
      type:Boolean,
      value:true,
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    actionSheetHidden: true,
    hasOnlineReserve:false,
  },

  /**
   * 组件的方法列表
   */
  methods: {
    show(seller){
      this.seller=seller
      let seller_tel = this.seller.seller_tel;
      // if(this.seller.is_online_reserve==1 && this.seller.is_tele==0){
      //   //开通在线预订,但无商家接单设备,拨打运营电话
      //   seller_tel = ['400-000-9690']
      // }else{
      //   if (seller_tel.length < 1) {
      //     seller_tel = [this.seller.phone]
      //   }
      // }
      if (seller_tel.length < 1) {
        seller_tel = [this.seller.phone]
      }
      this.setData({
        actionSheetHidden: false,
        items:seller_tel,
        hasOnlineReserve:this.seller.is_online_reserve==1
      })
    },
    hide(){
      this.setData({
        actionSheetHidden: true,
      })
    },
    bindItemTap(e){
      this.hide();
      let index=util.attr(e,'index')
      if(index=='reserve'){//跳转到预订页
        let url=util.http_build_query({id:this.seller.id,activeTab:'reserve'},'/pages/reserve/reserve')
        wx.navigateTo({
          url:url,
        })
        return;
      }else{
        let value=util.attr(e,'value')
        wx.makePhoneCall({
          phoneNumber: value.replace(/[^\d]/g, '')
        })
      }
    },
    actionSheetChange(){
      this.hide();
    }
  }
})