course.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view class="column hidden" style="height: 100%;">
  3. <!-- <view class="p20 bgf" style="z-index: 999;">
  4. <u-subsection class="subsection" :list="list" :current="current" bgColor="#e7f1fe" activeColor="#1677ff"
  5. :fontSize="15" :bold="false" @change="sectionChange" ></u-subsection>
  6. </view>
  7. <living v-if="current==0" style="margin-top: -240rpx;"></living> -->
  8. <liveCourse @child-data-update="onChildDataUpdate" :parent-method="handleParentMethod"></liveCourse>
  9. <u-popup :show="showShare" :closeOnClickOverlay="true" :round='20' @close="closeShare">
  10. <view class="sharePop x-ac">
  11. <!--#ifdef MP-WEIXIN-->
  12. <view class="sharePop-item y-f card-share">
  13. <image src="https://fbylive.obs.cn-southwest-2.myhuaweicloud.com:443/app/images/card_icon.png"
  14. mode="aspectFill" style="width: 80rpx; height: 80rpx;margin-top: 20rpx;"></image>
  15. <view style="font-weight: bold;margin-bottom: 4px;">生成卡片</view>
  16. <view style="font-size: 12px;color: #888;">指导分享轻松转发</view>
  17. <button open-type="share" class="share">分享课程</button>
  18. </view>
  19. <!--#endif-->
  20. </view>
  21. </u-popup>
  22. </view>
  23. </template>
  24. <script>
  25. import liveCourse from "@/components/liveCourse.vue"
  26. import living from "@/components/living.vue"
  27. export default {
  28. components: {
  29. living,
  30. liveCourse
  31. },
  32. data() {
  33. return {
  34. list: [{
  35. name: '直播课',
  36. }, {
  37. name: '训练营'
  38. }],
  39. current: 0,
  40. childdata: [],
  41. showShare: false
  42. }
  43. },
  44. onLoad() {
  45. wx.showShareMenu({
  46. withShareTicket: true, // 支持群聊分享带shareTicket
  47. menus: ['shareAppMessage'] // 同时启用两种分享
  48. })
  49. },
  50. mounted() {},
  51. onShareAppMessage() {
  52. return {
  53. title: this.childdata.title, // 分享卡片标题
  54. path: this.childdata.path + "?course=" + this.childdata.params, // 目标页面路径
  55. // 携带参数:将当前页面的数据拼接到路径中
  56. imageUrl: this.childdata.img, // 分享卡片封面图(可选)
  57. success: (res) => {
  58. console.log("分享成功", res);
  59. },
  60. fail: (err) => {
  61. console.log("分享失败", err);
  62. },
  63. }
  64. },
  65. methods: {
  66. closeShare() {
  67. this.showShare = false
  68. // console.log('open');
  69. },
  70. handleParentMethod() {
  71. // uni.showToast({ title: '父组件方法被调用' });
  72. /* if (!this.childdata || Object.keys(this.childdata).length === 0) {
  73. uni.showToast({
  74. title: '数据未准备好,无法分享',
  75. icon: 'none'
  76. });
  77. return;
  78. }
  79. this.$nextTick(() => {
  80. setTimeout(() => {
  81. this.showShare = this.childdata.onshow
  82. }, 200)
  83. }) */
  84. },
  85. onChildDataUpdate(data) {
  86. this.childdata = data
  87. this.showShare = this.childdata.onshow
  88. console.log(this.childdata);
  89. console.log('父组件', this.childdata.path + "?course=" +JSON.stringify(this.childdata.params) )
  90. },
  91. sectionChange(index) {
  92. this.current = index
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang="scss">
  98. .card-share{
  99. position: relative;
  100. }
  101. .share{
  102. display: inline-block;
  103. position: absolute;
  104. top: 0;
  105. left: 0;
  106. width: 100%;
  107. height: 100%;
  108. opacity: 0;
  109. }
  110. .sharePop {
  111. background-color: #fff;
  112. padding: 30rpx 0;
  113. border-radius: 20px 20px 0 0;
  114. /* #ifdef MP-WEIXIN */
  115. /* #endif */
  116. /* #ifdef H5 */
  117. padding-bottom: 60px;
  118. /* #endif */
  119. &-item {
  120. padding: 0 10px;
  121. box-sizing: border-box;
  122. font-family: PingFang SC, PingFang SC;
  123. font-weight: 400;
  124. font-size: 14px;
  125. display: inline-flex !important;
  126. image {
  127. height: 48px;
  128. width: 48px;
  129. margin-bottom: 10px;
  130. }
  131. }
  132. }
  133. </style>