share.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <view class="share_all">
  3. <view class="shadow" v-if="shaflag" @click="getClose"></view>
  4. <transition name="fade">
  5. <view v-if="wxshareflag" @click="wxzheFn">
  6. <image :src="tipimg" class="tipimg"></image>
  7. </view>
  8. </transition>
  9. <view :class="shareflag ? 'share_btn share_bot' : 'share_btn'">
  10. <view class="f15 c16 fw5 txc">分享至</view>
  11. <view class="box">
  12. <!-- #ifdef MP-WEIXIN -->
  13. <view class="list">
  14. <image :src="wximg" class="share_img"></image>
  15. <view class="share_tit">微信好友</view>
  16. <button open-type="share" class="sharebox"></button>
  17. <!-- :data-id="datainfo.noticeId" :data-tit="datainfo.noticeContent" :data-img="photo.length?photo[0]:''" -->
  18. </view>
  19. <view class="list" @click="getPshare">
  20. <image :src="pyqimg" class="share_img"></image>
  21. <view class="share_tit">朋友圈</view>
  22. </view>
  23. <!-- #endif -->
  24. <!-- #ifdef APP-PLUS -->
  25. <view class="list" @click="getAppwshare">
  26. <image :src="wximg" class="share_img"></image>
  27. <view class="share_tit">微信好友</view>
  28. </view>
  29. <view class="list" @click="getApppshare">
  30. <image :src="pyqimg" class="share_img"></image>
  31. <view class="share_tit">朋友圈</view>
  32. </view>
  33. <!-- #endif -->
  34. </view>
  35. <view class="zhan"></view>
  36. <view class="share_close" @click="getClose">取消</view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import { mapState, mapMutations } from 'vuex';
  42. export default {
  43. props:{
  44. // notxt:{
  45. // type: String,
  46. // default () {
  47. // return '暂无数据'
  48. // }
  49. // },
  50. // padtop:{
  51. // type: Number,
  52. // default () {
  53. // return 200
  54. // }
  55. // }
  56. },
  57. data(){
  58. return{
  59. wximg:require("@/static/images/share/WeChat.png"),
  60. pyqimg:require("@/static/images/share/friend.png"),
  61. tipimg:require("@/static/images/share/pytip.png"),
  62. wxshareflag:false,
  63. }
  64. },
  65. onLoad: function() {
  66. },
  67. computed: {
  68. ...mapState({
  69. shareflag: state => state.user.shareflag,
  70. shaflag: state => state.user.shaflag,
  71. sharetit: state => state.user.sharetit,
  72. sharedesc: state => state.user.sharedesc,
  73. sharelink: state => state.user.sharelink,
  74. }),
  75. },
  76. methods:{
  77. ...mapMutations({
  78. "shasFn": "share"
  79. }),
  80. wxzheFn(){
  81. var that = this;
  82. that.wxshareflag = false;
  83. that.getClose();
  84. },
  85. getAppwshare(){
  86. uni.share({
  87. provider: "weixin",
  88. scene: "WXSceneSession",
  89. type: 0,
  90. href: this.sharelink,
  91. title: this.sharetit,
  92. summary: "我正在使用智能校管家,赶紧跟我一起来体验!",
  93. imageUrl: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni@2x.png",
  94. success: function (res) {
  95. console.log("success:" + JSON.stringify(res));
  96. },
  97. fail: function (err) {
  98. console.log("fail:" + JSON.stringify(err));
  99. }
  100. });
  101. },
  102. getApppshare(){
  103. uni.share({
  104. provider: "weixin",
  105. scene: "WXSceneTimeline",
  106. type: 0,
  107. href: this.sharelink,
  108. title: this.sharetit,
  109. summary: "我正在使用智能校管家,赶紧跟我一起来体验!",
  110. imageUrl: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni@2x.png",
  111. success: function (res) {
  112. console.log("success:" + JSON.stringify(res));
  113. },
  114. fail: function (err) {
  115. console.log("fail:" + JSON.stringify(err));
  116. }
  117. });
  118. },
  119. getPshare(){
  120. this.wxshareflag=true;
  121. },
  122. getClose(){
  123. var that = this;
  124. that.wxshareflag=false;
  125. var data = [
  126. {
  127. shareflag: false,
  128. shaflag: false,
  129. homeflag: false,
  130. sharetit: '',
  131. sharedesc: '',
  132. sharelink: '',
  133. shareimg: '',
  134. life_id: '',
  135. }
  136. ];
  137. that.$nextTick(function(){
  138. this.shasFn(data);
  139. })
  140. }
  141. },
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .shadow{position: fixed;top: 0;left: 0;right: 0;bottom: 0;background: rgba(0,0,0,0.4);z-index: 97;}
  146. .tipimg{width: 432rpx;height: 174rpx;position: fixed;top: 0;right: 120rpx;bottom: 0;z-index: 98;}
  147. .share_btn{position: fixed;bottom: 0;left: 0;right: 0;background: #fff;z-index: 99;transition: all linear 0.3s;transform: translateY(100%);padding-top: 26rpx;
  148. .zhan{width: 100%;height: 24rpx;background-color: #f5f5f5;}
  149. .box{padding: 50rpx 0;display: flex;align-items: center;flex-wrap: nowrap;
  150. .list{flex: 1;display: flex;flex-direction: column;align-items: center;position: relative;
  151. .sharebox{position: absolute;left: 0;right: 0;top: 0;bottom: 0;opacity: 0;}
  152. .share_img{width: 90rpx;height: 90rpx;}
  153. .share_tit{color: #666666;font-size: 30rpx;padding-top: 40rpx;}
  154. }
  155. }
  156. .share_close{height: 100rpx;background: #FFFFFF;font-size: 32rpx;font-weight: 500;color: #4775EA;display: flex;align-items: center;justify-content: center;}
  157. }
  158. .share_bot{transform: translateY(0);}
  159. </style>