beizhu.vue 2.06 KB
<template>
  <up-popup :show="show" mode="bottom" round="16" closeable @close="show = false" :safeAreaInsetBottom="false">
    <view class="desc-container">
      <view class="title">动作备注</view>

      <view class="input-box">
        <up-textarea
          v-model="tempNoteContent"
          placeholder="此处填写个人备注"
          autoHeight
          border="none"
          customStyle="background: #242424; padding: 20rpx; border-radius: 12rpx; color: #fff"
          placeholderStyle="color: #999"
        ></up-textarea>
      </view>

      <view class="footer">
        <view class="btn" @click="saveNoteContent">保存</view>
      </view>
    </view>
  </up-popup>
</template>

<script setup>
  import { ref } from 'vue';

  const show = ref(false);
  const tempNoteContent = ref(''); // 临时编辑的备注内容

  const emit = defineEmits(['saveSuccess']);
  // 保存备注
  const saveNoteContent = async () => {
    const content = tempNoteContent.value.trim();
    // 如果内容为空,直接返回,不提交
    if (!content) {
      uni.showToast({ title: '备注不能为空', icon: 'none' });
      return;
    }
    emit('saveSuccess', content);
    // 关闭弹窗
    show.value = false;
  };

  const open = () => {
    show.value = true;
  };

  defineExpose({ open });
</script>

<style lang="scss" scoped>
  .desc-container {
    background-color: #1a1a1a;
    padding: 40rpx 30rpx 40rpx;

    .title {
      color: #fff;
      font-size: 32rpx;
      font-weight: 500;
      text-align: center;
      margin-bottom: 40rpx;
    }

    .input-box {
      margin-bottom: 60rpx;

      /* 穿透修改 u-textarea 内部文字颜色 */
      :deep(.u-textarea__field) {
        color: #ccc !important;
      }
    }

    .footer {
      width: 100%;
      display: flex;
      justify-content: center;
      align-items: center;

      .btn {
        width: 100%;
        height: 80rpx;
        background-color: #fedc1f;
        color: #333;
        border-radius: 12rpx;
        text-align: center;
        line-height: 80rpx;
      }
    }
  }
</style>