import { VueLikePage } from '../../utils/page'
import UserApi from '../../apis/user'
import Router from '../../utils/routes'
VueLikePage([], {
  data: {
    my_info: getApp().globalData.userinfo
  },
  methods: {
    onShow () {
      
      this.getBusinessCardList()
      this.setData({
        my_info: getApp().globalData.userinfo
      })
    },
    getBusinessCardList () {
      return UserApi.getVisitCardList().then(res => {
        let list = res.data.list
        this.origin_list = list
        this.setData({
          business_list: list
        })
      })
    },
    bindinput (e) {
      const value = e.detail
      this.setData({
        business_list: this.origin_list.filter(item => item.name.indexOf(value) > -1)
      })
    },
    toBusinessCard (e) {
      const { id } = e.currentTarget.dataset
      Router.push({
        url: 'businessCardDetail',
        query: {
          id
        }
      })
    },
    toScan () {
      Router.push('scan')
    },
    callPhone (e) {
      const { phone } = e.currentTarget.dataset
      wx.makePhoneCall({
        phoneNumber: phone
      })
    }
  }
})