Detail.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <home-base :show="false" ><view class="div distributor-article-list">
  3. <title-header />
  4. <view class="div detail_bg" :style="'background-image:url('+detailbg+')'">
  5. <view class="div red_packet">
  6. <text class="span" :class="red_packet_bg"></text>
  7. <text class="button" @click="receiveBonus(bonus)" v-if="!message">领取红包</text>
  8. <view class="div red-jg" v-if="message">
  9. <text class="h1">恭喜您!</text>
  10. <text class="h5">{{ message }}</text>
  11. </view>
  12. </view>
  13. <view class="p tips">领取的红包将转入到商城预存款</view>
  14. <view class="p rule" @click="goMemberBonusreceive">查看领取记录</view>
  15. <view class="div bonus-info" v-if="bonus">
  16. <view class="p">红包名称:{{bonus.bonus_name}}</view>
  17. <view class="p">红包祝福语:{{bonus.bonus_blessing}}</view>
  18. <view class="p">红包有效时间:{{bonus.bonus_begintime_text}}至{{bonus.bonus_endtime_text}}</view>
  19. </view>
  20. </view>
  21. </view></home-base>
  22. </template>
  23. <script>
  24. import {getFontSize} from '@/util/common'
  25. import TitleHeader from '../../TitleHeader'
  26. import HomeBase from '../HomeBase'
  27. import { env } from '../../../static/config'
  28. import { getBonusDetail, receiveBonus } from '../../../api/homeBonus'
  29. export default {
  30. name: 'Bonusdetail',
  31. computed:{
  32. fontSize(){
  33. return getFontSize()
  34. },
  35. },
  36. data(){
  37. return {
  38. bonus: '',
  39. bonusreceive_list: '',
  40. message: '',
  41. red_packet_bg: 'bg-w', // 背景图
  42. detailbg:env.SITE_URL+'/uploads/home/h5/home/home-bonus-bg.png'
  43. }
  44. },
  45. components:{
  46. TitleHeader,
  47. HomeBase,
  48. },
  49. onLoad: function (option) {
  50. let bonus_id = option.bonus_id
  51. getBonusDetail(bonus_id)
  52. .then(res => {
  53. this.bonus = res.result.bonus
  54. this.bonusreceive_list = res.result.bonusreceive_list
  55. })
  56. .catch(function (error) {
  57. uni.showToast({icon:'none',title: error.message})
  58. })
  59. },
  60. methods: {
  61. receiveBonus (bonus) {
  62. receiveBonus(bonus.bonus_id)
  63. .then(res => {
  64. this.message = res.message
  65. this.red_packet_bg = 'bg-y'
  66. // uni.showToast({icon:'none',title: res.message})
  67. })
  68. .catch(function (error) {
  69. uni.showToast({icon:'none',title: error.message})
  70. })
  71. },
  72. goMemberBonusreceive () {
  73. uni.navigateTo({url:'/pages/member/bonusreceive/Bonusreceive'})
  74. }
  75. }
  76. }
  77. </script>
  78. <style scoped lang="scss">
  79. .detail_bg {
  80. background-size: 100% 100%;
  81. position: absolute;
  82. width: 100%;
  83. height: 100%;
  84. top: 0;
  85. left: 0;
  86. }
  87. .red_packet {
  88. margin: 2rem 20% 1rem 20%;
  89. width: 60%;
  90. position: relative;
  91. padding-top: 100%;
  92. }
  93. .red_packet .span {
  94. width: 100%;
  95. height: 100%;
  96. background-size: 100%;
  97. background-position: center;
  98. background-repeat: no-repeat;
  99. top: 0;
  100. left: 0;
  101. position: absolute;
  102. }
  103. .red_packet .button {
  104. position: absolute;
  105. top: 38%;
  106. left: 30%;
  107. font-size:$subFontSize;
  108. display:flex;align-items:center;justify-content:center;
  109. width: 40%;
  110. height: 24%;
  111. border-radius: 100%;
  112. background: #fdc339;
  113. color: #fff;
  114. border: none;
  115. }
  116. .red_packet .red-jg {
  117. position: absolute;
  118. top: 40%;
  119. text-align: center;
  120. width: 100%;
  121. }
  122. .red_packet .red-jg > .h1 {
  123. font-size:$h1;
  124. color: #ffc000;
  125. line-height: 2rem;
  126. }
  127. .red_packet .red-jg > .h5 {
  128. color: #fff;
  129. font-size:$subFontSize;
  130. }
  131. .bg-w {
  132. background-image: url("../../../static/image/home/home-bonus-red-w.png");
  133. }
  134. .bg-y {
  135. background-image: url("../../../static/image/home/home-bonus-red-y.png");
  136. }
  137. .tips {
  138. font-size:$subFontSize;
  139. color: #bf6b1d;
  140. text-align: center;
  141. }
  142. .rule {
  143. font-size:$fontSize;
  144. color: #bf6b1d;
  145. text-align: center;
  146. margin-top: 0.4rem;
  147. }
  148. .bonus-info{color: #bf6b1d;padding:0 1rem;margin-top:1rem;font-size:$fontSize;line-height:1rem;}
  149. .bonus-info .p{}
  150. </style>