living.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <view class="content">
  3. <u-empty v-if="list.length == 0" text="暂无直播" mode="list"></u-empty>
  4. <view class="main-item" v-for="(item, index) in list" v-else @click="navTo(item)">
  5. <view class="type">
  6. {{ item.live_status == 101 ? '直播中' : item.live_status == 102 ? '未开始' : item.live_status == 103 ? '已结束' : '' }}
  7. </view>
  8. <view class="main-image">
  9. <image :src="item.cover_img" mode=""></image>
  10. </view>
  11. <view class="info flex">
  12. <view class="info-left">
  13. <view class="main-title">{{ item.name }}</view>
  14. <view class="main-time">{{ item.add_time }}开播</view>
  15. </view>
  16. <!-- <view class="info-right" @click.stop="shareLink(item)">分享</view> -->
  17. <button class="info-right" open-type="share" @click.stop="shareLink(item)">分享</button>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. import {
  24. getZbList
  25. } from '@/api/index.js'
  26. import {
  27. short_link
  28. } from '@/api/activity.js';
  29. import {
  30. getTime
  31. } from '@/utils/rocessor.js';
  32. import uniCopy from '@/js_sdk/xb-copy/uni-copy.js';
  33. export default {
  34. // #ifdef MP
  35. onShareAppMessage: function(res) {
  36. console.log(this.share);
  37. if (res.from === 'button') {
  38. // 来自页面内分享按钮
  39. let pages = getCurrentPages();
  40. // 获取当前页面
  41. let page = pages[pages.length - 1];
  42. let path = '/' + page.route + '?';
  43. // 保存传值
  44. for (let i in page.options) {
  45. path += i + '=' + page.options[i] + '&';
  46. }
  47. // 保存邀请人
  48. let data = {
  49. path: path,
  50. imageUrl: this.share.cover_img,
  51. title: this.share.name
  52. };
  53. console.log('data', data);
  54. return data;
  55. }
  56. },
  57. // #endif
  58. data() {
  59. return {
  60. list: [],
  61. shareShow: false,
  62. share: ''
  63. };
  64. },
  65. onLoad() {
  66. this.loadData();
  67. },
  68. onShow() {},
  69. onReachBottom() {},
  70. onReady() {},
  71. methods: {
  72. loadData() {
  73. getZbList({
  74. page: 1,
  75. limit: 50
  76. }).then(({
  77. data
  78. }) => {
  79. data.forEach(e => {
  80. e.add_time = getTime(e.start_time);
  81. });
  82. this.list = data;
  83. console.log(data);
  84. });
  85. },
  86. shareLink(item) {
  87. console.log('dainjideniang');
  88. this.share = item;
  89. },
  90. copy() {
  91. short_link({
  92. url: 'pages/user/living'
  93. }).then(({
  94. data
  95. }) => {
  96. console.log(data);
  97. this.comfirm(data.link);
  98. });
  99. },
  100. comfirm(text) {
  101. console.log(text);
  102. const result = uniCopy(text);
  103. if (result === false) {
  104. uni.showToast({
  105. title: '不支持'
  106. });
  107. } else {
  108. uni.showToast({
  109. title: '复制成功',
  110. icon: 'none'
  111. });
  112. }
  113. },
  114. //取消分享
  115. cancel() {
  116. this.shareShow = false;
  117. },
  118. navTo(opt) {
  119. let roomId = opt.roomid;
  120. let customParams = encodeURIComponent(JSON.stringify({
  121. path: 'pages/index/index',
  122. pid: 1
  123. }));
  124. uni.navigateTo({
  125. url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${roomId}&custom_params=${customParams}`
  126. });
  127. }
  128. }
  129. };
  130. </script>
  131. <style lang="scss">
  132. page,
  133. .content {
  134. min-height: 100%;
  135. height: auto;
  136. }
  137. .main-item {
  138. margin: 20rpx auto 0;
  139. width: 690rpx;
  140. background: #ffffff;
  141. border-radius: 30rpx;
  142. position: relative;
  143. image {
  144. width: 100%;
  145. height: 100%;
  146. }
  147. .type {
  148. top: 50rpx;
  149. left: 50rpx;
  150. position: absolute;
  151. z-index: 2;
  152. border-radius: 50rpx;
  153. width: 100rpx;
  154. height: 50rpx;
  155. display: flex;
  156. justify-content: center;
  157. align-items: center;
  158. background: #7f7f7f;
  159. color: #ffffff;
  160. }
  161. .main-image {
  162. width: 100%;
  163. height: 500rpx;
  164. }
  165. .info {
  166. padding: 10rpx 10rpx 20rpx;
  167. justify-content: space-between;
  168. .info-left {
  169. line-height: 1;
  170. .main-title {
  171. font-size: 28rpx;
  172. font-family: PingFang SC;
  173. font-weight: 500;
  174. color: #333333;
  175. }
  176. .main-time {
  177. margin-top: 8rpx;
  178. font-size: 24rpx;
  179. font-family: PingFang SC;
  180. font-weight: 500;
  181. color: #666666;
  182. }
  183. }
  184. .info-right {
  185. margin: 0;
  186. &::after {
  187. border: none;
  188. }
  189. padding: 0;
  190. border-radius: 50rpx;
  191. width: 100rpx;
  192. height: 50rpx;
  193. display: flex;
  194. justify-content: center;
  195. align-items: center;
  196. color: #e56969;
  197. background-color: #fff;
  198. border: 1px solid #e56969;
  199. font-size: $font-lg;
  200. }
  201. }
  202. }
  203. .Shraremask {
  204. position: fixed;
  205. left: 0;
  206. top: 0;
  207. right: 0;
  208. bottom: 0;
  209. display: flex;
  210. justify-content: center;
  211. align-items: flex-end;
  212. z-index: 998;
  213. transition: 0.3s;
  214. background-color: rgba(51, 51, 51, 0.6);
  215. .bottomButtom {
  216. position: absolute;
  217. left: 0;
  218. bottom: 0;
  219. display: flex;
  220. justify-content: center;
  221. align-items: center;
  222. width: 100%;
  223. height: 90rpx;
  224. background: #fff;
  225. z-index: 9;
  226. font-size: $font-base + 2rpx;
  227. color: $font-color-dark;
  228. }
  229. }
  230. .mask-content {
  231. margin-bottom: 88rpx;
  232. width: 100%;
  233. height: 380rpx;
  234. transition: 0.3s;
  235. background: #fff;
  236. &.has-bottom {
  237. padding-bottom: 90rpx;
  238. }
  239. .view-content {
  240. height: 100%;
  241. }
  242. }
  243. .share-header {
  244. height: 110rpx;
  245. font-size: $font-base + 2rpx;
  246. color: font-color-dark;
  247. display: flex;
  248. align-items: center;
  249. justify-content: center;
  250. padding-top: 10rpx;
  251. &:before,
  252. &:after {
  253. content: '';
  254. width: 240rpx;
  255. height: 0;
  256. border-top: 1px solid $border-color-base;
  257. transform: scaleY(0.5);
  258. margin-right: 30rpx;
  259. }
  260. &:after {
  261. margin-left: 30rpx;
  262. margin-right: 0;
  263. }
  264. }
  265. .share-list {
  266. display: flex;
  267. width: 80%;
  268. margin: 0rpx auto;
  269. }
  270. .share-item {
  271. min-width: 33.33%;
  272. display: flex;
  273. justify-content: center;
  274. align-items: center;
  275. height: 180rpx;
  276. width: 100%;
  277. }
  278. .wechat-box {
  279. width: 100rpx;
  280. height: 50rpx;
  281. padding: 0;
  282. font-size: $font-sm;
  283. background: #ffffff;
  284. display: flex;
  285. justify-content: center;
  286. align-items: center;
  287. border-radius: 25rpx;
  288. border: 1px solid #f75022;
  289. color: #f75022;
  290. &::after {
  291. border: none;
  292. }
  293. }
  294. </style>