details.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <app-layout>
  3. <view>
  4. <app-card-detail @share="hShareAppMessage" :list="list"></app-card-detail>
  5. </view>
  6. </app-layout>
  7. </template>
  8. <script>
  9. import appCardDetail from '../components/app-card-detail.vue';
  10. import {mapState} from "vuex";
  11. export default {
  12. components: {appCardDetail},
  13. data() {
  14. return {
  15. list: null,
  16. }
  17. },
  18. computed: {
  19. ...mapState({
  20. cardImg: state => state.mallConfig.__wxapp_img.card,
  21. })
  22. },
  23. // #ifdef MP
  24. onShareAppMessage() {
  25. return this.hShareAppMessage();
  26. },
  27. // #endif
  28. methods: {
  29. hShareAppMessage(s = false) {
  30. return this.$shareAppMessage({
  31. title: this.list.app_share_title ? this.list.app_share_title : '送你一张卡券,赶快来领取吧',
  32. imageUrl: this.list.app_share_pic ? this.list.app_share_pic : this.cardImg.img_card_2,
  33. path: '/pages/card/give/give',
  34. params: {
  35. card_id: this.list.id
  36. }
  37. }, s);
  38. },
  39. getList(id) {
  40. let that = this;
  41. that.$showLoading({
  42. text: '加载中...'
  43. });
  44. that.$request({
  45. url: that.$api.card.detail,
  46. data: {
  47. cardId: id,
  48. },
  49. }).then(response=>{
  50. that.$hideLoading();
  51. if(response.code === 0) {
  52. that.list = response.data.card;
  53. } else {
  54. uni.showToast({
  55. title: response.msg,
  56. icon: 'none',
  57. duration: 1000,
  58. });
  59. }
  60. }).catch(() => {
  61. that.$hideLoading();
  62. });
  63. },
  64. },
  65. onLoad(options) { this.$commonLoad.onload(options);
  66. this.getList(options.id);
  67. },
  68. }
  69. </script>