BeeWxShare.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <view class="wx-share-container">
  3. <view class="view-ui" @click.stop="$emit('click')">
  4. <slot></slot>
  5. </view>
  6. <tui-bottom-popup
  7. background-color="transparent" :z-index="100000033" :show="showSharePopupVisible"
  8. @close="showSharePopupVisible = false"
  9. >
  10. <view class="main-wrapper">
  11. <view class="share-header"> 分享到 </view>
  12. <view class="container">
  13. <view class="item">
  14. <view class="icon-wrapper" @click="handleShareApp('WXSceneSession')">
  15. <tui-icon color="#80d640" :size="34" name="wechat"></tui-icon>
  16. </view>
  17. <text>微信</text>
  18. </view>
  19. <view class="item">
  20. <view class="icon-wrapper" @click="handleShareApp('WXSceneTimeline')">
  21. <tui-icon color="#80d640" :size="34" name="moments"></tui-icon>
  22. </view>
  23. <text>朋友圈</text>
  24. </view>
  25. </view>
  26. <button class="uni-btn" @click="showSharePopupVisible = false">取消</button>
  27. </view>
  28. </tui-bottom-popup>
  29. <!-- #ifdef H5 -->
  30. <PointShare :show="showPointVisible" @close="showPointVisible = false"></PointShare>
  31. <!-- #endif -->
  32. <tui-toast ref="toast"></tui-toast>
  33. <tui-modal
  34. :show="$data._isShowTuiModel" title="提示" content="您还未登录,是否先去登录?"
  35. @click="_handleClickTuiModel($event, 'login', backUrl)"
  36. ></tui-modal>
  37. </view>
  38. </template>
  39. <script>
  40. import share from 'utils/share'
  41. import PointShare from './point-share'
  42. import { isInWx } from '../../utils'
  43. import { T_STORAGE_KEY } from '../../constant'
  44. import showModalMixin from '../../mixin/showModal'
  45. export default {
  46. name: 'BeeWxShare',
  47. components: {
  48. PointShare
  49. },
  50. data() {
  51. return {
  52. showSharePopupVisible: false,
  53. showPointVisible: false,
  54. shareData: null,
  55. backUrl: null
  56. }
  57. },
  58. mixins: [ showModalMixin() ],
  59. methods: {
  60. async share(data, quiet, backUrl) {
  61. this.shareData = data
  62. this.backUrl = backUrl
  63. if (!uni.getStorageSync(T_STORAGE_KEY) || (uni.getStorageSync(T_STORAGE_KEY) && !uni.getStorageSync(T_STORAGE_KEY).token)) {
  64. if (!quiet) {
  65. this.$data._isShowTuiModel = true
  66. }
  67. return
  68. }
  69. // #ifdef H5
  70. if (quiet) {
  71. await share(data)
  72. return
  73. }
  74. if (isInWx()) {
  75. this.showPointVisible = true
  76. await share(data)
  77. return
  78. }
  79. this.ttoast({
  80. title: '请在微信公众号中打开',
  81. type: 'fail'
  82. })
  83. return
  84. // #endif
  85. // #ifdef APP
  86. if (!quiet) {
  87. this.showSharePopupVisible = true
  88. }
  89. // #endif
  90. },
  91. handleShareApp(shareType) {
  92. share(this.shareData, shareType)
  93. }
  94. }
  95. }
  96. </script>
  97. <style lang="less" scoped>
  98. .main-wrapper {
  99. background-color: #fff;
  100. height: 444upx;
  101. background-color: #e8e8e8;
  102. .share-header {
  103. padding: 30upx 30upx 0;
  104. box-sizing: border-box;
  105. }
  106. .container {
  107. height: auto;
  108. display: flex;
  109. align-items: center;
  110. margin-top: 30upx;
  111. padding: 30upx;
  112. box-sizing: border-box;
  113. .item {
  114. display: flex;
  115. align-items: center;
  116. justify-content: center;
  117. flex-direction: column;
  118. margin-right: 30upx;
  119. .icon-wrapper {
  120. width: 134upx;
  121. height: 134upx;
  122. background-color: #fff;
  123. border-radius: 34upx;
  124. display: flex;
  125. align-items: center;
  126. justify-content: center;
  127. margin-bottom: 20upx;
  128. transition: all 350ms;
  129. &:active {
  130. background-color: #ccc;
  131. }
  132. }
  133. }
  134. }
  135. .uni-btn {
  136. display: flex;
  137. align-items: center;
  138. justify-content: center;
  139. font-size: 38upx;
  140. height: 106upx;
  141. text-align: center;
  142. line-height: 40upx;
  143. background-color: #f6f6f6;
  144. color: #5c5c5c;
  145. }
  146. }
  147. </style>