index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <div style="width: 100%;height: 100%;">
  3. <!-- 积分秒杀提示 -->
  4. <div :class="{'label-tip-box': true, 'blue-label-tip-box': custTypeId === 1, 'green-label-tip-box': custTypeId === 2}">
  5. <div class="label-tip">{{labelTip}}</div>
  6. </div>
  7. <!-- 图片遮罩 使用遮罩时要在其父元素设置相对定位 -->
  8. <div class="imgBox" :style="{'background-image': 'url('+ imgUrl +')'}" v-if="imgUrl && imgUrl.length > 0 && isShow"></div>
  9. </div>
  10. </template>
  11. <script>
  12. import { mapState } from 'vuex'
  13. import sellOut from '@/pages/pointsMall/static/images/sellOut.png'
  14. import toSell from '@/pages/pointsMall/static/images/toSell.png'
  15. export default {
  16. props: {
  17. labelTip: {
  18. type: String,
  19. default: ''
  20. },
  21. // 是否即将售卖
  22. isComingSoon: {
  23. type: [String, Number],
  24. default: ''
  25. },
  26. // 是否已售罄
  27. batchAvailableNum: {
  28. type: [String, Number, Boolean],
  29. default: ''
  30. }
  31. },
  32. computed: {
  33. ...mapState({
  34. custTypeId: state => state.custTypeId
  35. }),
  36. imgUrl() { // 通过条件来改变遮罩图
  37. var url = 'https://cnsh-kerry-crm-le.oss-cn-shanghai.aliyuncs.com/shopService/info/sellOut.png'
  38. if (this.isComingSoon == '1') {
  39. url = 'https://cnsh-kerry-crm-le.oss-cn-shanghai.aliyuncs.com/shopService/info/toSell.png'
  40. }
  41. return url
  42. },
  43. isShow() {
  44. return (this.isComingSoon && this.isComingSoon == '1') || this.batchAvailableNum && this.batchAvailableNum == '0'
  45. }
  46. }
  47. }
  48. </script>
  49. <style lang="less" scoped>
  50. @import '../../styles/common.less';
  51. .blue-label-tip-box {
  52. .color-label-tip-box('blue');
  53. }
  54. .green-label-tip-box {
  55. .color-label-tip-box('green');
  56. }
  57. .color-label-tip-box(@value) {
  58. @color: 'color-@{value}';
  59. position: relative;
  60. z-index: 10;
  61. .label-tip {
  62. width:112px;
  63. height: 0;
  64. border-left:50px solid transparent;
  65. border-right:50px solid transparent;
  66. border-bottom:50px solid @@color;
  67. position: absolute;
  68. top: 28px;
  69. left: -48px;
  70. font-size: 26px;
  71. letter-spacing: 2px;
  72. color: #C7B299;
  73. text-align: center;
  74. line-height: 50px;
  75. transform: rotate(-45deg);
  76. }
  77. }
  78. .imgBox {
  79. width: 100%;
  80. height: 100%;
  81. z-index: 20;
  82. position: absolute;
  83. background-repeat: no-repeat;
  84. background-position: 0 0px;
  85. background-size: 100% 100%;
  86. }
  87. </style>