details.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <app-layout>
  3. <view>
  4. <app-details :detail-list="list" :is-show-share="true" :type="type"></app-details>
  5. </view>
  6. </app-layout>
  7. </template>
  8. <script>
  9. import appDetails from './app-details.vue';
  10. import {mapState} from "vuex";
  11. export default {
  12. components: {appDetails},
  13. data() {
  14. return {
  15. type: 0,
  16. id: 0,
  17. list: null,
  18. }
  19. },
  20. computed: {
  21. ...mapState({
  22. couponImg: state => state.mallConfig.__wxapp_img.coupon,
  23. })
  24. },
  25. methods: {
  26. getList(id) {
  27. let that = this;
  28. that.$showLoading({
  29. type: 'global',
  30. text: '加载中...'
  31. });
  32. let url = that.$api.coupon.detail;
  33. let para = {
  34. coupon_id: id
  35. };
  36. if (this.type === 2) {
  37. url = that.$api.coupon.user_coupon_detail;
  38. para = {
  39. user_coupon_id: id
  40. };
  41. }
  42. that.$request({
  43. url: url,
  44. data: para
  45. }).then(response => {
  46. that.$hideLoading();
  47. if (response.code === 0) {
  48. that.list = response.data.list;
  49. } else {
  50. uni.showToast({
  51. title: response.msg,
  52. icon: 'none',
  53. duration: 1000
  54. });
  55. }
  56. }).catch(() => {
  57. that.$hideLoading();
  58. });
  59. },
  60. },
  61. onLoad(option) { this.$commonLoad.onload(option);
  62. this.id = option.id;
  63. this.getList(this.id);
  64. },
  65. // #ifdef MP
  66. onShareAppMessage() {
  67. return this.$shareAppMessage({
  68. title: this.list.app_share_title,
  69. imageUrl: this.list.app_share_pic ? this.list.app_share_pic : this.couponImg.img_coupon_2,
  70. path: '/pages/coupon/give/give',
  71. params: {
  72. coupon_id: this.id
  73. }
  74. });
  75. }
  76. // #endif
  77. }
  78. </script>
  79. <style scoped lang="scss">
  80. </style>