app-share.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view class="bottom-panel popup-bg" :class="Visible?'bottom-panel open':'bottom-panel close'" @click="closePopup">
  3. <view class="content" v-on:click.stop>
  4. <view class="module-box module-share">
  5. <view class="hd d-c-c">
  6. 分享
  7. </view>
  8. <view class="p30 box-s-b">
  9. <view class="d-c-c">
  10. <view class="item flex-1 d-c-c d-c">
  11. <button open-type="share" @click="share(0, 'WXSceneSession')">
  12. <view class="icon-box d-c-c share-friend">
  13. <text class="iconfont icon-fenxiang"></text>
  14. </view>
  15. <text class="pt20">微信好友</text>
  16. </button>
  17. </view>
  18. <view class="item flex-1 d-c-c d-c">
  19. <button class="d-c-c d-c" @click="share(0, 'WXSenceTimeline')">
  20. <view class="icon-box d-c-c">
  21. <text class="iconfont icon-edit"></text>
  22. </view>
  23. <text class="pt20">微信朋友圈</text>
  24. </button>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="btns">
  29. <button type="default" @click="closePopup(1)">取消</button>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import config from '@/config.js';
  37. export default {
  38. data() {
  39. return {
  40. /*是否可见*/
  41. Visible: false,
  42. /*分享配置*/
  43. shareConfig: {},
  44. // logo
  45. logo: ''
  46. }
  47. },
  48. created() {
  49. this.getData();
  50. },
  51. props: ['isAppShare', 'appParams'],
  52. watch: {
  53. 'isAppShare': function(n, o) {
  54. if (n != o) {
  55. this.Visible = n;
  56. }
  57. }
  58. },
  59. methods: {
  60. getData(){
  61. let self = this;
  62. self._get(
  63. 'settings/appShare',{},
  64. function(res) {
  65. self.shareConfig = res.data.appshare;
  66. self.logo = res.data.logo;
  67. }
  68. );
  69. },
  70. /*关闭弹窗*/
  71. closePopup(type) {
  72. this.$emit('close');
  73. },
  74. // 分享
  75. share: function(shareType, scene) {
  76. let shareOPtions = {
  77. provider: "weixin",
  78. scene: scene, //WXSceneSession”分享到聊天界面,“WXSenceTimeline”分享到朋友圈
  79. type: shareType,
  80. success: function (res) {
  81. console.log("success:" + JSON.stringify(res));
  82. },
  83. fail: function (err) {
  84. console.log("fail:" + JSON.stringify(err));
  85. }
  86. }
  87. if(this.shareConfig.type != 2){
  88. shareOPtions.summary = this.appParams.summary;
  89. shareOPtions.imageUrl = this.logo;
  90. shareOPtions.title = this.appParams.title;
  91. // 公众号/h5
  92. if(this.shareConfig.type == 1){
  93. shareOPtions.href = this.shareConfig.open_site + this.appParams.path;
  94. }else if(this.shareConfig.type == 3){
  95. //下载页
  96. if(this.shareConfig.bind_type == 1){
  97. shareOPtions.href = this.shareConfig.down_url;
  98. }else{
  99. shareOPtions.href = config.app_url + "/index.php/api/user.useropen/invite?app_id="+ config.app_id +"&referee_id=" + uni.getStorageSync('user_id');
  100. }
  101. }
  102. }else{
  103. // 分享到小程序
  104. shareOPtions.scene = 'WXSceneSession';
  105. shareOPtions.type = 5;
  106. shareOPtions.imageUrl = this.appParams.image ? this.appParams.image : this.logo;
  107. shareOPtions.title = this.appParams.title;
  108. shareOPtions.miniProgram = {
  109. id: this.shareConfig.gh_id,
  110. path: this.appParams.path,
  111. webUrl: this.shareConfig.web_url,
  112. type:0
  113. };
  114. }
  115. uni.share(shareOPtions);
  116. },
  117. }
  118. }
  119. </script>
  120. <style>
  121. .bottom-panel{
  122. }
  123. .bottom-panel.popup-bg {
  124. position: fixed;
  125. top: 0;
  126. right: 0;
  127. bottom: 0;
  128. left: 0;
  129. background: rgba(0, 0, 0, .6);
  130. height: 100%;
  131. z-index: 98;
  132. }
  133. .bottom-panel.popup-bg .wechat-box{ padding-top: var(--window-top);}
  134. .bottom-panel.popup-bg .wechat-box image{ width: 100%;}
  135. .bottom-panel .content {
  136. position: fixed;
  137. width: 100%;
  138. bottom: 0;
  139. min-height: 200rpx;
  140. max-height: 900rpx;
  141. background-color: #fff;
  142. transform: translate3d(0, 980rpx, 0);
  143. transition: transform .2s cubic-bezier(0, 0, .25, 1);
  144. bottom: env(safe-area-inset-bottom);
  145. z-index: 99;
  146. }
  147. .bottom-panel.open .content {
  148. transform: translate3d(0, 0, 0);
  149. }
  150. .bottom-panel.close.popup-bg {
  151. display: none;
  152. }
  153. .module-share .hd {
  154. height: 90rpx;
  155. line-height: 90rpx;
  156. font-size: 36rpx;
  157. }
  158. .module-share .item button,.module-share .item button::after{ background: none; border: none;}
  159. .module-share .icon-box {
  160. width: 100rpx;
  161. height: 100rpx;
  162. border-radius: 50%;
  163. background: #f6bd1d;
  164. }
  165. .module-share .icon-box .iconfont {
  166. font-size: 60rpx;
  167. color: #FFFFFF;
  168. }
  169. .module-share .btns {
  170. margin-top: 30rpx;
  171. }
  172. .module-share .btns button {
  173. height: 90rpx;
  174. line-height: 90rpx;
  175. border-radius: 0;
  176. border-top: 1px solid #EEEEEE;
  177. }
  178. .module-share .btns button::after {
  179. border-radius: 0;
  180. }
  181. .module-share .share-friend {
  182. background: #04BE01;
  183. }
  184. </style>