my_share.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <view class="share-container">
  3. <form >
  4. <view class="share-begin">
  5. <button open-type="share" form-type="submit" class="alias-submit" type="primary" >开始分享推荐</button>
  6. </view>
  7. <view>
  8. <button class="alias-submit" type="primary" @click="queryResult" >查看分享结果</button>
  9. </view>
  10. </form>
  11. </view>
  12. </template>
  13. <script>
  14. import { mapMutations, mapState } from 'vuex'
  15. export default {
  16. computed: {
  17. ...mapState('m_user', ['userinfo'])
  18. },
  19. methods: {
  20. /**
  21. * 分享处理函数,可以响应2类事件,1是button,2是右上角的menu中的Send to Chat
  22. * button用法:<button class="forshare" open-type="share">share</button>
  23. * menu用法:不用引入变量,当页面有这个函数时, Send to Chat会启用,否则灰色
  24. * path中的uid=txj123,txj123应该换为真实的用户号,当这个分享的卡片被打开时,小程序可以取到这个号
  25. */
  26. onShareAppMessage: function () {
  27. //console.log(this.userinfo)
  28. return {
  29. title:'来自 ' + this.userinfo.alias + ' 的分享',
  30. path: '/pages/home/home?uid=' + this.userinfo.uid,
  31. imageUrl: '/static/share.jpg', //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
  32. }
  33. },
  34. queryResult:function(){
  35. uni.navigateTo({
  36. url: '/subpkg/my/share/my_share_result'
  37. })
  38. }
  39. }
  40. }
  41. </script>
  42. <style lang="scss" scoped>
  43. .share-container{
  44. height: 100%;
  45. padding: 0 20rpx;
  46. // background-color: #fff;
  47. }
  48. .share-begin{
  49. padding-top: 50rpx;
  50. margin-top: -50rpx;
  51. }
  52. .alias-submit {
  53. margin-top: 50rpx;
  54. border-radius: 30rpx;
  55. background-color: #35b882;
  56. }
  57. </style>