s-live-card.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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: rgba(#000000, 0.5);
  141. border-radius: 20rpx;
  142. .icon {
  143. width: 40rpx;
  144. height: 40rpx;
  145. border-radius: 20rpx 0px 20rpx 20rpx;
  146. }
  147. .title {
  148. font-size: 24rpx;
  149. font-weight: 500;
  150. color: #ffffff;
  151. }
  152. }
  153. .md-goods-content {
  154. position: absolute;
  155. left: 20rpx;
  156. bottom: 20rpx;
  157. }
  158. .md-img-box {
  159. width: 100%;
  160. height: 100%;
  161. }
  162. .md-goods-title {
  163. font-size: 26rpx;
  164. color: #333;
  165. width: 100%;
  166. }
  167. .md-goods-subtitle {
  168. font-size: 24rpx;
  169. font-weight: 400;
  170. color: #999999;
  171. }
  172. }
  173. .sl-goods-card {
  174. overflow: hidden;
  175. position: relative;
  176. z-index: 1;
  177. width: 100%;
  178. height: 400rpx;
  179. background-color: $white;
  180. .icon-box {
  181. position: absolute;
  182. left: 20rpx;
  183. top: 10rpx;
  184. width: 136rpx;
  185. height: 40rpx;
  186. background: #000000;
  187. opacity: 0.5;
  188. border-radius: 20rpx;
  189. .icon {
  190. width: 40rpx;
  191. height: 40rpx;
  192. border-radius: 20rpx 0px 20rpx 20rpx;
  193. }
  194. .title {
  195. font-size: 24rpx;
  196. font-weight: 500;
  197. color: #ffffff;
  198. }
  199. }
  200. .sl-goods-content {
  201. position: absolute;
  202. left: 20rpx;
  203. bottom: 20rpx;
  204. }
  205. .sl-img-box {
  206. width: 100%;
  207. height: 100%;
  208. }
  209. .sl-goods-title {
  210. font-size: 26rpx;
  211. color: #333;
  212. width: 100%;
  213. }
  214. .sl-goods-subtitle {
  215. font-size: 24rpx;
  216. font-weight: 400;
  217. color: #999999;
  218. }
  219. }
  220. </style>