index.vue 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <view>
  3. <!--template/couponAd/index.wxml-->
  4. <template name="red_envelopes">
  5. <block v-if="!first&&!storeShow">
  6. <view class="layer" v-if="couponAd&&couponAd.state==0&&couponAd.titleCon&&iscouponAd">
  7. <image lazy-load="true" :src="couponAd.titleCon" mode="aspectFit" @tap="redEnvelopes" :data-type="couponAd.type"
  8. :data-content="couponAd.content"></image>
  9. <image class="close" src="/static/pages/images/ad_close_w.png" @tap="hidecouponAd"></image>
  10. </view>
  11. </block>
  12. </template>
  13. </view>
  14. </template>
  15. <script>
  16. const req = require("../../utils/request.js");
  17. export default {
  18. data() {
  19. return {};
  20. },
  21. components: {},
  22. props: {
  23. first: Boolean, //点击此处关闭气泡
  24. couponAd: Object, //红包配置
  25. iscouponAd: Boolean, //是否关闭红包
  26. storeShow:Boolean //是否显示组件
  27. },
  28. mounted() {
  29. // console.log(this.iscouponAd,this.first,this.couponAd)
  30. },
  31. methods: {
  32. // 关闭优惠券广告
  33. hidecouponAd() {
  34. this.setData({
  35. iscouponAd: false
  36. })
  37. this.$emit('iscouponAd', {
  38. detail: this.iscouponAd
  39. });
  40. },
  41. // 领红包
  42. redEnvelopes() {
  43. if (!req.getStorage('userInfo')) {
  44. let params = '?couponId=' + this.couponAd.contentId
  45. req.redirectIndex(params)
  46. } else {
  47. req.postRequest('/api/coupon/receiveCoupon', {
  48. id: this.couponAd.contentId
  49. }, data => {
  50. // console.log(data)
  51. if (data == 1) {
  52. this.setData({
  53. iscouponAd: false
  54. })
  55. return req.msg('领取成功')
  56. }
  57. })
  58. // console.log(1233)
  59. }
  60. // req.isLogin().then(success => {
  61. // console.log(success)
  62. // if (success) {
  63. // this.setData({iscouponAd:false})
  64. // }
  65. // })
  66. },
  67. }
  68. };
  69. </script>
  70. <style>
  71. @import "./index.css";
  72. </style>