fa-app-share.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <view>
  3. <u-popup v-model="is_show" mode="bottom">
  4. <u-grid :col="3" :border="false">
  5. <u-grid-item v-for="(item,index) in list" :key="index" @click="share(index,item)">
  6. <u-icon :name="item.icon" :color="item.color" :size="item.size"></u-icon>
  7. <view class="grid-text u-m-t-10" v-text="item.name"></view>
  8. </u-grid-item>
  9. </u-grid>
  10. <u-gap height="3" bg-color="rgb(244, 246, 248)"></u-gap>
  11. <view class="u-text-center u-p-30" @click="hide">
  12. 取消
  13. </view>
  14. </u-popup>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. name:'fa-app-share',
  20. props:{
  21. title:{
  22. type:String,
  23. default:''
  24. },
  25. summary:{
  26. type:String,
  27. default:''
  28. },
  29. href:{
  30. type:String,
  31. default:''
  32. },
  33. imageUrl:{
  34. type:String,
  35. default:''
  36. }
  37. },
  38. data() {
  39. return {
  40. is_show: false,
  41. list:[
  42. {
  43. name:'微信好友',
  44. icon:'weixin-circle-fill',
  45. size:60,
  46. color:'#44b549',
  47. type:0,//图文
  48. provider:'weixin'
  49. },
  50. {
  51. name:'微信朋友圈',
  52. icon:'moments-circel-fill',
  53. size:60,
  54. color:'#44b549',
  55. type:0,//图文
  56. provider:'weixin'
  57. },
  58. {
  59. name:'微信收藏',
  60. icon:'star-fill',
  61. size:60,
  62. color:'#ff9100',
  63. type:0,//图文
  64. provider:'weixin'
  65. },
  66. {
  67. name:'QQ好友',
  68. icon:'qq-circle-fill',
  69. size:60,
  70. color:'#388BFF',
  71. type:2,//图
  72. provider:'qq',
  73. },
  74. {
  75. name:'新浪微博',
  76. icon:'weibo-circle-fill',
  77. size:60,
  78. color:'#BE3E3F',
  79. type:0,//图文
  80. provider:'sinaweibo ',
  81. }
  82. ]
  83. };
  84. },
  85. methods:{
  86. show(){
  87. this.is_show = true;
  88. },
  89. hide(){
  90. this.is_show = false;
  91. },
  92. share(index,item){
  93. let data = {
  94. provider: item.provider,
  95. type: item.type,
  96. href: this.href,
  97. title: this.title,
  98. summary: this.summary,
  99. imageUrl: this.imageUrl,
  100. success: (res) => {
  101. this.hide();
  102. this.$u.toast('分享成功!');
  103. },
  104. fail: (err) => {
  105. console.log(JSON.stringify(err))
  106. this.$u.toast('分享失败!');
  107. }
  108. };
  109. if(index==0){
  110. data.scene = "WXSceneSession";
  111. }
  112. if(index==1){
  113. data.scene = "WXSenceTimeline";
  114. }
  115. if(index==2){
  116. data.scene = 'WXSceneFavorite';
  117. }
  118. console.log(JSON.stringify(data))
  119. uni.share(data);
  120. }
  121. }
  122. };
  123. </script>
  124. <style></style>