ToolBox.vue 4.31 KB
<template>
  <view class="tool-box" :style="toolStyle">
    <view
      :class="['btn', {hideIcon:!show}]"
      @click="show = false"
    >
      <view class="icon sprite-icon icon-tool-file">
      </view>
      文件夹
    </view>
    <view :class="['list',{showList:!show}]">
      <view
        class="title"
        @click="show = true"
      >文件夹</view>
      <template v-for="(i,index) in data">
        <view
          :class="['item', {active: i[idKey] == id} ]"
          :key="index"
          @click="jump(i)"
        >
          <image
            class="icon"
            :src="i.shortTitleUrl"
            mode="scaleToFill"
          />
          {{i.shortTitle}}
        </view>
      </template>
      <template v-if="showPayBtn">
        <view
          class="item"
          @click="toPay"
        >
          <view class="icon">
            <view class="sprite-icon icon-tool-pay"></view>
          </view>
          付款方式
        </view>
      </template>
      <template v-if="type != 'preview'">
        <view
          class="item"
          @click="finish"
        >
          <view class="icon">
            <view class="sprite-icon icon-tool-finish"></view>
          </view>
          完成接待
        </view>
      </template>
    </view>
  </view>
</template>

<script type='text/ecmascript-6'>
export default {
  name: 'ToolBox',
  props: {
    type: String,
    data: Array,
    id: [String, Number],
    showPayBtn: Boolean,
    idKey: {
      type: String,
      default: 'id'
    },
    toolStyle:String
  },
  data () {
    return {
      show: true
    }
  },
  computed: {
    watchStatus () {
      return this.$store.state.user.historyStatus
    },
  },
  watch: {
    watchStatus: {
      immediate: true,
      handler (newval) {
        this.show = true
      }
    },
  },
  methods: {
    hide () {
      this.show = true
    },
    jump (item) {
      this.show = true
      this.$emit('choose', item)
    },
    finish () {
      this.$emit('finish')
    },
    // 选择付款方式
    toPay () {
      this.$emit('toPay')
    },

  }
}
</script>

<style scoped lang='scss'>
.tool-box {
  position: fixed;
  right: 40rpx;
  top: calc(5% + 140rpx);
  z-index: 998;
  width: 120rpx;
  .btn {
    width: 100%;
    height: 120rpx;
    background-image: linear-gradient(180deg, #ffffff 0%, #f8f9fb 100%);
    border: 2.08rpx solid #ffffff;
    box-shadow: 0 8rpx 24rpx 0 #00000033;
    border-radius: 16rpx;
    font-size: 24rpx;
    color: #292d33;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    .icon {
      width: 60rpx;
      height: 60rpx;
      margin-bottom: 8rpx;
      transition: all 0.05s;
    }
  }
  .hideIcon {
    height: 0;
    overflow: hidden;
    opacity: 0;
    .icon {
      height: 0;
      margin-bottom: 0;
    }
  }
  .list {
    width: 100%;
    border: 2rpx solid #ffffff;
    box-shadow: 0 8rpx 22rpx 0 #0000001a;
    border-radius: 16rpx;
    flex-direction: column;
    align-items: center;
    transition: all 0.05s;
    overflow: hidden;
    opacity: 0;
    position: relative;
    background: rgba(255, 255, 255, 0.6);
    visibility: hidden;
    height: 0;
    &::after {
      position: absolute;
      content: "";
      background: inherit;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      filter: blur(8rpx);
      z-index: -1;
    }
    .title {
      width: 120rpx;
      height: 56rpx;
      background: #f4f4f5;
      border: 2rpx solid #ffffff;
      border-radius: 16rpx 16rpx 0 0;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .item {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      font-size: 20rpx;
      color: #666666;
      // height: 120rpx;
      width: 100%;
      padding-top: 16rpx;
      .icon {
        width: 60rpx;
        height: 60rpx;
        margin-bottom: 8rpx;
      }
    }
    .active {
      color: #2c66f7;
    }
  }
  .showList {
    display: flex;
    opacity: 1;
    padding-bottom: 16rpx;
    animation: scale-up-top-right 0.4s;
    visibility: visible;
    height: auto;
  }
  @keyframes scale-up-top-right {
    0% {
      transform: scale(0.5);
      transform-origin: top right;
    }
    100% {
      transform: scale(1);
      transform-origin: top right;
    }
  }
}
</style>