course.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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="imgPath+'/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. console.log(this.$store.state.imgpath+'/app/images/card_icon.png')
  50. },
  51. computed: {
  52. imgPath() {
  53. return this.$store.state.imgpath
  54. }
  55. },
  56. mounted() {},
  57. onShareAppMessage() {
  58. return {
  59. title: this.childdata.title, // 分享卡片标题
  60. path: this.childdata.path + "?course=" + JSON.stringify(this.childdata.params), // 目标页面路径
  61. // 携带参数:将当前页面的数据拼接到路径中
  62. imageUrl: this.childdata.img, // 分享卡片封面图(可选)
  63. success: (res) => {
  64. console.log("分享成功", res);
  65. },
  66. fail: (err) => {
  67. console.log("分享失败", err);
  68. },
  69. }
  70. },
  71. methods: {
  72. closeShare() {
  73. this.showShare = false
  74. // console.log('open');
  75. },
  76. handleParentMethod() {
  77. // uni.showToast({ title: '父组件方法被调用' });
  78. /* if (!this.childdata || Object.keys(this.childdata).length === 0) {
  79. uni.showToast({
  80. title: '数据未准备好,无法分享',
  81. icon: 'none'
  82. });
  83. return;
  84. }
  85. this.$nextTick(() => {
  86. setTimeout(() => {
  87. this.showShare = this.childdata.onshow
  88. }, 200)
  89. }) */
  90. },
  91. onChildDataUpdate(data) {
  92. this.childdata = data
  93. this.showShare = this.childdata.onshow
  94. console.log(this.childdata);
  95. console.log('父组件', this.childdata.path + "?course=" +JSON.stringify(this.childdata.params) )
  96. },
  97. sectionChange(index) {
  98. this.current = index
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss">
  104. .card-share{
  105. position: relative;
  106. }
  107. .share{
  108. display: inline-block;
  109. position: absolute;
  110. top: 0;
  111. left: 0;
  112. width: 100%;
  113. height: 100%;
  114. opacity: 0;
  115. }
  116. .sharePop {
  117. background-color: #fff;
  118. padding: 30rpx 0;
  119. border-radius: 20px 20px 0 0;
  120. /* #ifdef MP-WEIXIN */
  121. /* #endif */
  122. /* #ifdef H5 */
  123. padding-bottom: 60px;
  124. /* #endif */
  125. &-item {
  126. padding: 0 10px;
  127. box-sizing: border-box;
  128. font-family: PingFang SC, PingFang SC;
  129. font-weight: 400;
  130. font-size: 14px;
  131. display: inline-flex !important;
  132. image {
  133. height: 48px;
  134. width: 48px;
  135. margin-bottom: 10px;
  136. }
  137. }
  138. }
  139. </style>