Detail.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <div>
  3. <!-- 图书id{{bookid}} -->
  4. <BookInfo :info='info'></BookInfo>
  5. <!-- <button open-type='share' class="btn">转发给好友</button> -->
  6. </div>
  7. </template>
  8. <script>
  9. import {get} from '@/util'
  10. import BookInfo from '@/components/BookInfo'
  11. export default {
  12. components: {
  13. BookInfo
  14. },
  15. data () {
  16. return {
  17. bookid: '',
  18. info: {}
  19. }
  20. },
  21. methods: {
  22. async getDetail () {
  23. const info = await get('/weapp/bookdetail', {id: this.bookid})
  24. wx.setNavigationBarTitle({
  25. title: info.title
  26. })
  27. console.log(info)
  28. this.info = info
  29. },
  30. },
  31. onShareAppMessage: function(res) {
  32. return {
  33. title: this.info.title,
  34. path: 'pages/detail/main',
  35. imageUrl:'', // 不填写默认页面截图
  36. // success: function (shareTickets) {
  37. // // console.info(shareTickets + '成功');
  38. // console.log(shareTickets + '成功');
  39. // // 转发成功
  40. // },
  41. // fail: function (res) {
  42. // console.log(res + '失败');
  43. // // 转发失败
  44. // },
  45. // complete:function(res){
  46. // console.log(res + '不管成功失败都会执行');
  47. // // 不管成功失败都会执行
  48. // }
  49. }
  50. },
  51. mounted () {
  52. this.bookid = this.$root.$mp.query.id; // 跳转页面使用this.$root.$mp.query获取参数
  53. this.getDetail();
  54. // wx.showShareMenu({
  55. // withShareTicket: true
  56. // });
  57. }
  58. }
  59. </script>
  60. <style lang="scss">
  61. </style>