shareLive.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <view>
  3. <!-- 订单列表 -->
  4. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption"
  5. :up="upOption">
  6. <view class="live-list">
  7. <view v-for="(item,index) in dataList" :key="index" class="item">
  8. <view class="bottom-box">
  9. <view class="left">
  10. <image class="img" v-if="item.liveImgUrl" :src="item.liveImgUrl"></image>
  11. <text class="ml30 label">{{item.liveName}}</text>
  12. </view>
  13. <view class="btn-box">
  14. <!-- <view class="btn pay" @click.stop="showDetail(item)">
  15. 分享直播间
  16. </view> -->
  17. <button open-type="share" class="button" :data-item="JSON.stringify(item)"
  18. @click="setShareItem($event)">
  19. 分享
  20. </button>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </mescroll-body>
  26. </view>
  27. </template>
  28. <script>
  29. import {
  30. liveShareList
  31. } from '@/api/living.js'
  32. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  33. export default {
  34. mixins: [MescrollMixin],
  35. data() {
  36. return {
  37. userinfo: {},
  38. currentShareItem: null,
  39. // searchKey: "",
  40. mescroll: null,
  41. // 上拉加载的配置
  42. upOption: {
  43. onScroll: true,
  44. use: true, // 是否启用上拉加载; 默认true
  45. page: {
  46. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  47. size: 10 // 每页数据的数量,默认10
  48. },
  49. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  50. empty: {
  51. icon: '/static/images/no_data.png',
  52. tip: '暂无数据'
  53. }
  54. },
  55. companyId: null,
  56. companyUserId:null,
  57. // 列表数据
  58. dataList: [],
  59. };
  60. },
  61. onLoad(options) {
  62. console.log("分享直播间options",options)
  63. var that = this;
  64. // uni.$on('refreshOrder', () => {
  65. that.mescroll.resetUpScroll()
  66. // })
  67. this.companyId = options.companyId;
  68. this.companyUserId = options.companyUserId;
  69. this.userinfo = JSON.parse(uni.getStorageSync("userInfo"))
  70. },
  71. onShareAppMessage() {
  72. const item = this.currentShareItem || {};
  73. console.log("item.liveId", item.liveId)
  74. console.log("this.companyUserId", this.companyUserId)
  75. return {
  76. title: '邀请你来观看直播:' + item.liveName,
  77. path: `/pages_course/living?companyId=${this.companyId}&companyUserId=${this.companyUserId}&liveId=${item.liveId}`,
  78. // imageUrl: this.products.image,
  79. imageUrl: '/static/images/logo.png',
  80. success(res) {
  81. console.log("分享成功", res);
  82. },
  83. fail(err) {
  84. console.error("分享失败", err);
  85. }
  86. };
  87. },
  88. methods: { // 记录当前要分享的item
  89. setShareItem(e) {
  90. // 从事件对象的currentTarget.dataset中获取item(需解析JSON)
  91. const itemStr = e.currentTarget.dataset.item;
  92. this.currentShareItem = JSON.parse(itemStr);
  93. },
  94. // goSearch(e) {
  95. // this.searchKey = e.detail.value;
  96. // this.mescroll.resetUpScroll()
  97. // },
  98. mescrollInit(mescroll) {
  99. this.mescroll = mescroll;
  100. },
  101. /*下拉刷新的回调 */
  102. downCallback(mescroll) {
  103. mescroll.resetUpScroll()
  104. },
  105. upCallback(page) {
  106. //联网加载数据
  107. var that = this;
  108. if(!this.companyId) return;
  109. // var data = {
  110. // pageNum: page.num,
  111. // pageSize: page.size,
  112. // };
  113. liveShareList(this.companyId,page.size,page.num).then(res => {
  114. if (res.code == 200) {
  115. //设置列表数据
  116. if (page.num == 1) {
  117. that.dataList = res.data.list;
  118. } else {
  119. that.dataList = that.dataList.concat(res.data.list);
  120. }
  121. that.mescroll.endBySize(res.data.list.length, res.data.total);
  122. } else {
  123. uni.showToast({
  124. icon: 'none',
  125. title: "请求失败",
  126. });
  127. that.dataList = null;
  128. that.mescroll.endErr();
  129. }
  130. });
  131. },
  132. // showDetail(item) {
  133. // uni.navigateTo({
  134. // url: './storeOrderDetail?id=' + item.id
  135. // })
  136. // },
  137. }
  138. }
  139. </script>
  140. <style lang="scss">
  141. .search-cont {
  142. padding: 16rpx 30rpx;
  143. background-color: #FFFFFF;
  144. .inner {
  145. box-sizing: border-box;
  146. width: 100%;
  147. height: 72rpx;
  148. background: #F7F7F7;
  149. border-radius: 36rpx;
  150. display: flex;
  151. align-items: center;
  152. padding: 0 30rpx;
  153. .icon-search {
  154. width: 28rpx;
  155. height: 28rpx;
  156. margin-right: 20rpx;
  157. }
  158. input {
  159. height: 60rpx;
  160. line-height: 60rpx;
  161. flex: 1;
  162. }
  163. }
  164. }
  165. .live-list {
  166. padding: 20rpx;
  167. .item {
  168. background: #FFFFFF;
  169. border-radius: 16rpx;
  170. padding: 20rpx 30rpx;
  171. margin-bottom: 20rpx;
  172. .bottom-box {
  173. display: flex;
  174. align-items: center;
  175. justify-content: space-between;
  176. .left {
  177. display: flex;
  178. align-items: center;
  179. .img {
  180. width: 140rpx;
  181. height: 140rpx;
  182. }
  183. .label {
  184. font-size: 28rpx;
  185. font-weight: 500;
  186. color: #999999;
  187. line-height: 1;
  188. }
  189. .price-box {
  190. display: flex;
  191. align-items: flex-end;
  192. .unit {
  193. font-size: 24rpx;
  194. font-family: PingFang SC;
  195. font-weight: 500;
  196. color: #FF6633;
  197. line-height: 1.2;
  198. margin-right: 4rpx;
  199. }
  200. .num {
  201. font-size: 32rpx;
  202. font-family: PingFang SC;
  203. font-weight: bold;
  204. color: #FF6633;
  205. line-height: 1;
  206. }
  207. }
  208. }
  209. .btn-box {
  210. box-sizing: border-box;
  211. display: flex;
  212. align-items: center;
  213. button {
  214. font-size: 28rpx;
  215. color: #F7F7F7;
  216. padding: 12rpx 20rpx !important;
  217. background-color: #2BC7B9 !important;
  218. line-height: inherit !important;
  219. margin: 0 !important;
  220. width: auto !important;
  221. font-weight: 500 !important;
  222. border-radius: none !important;
  223. }
  224. }
  225. }
  226. }
  227. }
  228. </style>