app-live.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. <template>
  2. <view v-if="value.live_list.length > 0" class="app-live" :style="{background: value.background}">
  3. <view class="live-style-1 shadow"
  4. v-if="value.style_type == 1"
  5. v-for="(item, index) in value.live_list"
  6. :key="index"
  7. @click="liveClick(item)">
  8. <view class="item">
  9. <image class="anchor-img" mode="aspectFill" :src="item.anchor_img"></image>
  10. <view class="gradient"></view>
  11. <view class="label-box">
  12. <view class="label-item"
  13. :class="{'label-item-over': item.live_status == 103,
  14. 'label-item-notice': item.live_status == 102}">
  15. <image v-if="item.live_status == 101" class="live-ing"
  16. src="/static/image/icon/liveing.png"></image>
  17. <view v-else class="round"></view>
  18. <span class="label-text">{{item.status_text}}</span>
  19. </view>
  20. <span v-if="item.live_status == 102" class="text-time">{{item.text_time}}</span>
  21. </view>
  22. <view class="user-info">
  23. <image class="avatar" mode="aspectFill" :src="item.anchor_img"></image>
  24. <span class="nickname ellipsis">{{item.anchor_name}}</span>
  25. </view>
  26. <image v-if="item.live_status === 103" class="play-icon"
  27. src="/static/image/video-play.png"></image>
  28. </view>
  29. <span class="title ellipsis">{{item.name}}</span>
  30. <view v-if="value.is_show_goods == true && item.goods.length > 0" class="goods-info">
  31. <image mode="aspectFill" class="goods-cover" :src="item.goods[0].cover_img"></image>
  32. <view class="goods-item">
  33. <span class="goods-name ellipsis">{{item.goods[0].name}}</span>
  34. <span class="goods-price">¥{{item.goods[0].price}}</span>
  35. </view>
  36. </view>
  37. </view>
  38. <view v-if="value.style_type == 2" class="wrap-box">
  39. <view class="wrap-item" v-for="(valueItem, valueIndex) in newValue" :key="valueIndex">
  40. <view class="live-style-2 shadow"
  41. v-for="(item, index) in valueItem.live_list"
  42. :key="index"
  43. @click="liveClick(item)">
  44. <view class="item">
  45. <image mode="aspectFill" class="anchor-img" :src="item.anchor_img"></image>
  46. <view class="gradient"></view>
  47. <view class="label-box">
  48. <view class="label-item"
  49. :class="{'label-item-over': item.live_status == 103,
  50. 'label-item-notice': item.live_status == 102}">
  51. <image v-if="item.live_status == 101" class="live-ing"
  52. src="/static/image/icon/liveing.png"></image>
  53. <view v-else class="round"></view>
  54. <span class="label-text">{{item.status_text}}</span>
  55. </view>
  56. <span v-if="item.live_status == 102" class="text-time">{{item.text_time}}</span>
  57. </view>
  58. <view class="user-info">
  59. <image class="avatar" mode="aspectFill" :src="item.anchor_img"></image>
  60. <span class="nickname ellipsis">{{item.anchor_name}}</span>
  61. </view>
  62. <image v-if="item.live_status === 103" class="play-icon"
  63. src="/static/image/video-play.png"></image>
  64. </view>
  65. <span class="title ellipsis">{{item.name}}</span>
  66. <view v-if="value.is_show_goods == true && item.goods.length > 0" class="goods-info">
  67. <image mode="aspectFill" class="goods-cover" :src="item.goods[0].cover_img"></image>
  68. <view class="goods-item">
  69. <span class="goods-name ellipsis">{{item.goods[0].name}}</span>
  70. <span class="goods-price">¥{{item.goods[0].price}}</span>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <view class="live-style-3 shadow"
  77. v-if="value.style_type == 3"
  78. v-for="(item, index) in value.live_list"
  79. :key="index"
  80. @click="liveClick(item)">
  81. <view class="item">
  82. <image mode="aspectFill" class="anchor-img" :src="item.anchor_img"></image>
  83. <view class="gradient"></view>
  84. <view class="label-box">
  85. <view class="label-item"
  86. :class="{'label-item-over': item.live_status == 103,
  87. 'label-item-notice': item.live_status == 102}">
  88. <image v-if="item.live_status == 101" class="live-ing"
  89. src="/static/image/icon/liveing.png"></image>
  90. <view v-else class="round"></view>
  91. <span class="label-text">{{item.status_text}}</span>
  92. </view>
  93. <span v-if="item.live_status == 102" class="text-time">{{item.text_time}}</span>
  94. </view>
  95. <image v-if="item.live_status === 103" class="play-icon"
  96. src="/static/image/video-play.png"></image>
  97. </view>
  98. <view class="item-2">
  99. <span class="title">{{item.name}}</span>
  100. <view class="user-info">
  101. <image class="avatar" mode="aspectFill" :src="item.anchor_img"></image>
  102. <span class="nickname ellipsis">{{item.anchor_name}}</span>
  103. </view>
  104. <view v-if="value.is_show_goods == true && item.goods.length > 0" class="goods-info">
  105. <view class="goods-cover">
  106. <view class="gradient"></view>
  107. <image mode="aspectFill" :src="item.goods[0].cover_img"></image>
  108. <span class="goods-price">¥{{item.goods[0].price}}</span>
  109. </view>
  110. <view class="goods-cover goods-cover-2" v-if="item.goods.length >= 2">
  111. <view class="shade"></view>
  112. <image mode="aspectFill" :src="item.goods[1].cover_img"></image>
  113. <view class="goods-count">
  114. <span class="number">{{item.goods.length}}</span>
  115. <span>宝贝</span>
  116. </view>
  117. </view>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. </template>
  123. <script>
  124. export default {
  125. name: 'app-live',
  126. components: {},
  127. props: {
  128. value: {
  129. type: Object,
  130. default: function () {
  131. return {
  132. background: '#f7f7f7',
  133. live_list: [],
  134. is_show_goods: true,
  135. number: 5,
  136. style_type: 1
  137. }
  138. }
  139. },
  140. },
  141. data() {
  142. return {}
  143. },
  144. computed: {
  145. newValue() {
  146. let self = this;
  147. let newValue = [
  148. {
  149. background: self.value.background,
  150. is_show_goods: self.value.is_show_goods,
  151. number: self.value.number,
  152. style_type: self.value.style_type,
  153. live_list: [],
  154. }, {
  155. background: self.value.background,
  156. is_show_goods: self.value.is_show_goods,
  157. number: self.value.number,
  158. style_type: self.value.style_type,
  159. live_list: [],
  160. },
  161. ];
  162. let number1 = 0;
  163. let number2 = 0;
  164. self.value.live_list.forEach((item, index) => {
  165. let sign = item.goods.length > 0 ? true : false;
  166. if (number1 == 0 || number1 <= number2) {
  167. number1 = sign ? number1 + 2 : number1 + 1;
  168. newValue[0].live_list.push(item);
  169. } else {
  170. number2 = sign ? number2 + 2 : number2 + 1;
  171. newValue[1].live_list.push(item);
  172. }
  173. });
  174. return newValue;
  175. }
  176. },
  177. mounted() {
  178. console.log(this.newValue);
  179. },
  180. methods: {
  181. liveClick(liveData) {
  182. let self = this;
  183. if (liveData.live_status === 101 || liveData.live_status === 102) {
  184. uni.navigateTo({
  185. url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${liveData.roomid}`
  186. })
  187. } else if (liveData.live_status === 103) {
  188. uni.setStorage({
  189. key: "live_playback",
  190. data: {
  191. room_info: liveData
  192. }
  193. });
  194. uni.navigateTo({
  195. url: `/pages/live/playback?room_id=${liveData.roomid}`
  196. })
  197. }
  198. }
  199. }
  200. }
  201. </script>
  202. <style scoped lang="scss">
  203. .app-live {
  204. padding: 20#{rpx};
  205. .shadow {
  206. box-shadow: 0 0 10#{rpx} 5#{rpx} rgba(0, 0, 0, 0.1);
  207. }
  208. .label-item {
  209. border-top-left-radius:16#{rpx};
  210. border-top-right-radius: 30#{rpx};
  211. border-bottom-right-radius: 30#{rpx};
  212. background: #ff4544;
  213. padding: 12#{rpx} 20#{rpx};
  214. display: flex;
  215. align-items: center;
  216. }
  217. .label-item-over {
  218. background: #777777;
  219. }
  220. .label-item-notice {
  221. background: #22ac38;
  222. }
  223. .round {
  224. width: 12#{rpx};
  225. height: 12#{rpx};
  226. background: #ffffff;
  227. border-radius: 50%;
  228. }
  229. .live-ing {
  230. width: 24#{rpx};
  231. height: 24#{rpx};
  232. }
  233. .label-text {
  234. margin-left: 12#{rpx};
  235. color: #ffffff;
  236. font-size: 26#{rpx};
  237. }
  238. .label-box {
  239. position: absolute;
  240. top: 0;
  241. left: 0;
  242. border-top-left-radius: 16#{rpx};
  243. border-top-right-radius: 30#{rpx};
  244. border-bottom-right-radius: 30#{rpx};
  245. background: rgba(0, 0, 0, 0.5);
  246. display: flex;
  247. align-items: center;
  248. z-index: 20;
  249. }
  250. .ellipsis {
  251. overflow: hidden;
  252. text-overflow: ellipsis;
  253. white-space: nowrap;
  254. }
  255. .play-icon {
  256. width: 100#{rpx};
  257. height: 100#{rpx};
  258. z-index: 20;
  259. }
  260. .user-info {
  261. display: flex;
  262. align-items: center;
  263. z-index: 20;
  264. .avatar {
  265. width: 40#{rpx};
  266. height: 40#{rpx};
  267. border-radius: 50%;
  268. }
  269. .nickname {
  270. color: #ffffff;
  271. font-size: 24#{rpx};
  272. margin-left: 12#{rpx};
  273. width: 578#{rpx};
  274. }
  275. }
  276. .text-time {
  277. color: #ffffff;
  278. font-size: 24#{rpx};
  279. margin: 0 20#{rpx} 0 12#{rpx};
  280. }
  281. .shade {
  282. width: 100%;
  283. height: 100%;
  284. background: rgba(0, 0, 0, 0.3);
  285. position: absolute;
  286. z-index: 10;
  287. }
  288. .gradient {
  289. width: 100%;
  290. height: 100%;
  291. position: absolute;
  292. top: 0;
  293. left: 0;
  294. background-image: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.5));
  295. }
  296. /*样式一*/
  297. .live-style-1 {
  298. width: 100%;
  299. border-radius: 16#{rpx};
  300. background: #ffffff;
  301. padding: 20#{rpx};
  302. margin-bottom: 20#{rpx};
  303. display: flex;
  304. flex-direction: column;
  305. .item {
  306. width: 100%;
  307. height: 360#{rpx};
  308. border-radius: 16#{rpx};
  309. position: relative;
  310. overflow: hidden;
  311. .anchor-img {
  312. position: absolute;
  313. left: 0;
  314. top: 0;
  315. width: 100%;
  316. height: 100%;
  317. }
  318. .user-info {
  319. position: absolute;
  320. bottom: 0;
  321. left: 0;
  322. margin-left: 20#{rpx};
  323. margin-bottom: 20#{rpx};
  324. }
  325. .play-icon {
  326. position: absolute;
  327. top: 130#{rpx};
  328. left: 285#{rpx};
  329. }
  330. }
  331. .title {
  332. font-size: 32#{rpx};
  333. color: #353535;
  334. width: 654#{rpx};
  335. margin: 28#{rpx} 0 20#{rpx};
  336. }
  337. .goods-info {
  338. width: 100%;
  339. border-radius: 8#{rpx};
  340. padding: 10#{rpx};
  341. display: flex;
  342. background: #f7f7f7;
  343. .goods-cover {
  344. width: 80#{rpx};
  345. height: 80#{rpx};
  346. border-radius: 8#{rpx};
  347. }
  348. .goods-item {
  349. display: flex;
  350. flex-direction: column;
  351. margin-left: 16#{rpx};
  352. .goods-name {
  353. font-size: 26#{rpx};
  354. color: #666666;
  355. width: 540#{rpx};
  356. }
  357. .goods-price {
  358. font-size: 26#{rpx};
  359. color: #353535;
  360. margin-top: 16#{rpx};
  361. }
  362. }
  363. }
  364. }
  365. .live-style-1:last-child {
  366. margin-bottom: 0;
  367. }
  368. /*样式二*/
  369. .wrap-box {
  370. width: 100%;
  371. display: flex;
  372. justify-content: space-between;
  373. .wrap-item {
  374. display: flex;
  375. flex-direction: column;
  376. .live-style-2 {
  377. background: #ffffff;
  378. border-radius: 16#{rpx};
  379. overflow: hidden;
  380. margin-bottom: 20#{rpx};
  381. width: 100%;
  382. display: flex;
  383. flex-direction: column;
  384. .item {
  385. width: 346#{rpx};
  386. height: 346#{rpx};
  387. position: relative;
  388. border-radius: 16#{rpx};
  389. .anchor-img {
  390. position: absolute;
  391. width: 100%;
  392. height: 100%;
  393. top: 0;
  394. left: 0;
  395. }
  396. .user-info {
  397. position: absolute;
  398. bottom: 20#{rpx};
  399. left: 20#{rpx};
  400. .nickname {
  401. width: 254#{rpx};
  402. }
  403. }
  404. .play-icon {
  405. position: absolute;
  406. top: 123#{rpx};
  407. left: 123#{rpx};
  408. }
  409. }
  410. .title {
  411. font-size: 28#{rpx};
  412. color: #353535;
  413. width: 290#{rpx};
  414. margin: 28#{rpx};
  415. }
  416. .goods-info {
  417. width: 100%;
  418. display: flex;
  419. margin: 0 28#{rpx} 28#{rpx};
  420. .goods-cover {
  421. width: 80#{rpx};
  422. height: 80#{rpx};
  423. border-radius: 8#{rpx};
  424. }
  425. .goods-item {
  426. display: flex;
  427. flex-direction: column;
  428. margin-left: 16#{rpx};
  429. .goods-name {
  430. font-size: 26#{rpx};
  431. color: #666666;
  432. width: 194#{rpx};
  433. }
  434. .goods-price {
  435. font-size: 26#{rpx};
  436. color: #353535;
  437. margin-top: 16#{rpx};
  438. }
  439. }
  440. }
  441. }
  442. .live-style-2:last-child {
  443. margin-bottom: 0;
  444. }
  445. }
  446. }
  447. /*样式三*/
  448. .live-style-3 {
  449. width: 100%;
  450. background: #ffffff;
  451. border-radius: 16#{rpx};
  452. overflow: hidden;
  453. display: flex;
  454. margin-bottom: 20#{rpx};
  455. .item {
  456. border-radius: 16#{rpx};
  457. width: 360#{rpx};
  458. height: 360#{rpx};
  459. position: relative;
  460. .anchor-img {
  461. width: 100%;
  462. height:100%;
  463. position: absolute;
  464. top: 0;
  465. left: 0;
  466. }
  467. .play-icon {
  468. position: absolute;
  469. top: 123#{rpx};
  470. left: 123#{rpx};
  471. }
  472. }
  473. .item-2 {
  474. display: flex;
  475. flex-direction: column;
  476. padding: 20#{rpx};
  477. .title {
  478. width: 310#{rpx};
  479. height: 88#{rpx};
  480. overflow: hidden;
  481. text-overflow: ellipsis;
  482. display: -webkit-box;
  483. -webkit-box-orient: vertical;
  484. -webkit-line-clamp: 2;
  485. line-clamp: 2;
  486. }
  487. .user-info {
  488. margin: 20#{rpx} 0;
  489. }
  490. .nickname {
  491. width: 258#{rpx};
  492. color: #999999;
  493. }
  494. .goods-info {
  495. display: flex;
  496. justify-content: space-between;
  497. .goods-cover {
  498. width: 148#{rpx};
  499. height: 148#{rpx};
  500. border-radius: 16#{rpx};
  501. overflow: hidden;
  502. display: flex;
  503. align-items: flex-end;
  504. justify-content: center;
  505. position: relative;
  506. image {
  507. width: 148#{rpx};
  508. height: 148#{rpx};
  509. position: absolute;
  510. top: 0;
  511. left: 0;
  512. }
  513. .goods-price {
  514. color: #ffffff;
  515. font-size: 24#{rpx};
  516. z-index: 10;
  517. margin-bottom: 10#{rpx};
  518. }
  519. }
  520. .goods-cover-2 {
  521. align-items: center;
  522. .goods-count {
  523. display: flex;
  524. flex-direction: column;
  525. color: #ffffff;
  526. font-size: 24#{rpx};
  527. z-index: 10;
  528. .number {
  529. text-align: center;
  530. }
  531. }
  532. }
  533. }
  534. }
  535. }
  536. .live-style-3:last-child {
  537. margin-bottom: 0;
  538. }
  539. }
  540. </style>