index.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <!--姜枫 2021.04.13-->
  2. <style lang="scss" scoped>
  3. .app-content {
  4. }
  5. </style>
  6. <template>
  7. <div class="app-content">
  8. <button type="default" open-type="share">点击分享</button>
  9. 参数展示:{{JSON.stringify(shareInfo.shopId)}}
  10. </div>
  11. </template>
  12. <script>
  13. import { ghsInfo } from "@/api/ghs/index";
  14. export default {
  15. name: 'Share',
  16. data () {
  17. return {
  18. shareInfo:'',
  19. title: ''
  20. }
  21. },
  22. onShareAppMessage(res) {
  23. let {shopId,id,name} = this.shareInfo;
  24. if (res.from === 'button') {// 来自页面内分享按钮
  25. console.log(res.target)
  26. }
  27. return {
  28. title: this.title,
  29. path: `/pagesPurchase/ghsProduct?shopId=${shareInfo.shopId}&id=${shareInfo.id}&name=${shareInfo.name}`
  30. }
  31. },
  32. onLoad () {
  33. if(uni.getStorageSync('extraData')){
  34. this.shareInfo = uni.getStorageSync('extraData').referrerInfo.extraData;
  35. }
  36. ghsInfo({shopId: this.shareInfo.shopId}).then(res => {
  37. console.log(res)
  38. uni.setNavigationBarTitle({
  39.   title:res.data.name
  40. })
  41. this.title = res.data.name
  42. }).catch(err => {console.log(err)})
  43. },
  44. methods: {
  45. }
  46. }
  47. </script>