give.vue 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <app-layout>
  3. <view v-if="type === 'give'">
  4. <app-card-give :card="card" @receive="receive"></app-card-give>
  5. </view>
  6. <view v-if="type === 'detail'">
  7. <app-card-detail :list="card"></app-card-detail>
  8. </view>
  9. </app-layout>
  10. </template>
  11. <script>
  12. import {mapState} from "vuex";
  13. import appCardGive from '../components/app-card-give.vue';
  14. import appCardDetail from '../components/app-card-detail.vue';
  15. export default {
  16. name: "give",
  17. components: {
  18. appCardGive,
  19. appCardDetail
  20. },
  21. data() {
  22. return {
  23. card: null,
  24. type: null,
  25. };
  26. },
  27. computed: {
  28. ...mapState({
  29. cardImg: state => state.mallConfig.__wxapp_img.card,
  30. })
  31. },
  32. onLoad(options) {
  33. this.loadData(options);
  34. },
  35. methods: {
  36. loadData(options) {
  37. this.$showLoading();
  38. this.$request({
  39. url: this.$api.card.givesp,
  40. method: 'get',
  41. data: {
  42. cardId: options.card_id
  43. }
  44. }).then(response => {
  45. this.$hideLoading();
  46. if (response.code === 0) {
  47. let data = response.data;
  48. this.type = data.type;
  49. this.card = response.data;
  50. let title = '';
  51. if (data.type === 'give') {
  52. title = '领取碎屏险'
  53. } else {
  54. title = '碎屏险详情'
  55. }
  56. uni.setNavigationBarTitle({
  57. title: title,
  58. });
  59. }
  60. })
  61. },
  62. receive() {
  63. this.loadData({card_id: this.card.id})
  64. }
  65. },
  66. onShareAppMessage(object) {
  67. return this.$shareAppMessage({
  68. title: this.card.app_share_title ? this.card.app_share_title : '送你一张碎屏险,赶快来领取吧',
  69. imageUrl: this.card.app_share_pic ? this.card.app_share_pic : this.cardImg.img_card_2,
  70. path: '/pages/card/give/give',
  71. params: {
  72. card_id: this.card.id
  73. }
  74. });
  75. },
  76. }
  77. </script>
  78. <style scoped lang="scss">
  79. </style>