share.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <app-layout>
  3. <view class="page-width share" :class="[`${theme}-background`]" v-if="loading">
  4. <!-- 标题 -->
  5. <view class="page-width ready-send">
  6. <share-gift-text
  7. big="礼物准备完毕,送出去吧"
  8. small="记得提醒收礼人填写地址哦"
  9. ></share-gift-text>
  10. </view>
  11. <!-- 内容 -->
  12. <view class="page-width gift-content">
  13. <gift-content
  14. v-on:share="setShare"
  15. :theme="theme"
  16. :big_gift_pic="big_gift_pic"
  17. :nickname="gift_detail.list.user.nickname"
  18. :avatar="gift_detail.list.user.userInfo.avatar"
  19. :bless_word="gift_detail.list.bless_word"
  20. :is_big_gift="gift_detail.is_big_gift"
  21. :cover_pic="gift_detail.list.sendOrder[0].detail[0].goods.goodsWarehouse.cover_pic"
  22. :name="gift_detail.list.sendOrder[0].detail[0].goods.goodsWarehouse.name"
  23. :refund_time="gift_detail.refund_time"
  24. :bless_music="gift_detail.list.bless_music"
  25. :is_play="is_play"
  26. @play="play"
  27. ></gift-content>
  28. </view>
  29. <!-- 分享海报 -->
  30. <view class="page-width share-poster">
  31. <app-share-qr-code-poster @share="hShareAppMessage" sign="gift" :theme="theme" :url="url" v-model="share"></app-share-qr-code-poster>
  32. </view>
  33. </view>
  34. </app-layout>
  35. </template>
  36. <script>
  37. import { mapState } from 'vuex';
  38. import shareGiftText from '../components/announcement/share-gift-text.vue';
  39. import giftContent from '../components/share/gift-content.vue';
  40. import appShareQrCodePoster from '../../../components/page-component/app-share-qr-code-poster/app-share-qr-code-poster.vue'
  41. export default {
  42. name: 'share',
  43. data() {
  44. return {
  45. gift_id: -1,
  46. gift_detail: {},
  47. share: false,
  48. url: ``,
  49. loading: false,
  50. is_play: false,
  51. innerAudioContext: ''
  52. }
  53. },
  54. onLoad(options) { this.$commonLoad.onload(options);
  55. if (JSON.parse(options.pay_data).gift_id) {
  56. this.gift_id = JSON.parse(options.pay_data).gift_id;
  57. this.request(JSON.parse(options.pay_data).gift_id);
  58. this.$storage.removeStorageSync('GIFT_CART');
  59. let self = this;
  60. this.innerAudioContext = uni.createInnerAudioContext();
  61. this.innerAudioContext.autoplay = true;
  62. this.innerAudioContext.onEnded(function(res) {
  63. self.is_play = false;
  64. });
  65. } else {
  66. uni.redirectTo({
  67. url: '/plugins/gift/index/index',
  68. })
  69. }
  70. },
  71. // #ifdef MP
  72. onShareAppMessage() {
  73. return this.hShareAppMessage();
  74. },
  75. // #endif
  76. methods: {
  77. hShareAppMessage(s = false){
  78. return this.$shareAppMessage({
  79. path: '/plugins/gift/index/index',
  80. imageUrl: this.gift_detail.is_big_gift === 0 ? this.gift_detail.list.sendOrder[0].detail[0].goods.goodsWarehouse.cover_pic : this.big_gift_pic,
  81. // #ifdef MP-ALIPAY
  82. bgImgUrl: this.gift_detail.is_big_gift === 0 ? this.gift_detail.list.sendOrder[0].detail[0].goods.goodsWarehouse.cover_pic : this.big_gift_pic,
  83. // #endif
  84. params: {
  85. gift_id: this.gift_id,
  86. },
  87. title: this.gift_detail.list.bless_word,
  88. }, s);
  89. },
  90. async request(gift_id) {
  91. this.$utils.showLoading();
  92. const res = await this.$request({
  93. url: this.$api.gift.gift,
  94. method: 'get',
  95. data: {
  96. gift_id: gift_id
  97. }
  98. });
  99. this.$utils.hideLoading();
  100. if (res.code === 0) {
  101. this.url = `${this.$api.gift.poster}&gift_id=${gift_id}`;
  102. this.gift_detail = res.data;
  103. this.loading = true;
  104. } else {
  105. uni.showModal({
  106. title: '提示',
  107. content: res.msg,
  108. })
  109. }
  110. },
  111. setShare() {
  112. this.share = true;
  113. },
  114. play(status, bless_music) {
  115. this.is_play = status;
  116. if (status) {
  117. this.innerAudioContext.src = bless_music;
  118. this.innerAudioContext.play();
  119. } else {
  120. this.innerAudioContext.stop();
  121. }
  122. }
  123. },
  124. computed: {
  125. ...mapState('gift',{
  126. theme: state => state.theme,
  127. big_gift_pic: state => state.big_gift_pic,
  128. })
  129. },
  130. onHide() {
  131. this.is_play = false;
  132. this.innerAudioContext.stop();
  133. },
  134. components: {
  135. 'share-gift-text': shareGiftText,
  136. 'gift-content': giftContent,
  137. 'app-share-qr-code-poster': appShareQrCodePoster,
  138. },
  139. }
  140. </script>
  141. <style scoped lang="scss">
  142. @import '../css/gift.scss';
  143. .share {
  144. position: absolute;
  145. height: 100%;
  146. overflow: hidden;
  147. }
  148. .gift-content {
  149. height: calc(100% - #{104upx});
  150. margin-top: #{104upx};
  151. }
  152. </style>