<template>
  <button v-if="control" class="button_search btn-gn" :disabled="clickable" @click="confirm()">扫码支付</button>
</template>

<script>
export default {
  name: 'PaymentCodeButton',
  data () {
    return {}
  },
  props: {
    // 付款方式,双向绑定
    payment: {},
    // 可点击
    clickable: {
      default: false
    },
    // 付款方式下拉选数据
    paymentData: {
      default: []
    }
  },
  created () {
  },
  mounted () {
  },
  methods: {
    confirm () {
      let paymentCodePayment = this.paymentData.find(value => value.value.includes('&'))
      if (paymentCodePayment) {
        this.payment = this.payment instanceof Array ? [paymentCodePayment.value] : paymentCodePayment.value
        this.$emit('confirm-payment')
      } else {
        this.$showMessage('在付款方式中没有找到相应的扫码支付方式, 请在参数管理中添加')
      }
    }
  },
  computed: {
    control () {
      return this.$login.r.find(value => value == '扫码支付按钮')
    }
  }
}
</script>

<style lang="less">

</style>
