Detail.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div>
  3. <!-- 图书id{{bookid}} -->
  4. <BookInfo :info='info'></BookInfo>
  5. <!-- <button open-type='share' class="btn">转发给好友</button> -->
  6. <div class="comment">
  7. <textarea v-model="comment"
  8. class="textarea"
  9. :maxlength="100"
  10. placeholder="请输入图书短评"></textarea>
  11. <div class="location">
  12. 地理位置:
  13. <switch color="#EA5A49" @change="getGeo" :checked="location" />
  14. <span class="text-primary">{{location}}</span>
  15. </div>
  16. <div class="phone">
  17. 手机型号:
  18. <switch color="#EA5A49" @change="getPhone" :checked="phone"/>
  19. <span class="text-primary">{{phone}}</span>
  20. </div>
  21. </div>
  22. </div>
  23. </template>
  24. <script>
  25. import {get} from '@/util'
  26. import BookInfo from '@/components/BookInfo'
  27. export default {
  28. components: {
  29. BookInfo
  30. },
  31. data () {
  32. return {
  33. bookid: '',
  34. info: {},
  35. comment: '',
  36. location: '',
  37. phone: ''
  38. }
  39. },
  40. methods: {
  41. getGeo () {
  42. },
  43. getPhone(e) {
  44. if(e.target.value) {
  45. const res = wx.getSystemInfoSync();
  46. // console.log(res.model);
  47. this.phone = res.model;
  48. } else {
  49. this.phone = '';
  50. }
  51. },
  52. async getDetail () {
  53. const info = await get('/weapp/bookdetail', {id: this.bookid})
  54. wx.setNavigationBarTitle({
  55. title: info.title
  56. })
  57. console.log(info)
  58. this.info = info
  59. }
  60. },
  61. onShareAppMessage: function(res) {
  62. return {
  63. title: this.info.title,
  64. path: 'pages/detail/main',
  65. imageUrl:'', // 不填写默认页面截图
  66. // success: function (shareTickets) {
  67. // // console.info(shareTickets + '成功');
  68. // console.log(shareTickets + '成功');
  69. // // 转发成功
  70. // },
  71. // fail: function (res) {
  72. // console.log(res + '失败');
  73. // // 转发失败
  74. // },
  75. // complete:function(res){
  76. // console.log(res + '不管成功失败都会执行');
  77. // // 不管成功失败都会执行
  78. // }
  79. }
  80. },
  81. mounted () {
  82. this.bookid = this.$root.$mp.query.id; // 跳转页面使用this.$root.$mp.query获取参数
  83. this.getDetail();
  84. // wx.showShareMenu({
  85. // withShareTicket: true
  86. // });
  87. }
  88. }
  89. </script>
  90. <style lang="scss">
  91. .comment {
  92. margin-top: 10px;
  93. .textarea {
  94. width: 730px;
  95. background-color: #eee;
  96. padding: 10px;
  97. }
  98. .location {
  99. margin-top: 10px;
  100. padding: 5px 10px;
  101. }
  102. .phone {
  103. margin-top: 10px;
  104. padding: 5px 10px;
  105. }
  106. }
  107. </style>