details.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <app-layout>
  3. <view>
  4. <app-card-detail :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. methods: {
  24. getList(id) {
  25. let that = this;
  26. that.$showLoading({
  27. text: '加载中...'
  28. });
  29. that.$request({
  30. url: that.$api.card.detailsp,
  31. data: {
  32. cardId: id,
  33. },
  34. }).then(response=>{
  35. that.$hideLoading();
  36. if(response.code === 0) {
  37. that.list = response.data.card;
  38. } else {
  39. uni.showToast({
  40. title: response.msg,
  41. icon: 'none',
  42. duration: 1000,
  43. });
  44. }
  45. }).catch(() => {
  46. that.$hideLoading();
  47. });
  48. },
  49. },
  50. onLoad(options) {
  51. this.getList(options.id);
  52. },
  53. onShareAppMessage(object) {
  54. return this.$shareAppMessage({
  55. title: this.list.app_share_title ? this.list.app_share_title : '送你一张碎屏险,赶快来领取吧',
  56. imageUrl: this.list.app_share_pic ? this.list.app_share_pic : this.cardImg.img_card_2,
  57. path: '/pages/card/give/give',
  58. params: {
  59. card_id: this.list.id
  60. }
  61. });
  62. },
  63. }
  64. </script>