tm-coupon.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <view class="tm-coupon ">
  3. <view :class="[`round-${round} `]">
  4. <view :class="[disabled?'gray-100 opacity-4':'']" class="flex-start " style="height: 150rpx;">
  5. <view :class="[color_tmeme,black?'bk':'',text?'text':'',`round-r-${round} round-l-${round}`]" class=" flex-center flex-col px-24 flex-shrink fulled-height">
  6. <view v-if="!h_objData.img">
  7. <text v-show="h_objData.saleSplit" class="text-size-s">{{h_objData.saleSplit}}</text>
  8. <text class=" text-weight-b" style="font-size:60rpx;">{{h_objData.sale}}</text>
  9. <text v-show="h_objData.suffix" class="text-size-s">{{h_objData.suffix}}</text>
  10. </view>
  11. <view v-if="h_objData.img">
  12. <image style="width: 100rpx;height: 100rpx;" class="rounded" :src="h_objData.img"></image>
  13. </view>
  14. <text v-show="h_objData.saleLable" class="text-size-xs text-align-center">{{h_objData.saleLable}}</text>
  15. </view>
  16. <view :class="[color_tmeme,black?'bk':'',text?'text':'',`round-l-${round} round-r-${round}`]" class=" flex-start fulled-height fulled overflow">
  17. <view class="opacity-2" style="height: 100%;width: 0px;border-style: dashed; border-width: 0.5px;"></view>
  18. <view class="px-24 flex-between fulled" >
  19. <view class="flex-col">
  20. <text v-show="h_objData.title" class="text-size-n text-weight-b d-block">{{h_objData.title}}</text>
  21. <text v-show="h_objData.time" class="text-size-xxs d-block">{{h_objData.time}}</text>
  22. </view>
  23. <view @click="onclick" class=" flex-shrink" :class="[h_objData.title&&h_objData.time?'pl-24':'']">
  24. <view :class="[color_tmeme,black?'bk':'',text?'':'text']" class="text-size-xs d-block round-24 px-24 py-6 ">{{h_objData.btnText}}</view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="py-10 px-24 white" v-show="h_objData.label">
  30. <text class="text-size-xs d-block text-overflow-1 opacity-6">{{h_objData.label}}</text>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. /**
  37. * 优惠券
  38. * @property {String|Number} shadow = [] 默认:6,投影
  39. * @property {String|Number} round = [] 默认:4,圆角
  40. * @property {String | Boolean} text = [true|false] 默认:false,是否为文本模式,即减淡背景颜色。
  41. * @property {String | Boolean} black = [true|false] 默认:false,是否开启暗黑模式
  42. * @property {String | Boolean} disabled = [true|false] 默认:false,是否禁用(已使用)
  43. * @property {String | Boolean} hdata = [] 默认:{},数据格式见文档
  44. * @property {String} color = [] 默认:primary,主题颜色名称
  45. * @property {Function} click 整个组件点击事件,返回项目数据
  46. * @example <tm-coupon :hdata="d_1"></tm-coupon>
  47. */
  48. export default {
  49. name:"tm-coupon",
  50. props:{
  51. // 跟随主题色的改变而改变。
  52. fllowTheme:{
  53. type:Boolean|String,
  54. default:false
  55. },
  56. shadow: {
  57. type: String|Number,
  58. default: 3
  59. },
  60. round: {
  61. type: String|Number,
  62. default: 3
  63. },
  64. // 是否为文本模式,即减淡背景颜色。
  65. text: {
  66. type: String | Boolean,
  67. default: false
  68. },
  69. // 是否开启暗黑模式
  70. black: {
  71. type: String | Boolean,
  72. default: null
  73. },
  74. // 是否已经使用。
  75. disabled: {
  76. type: String | Boolean,
  77. default: false
  78. },
  79. // 主题颜色名称
  80. color: {
  81. type: String,
  82. default: 'primary'
  83. },
  84. hdata:{
  85. type:Object,
  86. default:()=>{
  87. return {}
  88. }
  89. }
  90. },
  91. computed:{
  92. black_tmeme: function() {
  93. if (this.black !== null) return this.black;
  94. return this.$tm.vx.state().tmVuetify.black;
  95. },
  96. color_tmeme:function(){
  97. if(this.$tm.vx.state().tmVuetify.color!==null&&this.$tm.vx.state().tmVuetify.color && this.fllowTheme){
  98. return this.$tm.vx.state().tmVuetify.color;
  99. }
  100. return this.color;
  101. },
  102. h_objData:function(){
  103. let ps = {
  104. img:'',//礼品图片,提供了图片,不显示数字和数字券说明。
  105. sale:'0',
  106. saleSplit:'¥',
  107. saleLable:'',
  108. title:'',
  109. time:'',
  110. btnText:'去使用',
  111. label:'',
  112. suffix:''
  113. }
  114. if(typeof this.hdata !== 'object') return ps;
  115. ps = {...ps,...this.hdata};
  116. return ps;
  117. }
  118. },
  119. data() {
  120. return {
  121. };
  122. },
  123. methods: {
  124. onclick(e) {
  125. if(this.disabled) return;
  126. this.$emit('click',this.h_objData);
  127. }
  128. },
  129. }
  130. </script>
  131. <style lang="scss">
  132. </style>