shareLive.vue 6.1 KB

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