s-live-card.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <view>
  3. <!-- md卡片:竖向,一行放两个,图上内容下 -->
  4. <view v-if="size === 'md'" class="md-goods-card ss-flex-col" :style="[elStyles]" @tap="onClick">
  5. <view class="icon-box ss-flex">
  6. <image class="icon" :src="state.liveStatus[data.status].img"></image>
  7. <view class="title ss-m-l-16">{{ state.liveStatus[data.status].title }}</view>
  8. </view>
  9. <image class="md-img-box" :src="sheep.$url.cdn(data.feeds_img)" mode="aspectFill"></image>
  10. <view class="md-goods-content">
  11. <view class="md-goods-title ss-line-1" :style="[{ color: titleColor }]">
  12. {{ data.name }}
  13. </view>
  14. <view class="md-goods-subtitle ss-m-t-20 ss-line-1" :style="[{ color: subTitleColor }]">
  15. 主播:{{ data.anchor_name }}
  16. </view>
  17. </view>
  18. </view>
  19. <!-- sl卡片:竖向型,一行放一个,图片上内容下边 -->
  20. <view v-if="size === 'sl'" class="sl-goods-card ss-flex-col" :style="[elStyles]" @tap="onClick">
  21. <view class="icon-box ss-flex">
  22. <image class="icon" :src="state.liveStatus[data.status].img"></image>
  23. <view class="title ss-m-l-16">{{ state.liveStatus[data.status].title }}</view>
  24. </view>
  25. <image class="sl-img-box" :src="sheep.$url.cdn(data.feeds_img)" mode="aspectFill"></image>
  26. <view class="sl-goods-content">
  27. <view class="sl-goods-title ss-line-1" :style="[{ color: titleColor }]">
  28. {{ data.name }}
  29. </view>
  30. <view class="sl-goods-subtitle ss-m-t-20 ss-line-1" :style="[{ color: subTitleColor }]">
  31. 主播:{{ data.anchor_name }}
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script setup>
  38. import { computed, reactive } from 'vue';
  39. import sheep from '@/sheep';
  40. /**
  41. * 直播卡片
  42. *
  43. * @property {String} img - 图片
  44. * @property {String} title - 标题
  45. * @property {Number} titleWidth = 0 - 标题宽度,默认0,单位rpx
  46. * @property {String} skuText - 规格
  47. * @property {String | Number} score - 积分
  48. * @property {String | Number} price - 价格
  49. * @property {String | Number} originalPrice - 单购价
  50. * @property {String} priceColor - 价格颜色
  51. * @property {Number | String} num - 数量
  52. *
  53. */
  54. const props = defineProps({
  55. goodsFields: {
  56. type: [Array, Object],
  57. default() {
  58. return {};
  59. },
  60. },
  61. tagStyle: {
  62. type: Object,
  63. default: {},
  64. },
  65. data: {
  66. type: Object,
  67. default: {},
  68. },
  69. size: {
  70. type: String,
  71. default: 'sl',
  72. },
  73. background: {
  74. type: String,
  75. default: '',
  76. },
  77. topRadius: {
  78. type: Number,
  79. default: 0,
  80. },
  81. bottomRadius: {
  82. type: Number,
  83. default: 0,
  84. },
  85. titleColor: {
  86. type: String,
  87. default: '#333',
  88. },
  89. subTitleColor: {
  90. type: String,
  91. default: '#999999',
  92. },
  93. });
  94. // 组件样式
  95. const elStyles = computed(() => {
  96. return {
  97. background: props.background,
  98. 'border-top-left-radius': props.topRadius + 'px',
  99. 'border-top-right-radius': props.topRadius + 'px',
  100. 'border-bottom-left-radius': props.bottomRadius + 'px',
  101. 'border-bottom-right-radius': props.bottomRadius + 'px',
  102. };
  103. });
  104. const state = reactive({
  105. liveStatus: {
  106. 101: {
  107. img: sheep.$url.static('/static/img/shop/app/mplive/living.png'),
  108. title: '直播中',
  109. },
  110. 102: {
  111. img: sheep.$url.static('/static/img/shop/app/mplive/start.png'),
  112. title: '未开始',
  113. },
  114. 103: {
  115. img: sheep.$url.static('/static/img/shop/app/mplive/ended.png'),
  116. title: '已结束',
  117. },
  118. },
  119. });
  120. const emits = defineEmits(['click', 'getHeight']);
  121. const onClick = () => {
  122. emits('click');
  123. };
  124. </script>
  125. <style lang="scss" scoped>
  126. // md
  127. .md-goods-card {
  128. overflow: hidden;
  129. width: 100%;
  130. height: 424rpx;
  131. position: relative;
  132. z-index: 1;
  133. background-color: $white;
  134. .icon-box {
  135. position: absolute;
  136. left: 20rpx;
  137. top: 10rpx;
  138. width: 136rpx;
  139. height: 40rpx;
  140. background: #000000;
  141. opacity: 0.5;
  142. border-radius: 20rpx;
  143. .icon {
  144. width: 40rpx;
  145. height: 40rpx;
  146. border-radius: 20rpx 0px 20rpx 20rpx;
  147. }
  148. .title {
  149. font-size: 24rpx;
  150. font-weight: 500;
  151. color: #ffffff;
  152. }
  153. }
  154. .md-goods-content {
  155. position: absolute;
  156. left: 20rpx;
  157. bottom: 20rpx;
  158. }
  159. .md-img-box {
  160. width: 100%;
  161. height: 100%;
  162. }
  163. .md-goods-title {
  164. font-size: 26rpx;
  165. color: #333;
  166. width: 100%;
  167. }
  168. .md-goods-subtitle {
  169. font-size: 24rpx;
  170. font-weight: 400;
  171. color: #999999;
  172. }
  173. }
  174. .sl-goods-card {
  175. overflow: hidden;
  176. position: relative;
  177. z-index: 1;
  178. width: 100%;
  179. height: 400rpx;
  180. background-color: $white;
  181. .icon-box {
  182. position: absolute;
  183. left: 20rpx;
  184. top: 10rpx;
  185. width: 136rpx;
  186. height: 40rpx;
  187. background: #000000;
  188. opacity: 0.5;
  189. border-radius: 20rpx;
  190. .icon {
  191. width: 40rpx;
  192. height: 40rpx;
  193. border-radius: 20rpx 0px 20rpx 20rpx;
  194. }
  195. .title {
  196. font-size: 24rpx;
  197. font-weight: 500;
  198. color: #ffffff;
  199. }
  200. }
  201. .sl-goods-content {
  202. position: absolute;
  203. left: 20rpx;
  204. bottom: 20rpx;
  205. }
  206. .sl-img-box {
  207. width: 100%;
  208. height: 100%;
  209. }
  210. .sl-goods-title {
  211. font-size: 26rpx;
  212. color: #333;
  213. width: 100%;
  214. }
  215. .sl-goods-subtitle {
  216. font-size: 24rpx;
  217. font-weight: 400;
  218. color: #999999;
  219. }
  220. }
  221. </style>