shareLive.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. liveList
  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. // var data = {
  120. // pageNum: page.num,
  121. // pageSize: page.size,
  122. // };
  123. liveList(this.companyId,page.size,page.num).then(res => {
  124. if (res.code == 200) {
  125. //设置列表数据
  126. if (page.num == 1) {
  127. that.dataList = res.data.list;
  128. } else {
  129. that.dataList = that.dataList.concat(res.data.list);
  130. }
  131. that.mescroll.endBySize(res.data.list.length, res.data.total);
  132. } else {
  133. uni.showToast({
  134. icon: 'none',
  135. title: "请求失败",
  136. });
  137. that.dataList = null;
  138. that.mescroll.endErr();
  139. }
  140. });
  141. },
  142. // showDetail(item) {
  143. // uni.navigateTo({
  144. // url: './storeOrderDetail?id=' + item.id
  145. // })
  146. // },
  147. }
  148. }
  149. </script>
  150. <style lang="scss">
  151. .search-cont {
  152. padding: 16rpx 30rpx;
  153. background-color: #FFFFFF;
  154. .inner {
  155. box-sizing: border-box;
  156. width: 100%;
  157. height: 72rpx;
  158. background: #F7F7F7;
  159. border-radius: 36rpx;
  160. display: flex;
  161. align-items: center;
  162. padding: 0 30rpx;
  163. .icon-search {
  164. width: 28rpx;
  165. height: 28rpx;
  166. margin-right: 20rpx;
  167. }
  168. input {
  169. height: 60rpx;
  170. line-height: 60rpx;
  171. flex: 1;
  172. }
  173. }
  174. }
  175. .live-list {
  176. padding: 20rpx;
  177. .item {
  178. background: #FFFFFF;
  179. border-radius: 16rpx;
  180. padding: 20rpx 30rpx;
  181. margin-bottom: 20rpx;
  182. .bottom-box {
  183. display: flex;
  184. align-items: center;
  185. justify-content: space-between;
  186. .left {
  187. display: flex;
  188. align-items: center;
  189. .img {
  190. width: 140rpx;
  191. height: 140rpx;
  192. }
  193. .label {
  194. font-size: 28rpx;
  195. font-weight: 500;
  196. color: #999999;
  197. line-height: 1;
  198. }
  199. .price-box {
  200. display: flex;
  201. align-items: flex-end;
  202. .unit {
  203. font-size: 24rpx;
  204. font-family: PingFang SC;
  205. font-weight: 500;
  206. color: #FF6633;
  207. line-height: 1.2;
  208. margin-right: 4rpx;
  209. }
  210. .num {
  211. font-size: 32rpx;
  212. font-family: PingFang SC;
  213. font-weight: bold;
  214. color: #FF6633;
  215. line-height: 1;
  216. }
  217. }
  218. }
  219. .btn-box {
  220. box-sizing: border-box;
  221. display: flex;
  222. align-items: center;
  223. button {
  224. font-size: 28rpx;
  225. color: #F7F7F7;
  226. padding: 12rpx 20rpx !important;
  227. background-color: #2BC7B9 !important;
  228. line-height: inherit !important;
  229. margin: 0 !important;
  230. width: auto !important;
  231. font-weight: 500 !important;
  232. border-radius: none !important;
  233. }
  234. }
  235. }
  236. }
  237. }
  238. </style>