s-live-block.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <view>
  3. <view
  4. v-if="mode === 2 && state.liveList.length"
  5. class="goods-md-wrap ss-flex ss-flex-wrap ss-col-top"
  6. :style="[{ margin: '-' + data.space + 'rpx' }]"
  7. >
  8. <view
  9. :style="[
  10. {
  11. padding: data.space + 'rpx',
  12. },
  13. ]"
  14. class="goods-list-box"
  15. v-for="item in state.liveList"
  16. :key="item.id"
  17. >
  18. <s-live-card
  19. class="goods-md-box"
  20. size="md"
  21. :goodsFields="goodsFields"
  22. :data="item"
  23. :titleColor="goodsFields.name?.color"
  24. :subTitleColor="goodsFields.anchor_name?.color"
  25. :topRadius="data.borderRadiusTop"
  26. :bottomRadius="data.borderRadiusBottom"
  27. @click="goRoom(item.roomid)"
  28. >
  29. </s-live-card>
  30. </view>
  31. </view>
  32. <view v-if="mode === 1 && state.liveList.length" class="goods-lg-box">
  33. <view
  34. class="goods-box"
  35. :style="[{ marginBottom: data.space + 'px' }]"
  36. v-for="item in state.liveList"
  37. :key="item.id"
  38. >
  39. <s-live-card
  40. class="goods-card"
  41. size="sl"
  42. :goodsFields="goodsFields"
  43. :data="item"
  44. :titleColor="goodsFields.name?.color"
  45. :subTitleColor="goodsFields.anchor_name.color"
  46. :topRadius="data.borderRadiusTop"
  47. :bottomRadius="data.borderRadiusBottom"
  48. @tap="goRoom(item.roomid)"
  49. >
  50. </s-live-card>
  51. </view>
  52. </view>
  53. </view>
  54. </template>
  55. <script setup>
  56. import { reactive, onMounted } from 'vue';
  57. import sheep from '@/sheep';
  58. const state = reactive({
  59. liveList: [],
  60. });
  61. const props = defineProps({
  62. data: {
  63. type: Object,
  64. default() {},
  65. },
  66. styles: {
  67. type: Object,
  68. default() {},
  69. },
  70. });
  71. const { mode, goodsFields, mpliveIds } = props.data ?? {};
  72. const { marginLeft, marginRight } = props.styles ?? {};
  73. async function getLiveListByIds(ids) {
  74. let { data } = await sheep.$api.app.mplive.getRoomList(ids);
  75. return data;
  76. }
  77. function goRoom(id) {
  78. // wx.navigateTo({
  79. // url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${id}&custom_params=${customParams}`,
  80. // });
  81. wx.navigateTo({
  82. url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${id}`,
  83. });
  84. }
  85. onMounted(async () => {
  86. state.liveList = await getLiveListByIds(mpliveIds);
  87. console.log(state.liveList, 'state.liveList');
  88. });
  89. </script>
  90. <style lang="scss" scoped>
  91. .goods-list-box {
  92. width: 50%;
  93. flex-shrink: 0;
  94. box-sizing: border-box;
  95. overflow: hidden;
  96. }
  97. .goods-box {
  98. &:nth-last-of-type(1) {
  99. margin-bottom: 0 !important;
  100. }
  101. }
  102. .goods-md-box,
  103. .goods-sl-box {
  104. position: relative;
  105. }
  106. </style>