item.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <div class="live-box">
  3. <div class="live-ongoing" v-if="liveData.live_status === 101 || isOn">
  4. <img class="cover-img" :src="liveData.cover_img" />
  5. <div class="status">
  6. <div class="status-state">
  7. <img class="img" src="../../../static/images/live/icon-live-num.png" />直播中</div>
  8. <div class="status-num">1000人</div>
  9. </div>
  10. <div class="user">
  11. <div class="user-pic">
  12. <img class="img" src="../../../static/images/live/huabei.png" />
  13. </div>
  14. <view class="user-name">{{ liveData.anchor_name }}</view>
  15. </div>
  16. <div class="products">
  17. <div class="uni-padding-wrap">
  18. <div class="page-section swiper">
  19. <div class="page-section-spacing">
  20. <el-carousel height="34px" direction="vertical" indicator-position="none">
  21. <el-carousel-item v-for="item in liveData.goods" :key="item.goods_id">
  22. <h3 class="medium">{{ item.name }}</h3>
  23. </el-carousel-item>
  24. </el-carousel>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </div>
  30. <div class="live-other" v-else>
  31. <img class="cover-img" :src="liveData.cover_img" />
  32. <div class="user">
  33. <div class="user-pic"><img class="img" src="../../../static/images/live/huabei.png" /></div>
  34. <div class="user-name">{{ liveData.anchor_name }}</div>
  35. </div>
  36. <div class="count-down">
  37. <div class="text">开播倒计时</div>
  38. <div class="time">
  39. <div class="time-item dots">{{times[0]}}</div>
  40. <div class="time-item dots">{{times[1]}}</div>
  41. <div class="time-item">{{times[2]}}</div>
  42. </div>
  43. </div>
  44. <div class="btn-subscribe">立即预约</div>
  45. <!-- <view class="btn-subscribe subscribed">已预约</view>-->
  46. </div>
  47. </div>
  48. </template>
  49. <script>
  50. export default {
  51. props: {
  52. liveData: {
  53. type: Object,
  54. default: () => ({
  55. name: '',
  56. cover_img: ''
  57. })
  58. }
  59. },
  60. data () {
  61. return {
  62. background: ['color1', 'color2', 'color3'],
  63. indicatorDots: false,
  64. autoplay: true,
  65. interval: 2000, // 自动播放间隔时长
  66. duration: 500, // 幻灯片切换时长(ms)
  67. times: [],
  68. isOn: false
  69. }
  70. },
  71. created() {
  72. this.countTime()
  73. },
  74. methods: {
  75. changeIndicatorDots(e) {
  76. this.indicatorDots = !this.indicatorDots
  77. },
  78. changeAutoplay(e) {
  79. this.autoplay = !this.autoplay
  80. },
  81. intervalChange(e) {
  82. this.interval = e.target.value
  83. },
  84. durationChange(e) {
  85. this.duration = e.target.value
  86. },
  87. countTime(){
  88. var nowtime = new Date().getTime() //获取当前时间
  89. var starttime = this.liveData.start_time * 1000
  90. if(this.liveData.live_status === 102){
  91. if(starttime > nowtime){
  92. var lefttime = starttime - nowtime //距离结束时间的毫秒数
  93. var leftd = Math.floor(lefttime/(1000*60*60)), //计算小时数
  94. leftm = Math.floor(lefttime/(1000*60)%60), //计算分钟数
  95. lefts = Math.floor(lefttime/1000%60); //计算秒数
  96. this.times = [leftd < 10?'0'+ leftd:leftd,leftm < 10?'0'+ leftm:leftm,lefts < 10?'0'+ lefts:lefts]
  97. setTimeout(() => {
  98. this.countTime()
  99. },1000)
  100. } else {
  101. this.isOn = true
  102. }
  103. }
  104. }
  105. }
  106. }
  107. </script>
  108. <style lang="scss" scoped>
  109. .live-box{
  110. position: relative;
  111. color: #fff;
  112. .cover-img{
  113. width: 100%;
  114. height: 100%;
  115. position: absolute;
  116. z-index: 0;
  117. }
  118. .user{
  119. display: flex;
  120. line-height: 60px;
  121. height: 64px;
  122. &-pic{
  123. .img{
  124. width: 60px;
  125. height: 60px;
  126. border: 2px solid rgba(255, 255, 255, 0.5019607843137255);
  127. border-radius: 50%;
  128. overflow: hidden;
  129. }
  130. }
  131. &-name{
  132. font-size: 28px;
  133. margin-left: 16px;
  134. }
  135. }
  136. .live-ongoing{
  137. width: 100%;
  138. height: 100%;
  139. position: relative;
  140. .status{
  141. position: absolute;
  142. top: 22px;
  143. left: 22px;
  144. //width: 212upx;
  145. height: 48px;
  146. background: rgba(0,0,0,0.3);
  147. border: 2px solid rgba(255,255,255,0.3);
  148. border-radius: 24px;
  149. font-size: 20px;
  150. line-height: 44px;
  151. display: flex;
  152. padding-right: 8px;
  153. &-state{
  154. width: 118px;
  155. height: 44px;
  156. background: linear-gradient(90deg, #C83732 0%, #E25C44 100%);
  157. opacity: 1;
  158. border-radius: 26px;
  159. display: flex;
  160. align-items: center;
  161. justify-content: center;
  162. .img{
  163. width: 20px;
  164. height: 20px;
  165. margin-right: 6px;
  166. }
  167. }
  168. &-num{
  169. min-width: 80px;
  170. padding: 0 8px;
  171. }
  172. }
  173. .user{
  174. position: absolute;
  175. bottom: 62px;
  176. left: 20px;
  177. }
  178. .products{
  179. position: absolute;
  180. left: 0px;
  181. bottom: 20px;
  182. width: 100%;
  183. padding:0 20px;
  184. .swiper{
  185. height: 34px;
  186. line-height: 34px;
  187. font-size: 24px;
  188. overflow: hidden;
  189. text-overflow:ellipsis;
  190. white-space: nowrap;
  191. }
  192. }
  193. }
  194. .live-other{
  195. position: relative;
  196. height: 100%;
  197. display: flex;
  198. align-items: center;
  199. justify-content: center;
  200. .cover-img{
  201. filter:blur(20px);
  202. -webkit-filter:blur(20px);
  203. -moz-filter:blur(20px);
  204. -ms-filter:blur(20px);
  205. -o-filter:blur(20px);
  206. }
  207. .user{
  208. position: absolute;
  209. top: 20px;
  210. left: 20px;
  211. }
  212. .count-down{
  213. position: relative;
  214. .text{
  215. font-size: 26px;
  216. line-height: 36px;
  217. margin-bottom: 16px;
  218. opacity: 0.5;
  219. text-align: center;
  220. }
  221. .time{
  222. display: flex;
  223. &-item{
  224. min-width: 52px;
  225. padding: 0 5px;
  226. height: 52px;
  227. line-height: 52px;
  228. background: #FFFFFF;
  229. opacity: 1;
  230. border-radius: 4px;
  231. font-size: 26px;
  232. color: #C83732;
  233. text-align: center;
  234. &.dots{
  235. margin-right: 22px;
  236. position: relative;
  237. &:before,&:after{
  238. content:'';
  239. width: 6px;
  240. height: 6px;
  241. background: #FFFFFF;
  242. position: absolute;
  243. right: -14px;
  244. }
  245. &:before{
  246. top: 14px;
  247. }
  248. &:after{
  249. bottom: 14px;
  250. }
  251. }
  252. }
  253. }
  254. }
  255. .btn-subscribe{
  256. width: 200px;
  257. height: 64px;
  258. line-height: 64px;
  259. background: linear-gradient(90deg, #C83732 0%, #E25C44 100%);
  260. box-shadow: 0rpx 6px 12px rgba(233, 0, 0, 0.3);
  261. opacity: 1;
  262. border-radius: 8px;
  263. color: #fff;
  264. font-size: 24px;
  265. text-align: center;
  266. position: absolute;
  267. bottom: 60px;
  268. left: 50%;
  269. margin-left: -100px;
  270. &.subscribed{
  271. background: #FFFFFF;
  272. color: #999999;
  273. box-shadow: none;
  274. }
  275. }
  276. }
  277. }
  278. </style>