living.vue 6.2 KB

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