lightButton.vue 1.64 KB
Newer Older
朱国瑞's avatar
朱国瑞 committed
1
<template>
朱国瑞's avatar
朱国瑞 committed
2
  <div class="btn-container" :class="{'mobile':_isMobile,'pc':!_isMobile}">
朱国瑞's avatar
朱国瑞 committed
3
    <img class="btn-img" src="../assets/images/gesture/light-btn-bg.png" />
朱国瑞's avatar
朱国瑞 committed
4
    <div class="btn-text light-button-text" :class="{'len':text.length>10}">{{text}}</div>
朱国瑞's avatar
朱国瑞 committed
5 6 7 8 9
    <slot name="body"></slot>
  </div>
</template>

<script >
朱国瑞's avatar
朱国瑞 committed
10
import { isMobile } from "../common/util";
朱国瑞's avatar
朱国瑞 committed
11 12 13 14 15 16

// defineProps({
//   msg: String
// });
export default {
  data() {
朱国瑞's avatar
朱国瑞 committed
17 18 19
    return {
      _isMobile: false
    };
朱国瑞's avatar
朱国瑞 committed
20 21 22 23 24 25 26 27 28
  },
  props: ["text"],
  methods: {
    confirm() {
      this.$emit("update:confirm", { type: "confirm" });
    },
    cancel() {
      this.$emit("update:confirm", { type: "cancel" });
    }
朱国瑞's avatar
朱国瑞 committed
29 30 31
  },
  created() {
    this._isMobile = isMobile();
朱国瑞's avatar
朱国瑞 committed
32 33 34 35 36
  }
};
</script>

<style lang="scss" scoped>
朱国瑞's avatar
朱国瑞 committed
37 38 39
.btn-container {
  position: relative;
  color: #ffffff;
朱国瑞's avatar
朱国瑞 committed
40
  cursor: pointer;
朱国瑞's avatar
朱国瑞 committed
41 42 43 44 45 46 47 48
  img,
  div,
  button {
    position: absolute;
    left: 0;
    top: 0;
  }
  &.pc {
朱国瑞's avatar
朱国瑞 committed
49 50 51
    width: 218px;
    height: 38.85px;
    line-height: 38.85px;
朱国瑞's avatar
朱国瑞 committed
52
  }
朱国瑞's avatar
朱国瑞 committed
53 54 55 56 57 58 59
  &.mobile {
    width: 5.8133rem;
    height: 1.036rem;
    line-height: 1.036rem;
  }
}
.pc {
朱国瑞's avatar
朱国瑞 committed
60 61 62
  .btn-text {
    width: 100%;
    text-align: center;
朱国瑞's avatar
朱国瑞 committed
63
    font-size: 22px;
朱国瑞's avatar
朱国瑞 committed
64 65
    letter-spacing: 0.2em;
    font-weight: bold;
朱国瑞's avatar
朱国瑞 committed
66
    &.len {
朱国瑞's avatar
朱国瑞 committed
67
      font-size: 12px;
朱国瑞's avatar
朱国瑞 committed
68
    }
朱国瑞's avatar
朱国瑞 committed
69 70 71 72 73 74 75 76 77 78
  }
  .btn-img {
    width: 100%;
    height: 100%;
  }

  .light-button-text {
    letter-spacing: 0.2em;
  }
}
朱国瑞's avatar
朱国瑞 committed
79
.mobile {
朱国瑞's avatar
朱国瑞 committed
80 81 82 83 84 85
  .btn-text {
    width: 100%;
    text-align: center;
    font-size: 0.5867rem;
    letter-spacing: 0.2em;
    font-weight: bold;
朱国瑞's avatar
朱国瑞 committed
86
    &.len {
朱国瑞's avatar
朱国瑞 committed
87
      font-size: 0.32rem;
朱国瑞's avatar
朱国瑞 committed
88
    }
朱国瑞's avatar
朱国瑞 committed
89 90 91 92 93 94 95 96 97 98 99
  }
  .btn-img {
    width: 100%;
    height: 100%;
  }

  .light-button-text {
    letter-spacing: 0.2em;
  }
}
</style>