living.vue 6.3 KB

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