<template>
  <view class="bottom-navbar safe-area-inset-bottom">
    <view class="left-actions">
      <view class="action" @tap="onShare">
        <u-icon name="share" color="#909399" size="50"></u-icon>
        <text class="label">分享</text>
      </view>
      <view class="action" @tap="onCall">
        <u-icon name="phone" color="#909399" size="50"></u-icon>
        <text class="label">拨打电话</text>
      </view>
    </view>

    <view class="main-btn" @tap="onReserve" :style="{backgroundColor: btnColor}">
      <text class="label">{{btnTitle || '加载错误'}}</text>
    </view>
    <share ref="share" :assetId="assetId" :title="shareBtnTitle" :btnColor="btnColor"/>
  </view>
</template>


<script>
import share from '../share/share.vue';

export default {
  name: 'assetBottomBar',
  components: { share },
  props: { 
	  assetId: [String, Number], 
	  phone: String ,
	  btnTitle:  {
      type: String,
      default: ''
    },
	shareBtnTitle:  {
	  type: String,
	  default: ''
	},
	/** 小程序页面路径 */
	pagePath: {
	  type: String,
	  required: true
	},
	
	/** H5 页面路径 */
	h5Path: {
	  type: String,
	  required: true
	},
	
	/** 分享参数（id / code 等） */
	query: {
	  type: Object,
	  default: () => ({})
	},
	
	/** 小程序码接口 */
	minicodeApi: {
	  type: String,
	  default: ''
	},
	
	/** H5 基础域名（可选） */
	baseUrl: {
	  type: String,
	  default: ''
	},
	btnColor: {
	  type: String,
	  default: ''
	}
	  },
  methods: {
    onShare() {
        console.log("调用分享")
        this.$refs.share.open()
    },
    onCall() {
      if (!this.phone) {
        return uni.showToast({ title: '暂无联系电话', icon: 'none' })
      }
      uni.makePhoneCall({
        phoneNumber: this.phone
      })
    },
    onReserve() {
      this.$emit('reserve') // 通知父页面弹出预约弹窗
    }
  }
}
</script>

<style scoped>
.bottom-navbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 170rpx;
  background-color: #ffffff;
  border-top: 1rpx solid #e5e5e5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 999;
  box-shadow: 0 -4rpx 12rpx rgba(0, 0, 0, 0.06);
  padding: 0 20rpx env(safe-area-inset-bottom);
}

/* 左侧按钮组 */
.left-actions {
  display: flex;
  align-items: center;
  gap: 20rpx;
}
.action {
  width: 120rpx;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #333;
  font-size: 24rpx;
}
.action:active {
  background-color: #f6f6f6;
  border-radius: 12rpx;
}
.icon {
  width: 42rpx;
  height: 42rpx;
  margin-bottom: 6rpx;
}
.label {
  font-size: 22rpx;
}

.main-btn {
  flex-shrink: 0;
  width: 340rpx;
  height: 88rpx;
  border-radius: 44rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 30rpx;
  font-weight: 500;
  transition: all 0.2s;
}
.main-btn:active {
  background-color: #e6f0ff;
  border-color: #FF2F31;
  color: #FF2F31;
}

/* 内部内容居中控制 */
.btn-content {
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-content .icon {
  width: 38rpx;
  height: 38rpx;
  margin-right: 10rpx;
}
.btn-content .label {
  font-size: 28rpx;
  color: #FF2F31;
}
</style>
