takeReward.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <div class="jingpai-toast-mask">
  3. <div class="jingpai-toast z100" v-if="rewardRec">
  4. <p>{{$t('auction.text6')}}#{{rewardRec.actId}}{{$t('auction.text9')}}</p>
  5. <p>{{$t('auction.text10')}} {{rewardRec.return_eos / 10000}} EOS</p>
  6. <button @click="handleReward">{{$t('auction.takeBtn')}}</button>
  7. </div>
  8. <div class="jingpai-toast" v-if="rewardGt">
  9. <p>{{$t('auction.text5')}}#{{rewardGt.act_id}}{{$t('auction.text7')}}</p>
  10. <p>{{$t('auction.text8')}} {{rewardGt.return_gt / 10000}} GT</p>
  11. <button @click="handleRewardGt">{{$t('auction.confirmBtn')}}</button>
  12. </div>
  13. </div>
  14. </template>
  15. <script>
  16. import API from '@/api'
  17. import NP from 'number-precision'
  18. export default {
  19. name: 'takeReward',
  20. props: ['rewardRec', 'rewardGt'],
  21. data () {
  22. return {
  23. }
  24. },
  25. computed: {
  26. auctionInfo () {
  27. return this.$store.state.auctionInfo
  28. },
  29. account () {
  30. return this.$store.state.account
  31. },
  32. eos () {
  33. return this.$store.state.eos
  34. }
  35. },
  36. methods: {
  37. // 领取奖励
  38. handleReward () {
  39. var takeReward = () => {
  40. let params = {
  41. actId: this.rewardRec.actId
  42. }
  43. this.$showLoading()
  44. API.auction.takeReward(params).then(({ data }) => {
  45. this.$hideLoading()
  46. if (data.code === 0) {
  47. this.$emit('closeEosReward')
  48. if (this.rewardRec.return_eos) {
  49. let amount = this.rewardRec.return_eos
  50. this.$store.commit('updateBalance', amount)
  51. }
  52. this.$showTips(this.$t('auction.reward'))
  53. }
  54. }).catch(() => {
  55. this.$emit('closeEosReward')
  56. this.$hideLoading()
  57. })
  58. }
  59. this.$store.dispatch('doGameLogin').then(data => {
  60. takeReward()
  61. })
  62. },
  63. handleRewardGt () {
  64. this.$showLoading()
  65. let params = {
  66. tipType: 'auction_loser_gt_return',
  67. player: this.account.name || null
  68. }
  69. API.auction.toggleReadTip(params).then(({ data }) => {
  70. let amount = this.rewardGt.return_gt
  71. this.$store.commit('updateGt', NP.divide(amount, 10000))
  72. this.$emit('closeGtReward')
  73. this.$hideLoading()
  74. }).catch(() => {
  75. this.$hideLoading()
  76. this.$emit('closeGtReward')
  77. })
  78. }
  79. },
  80. created () {
  81. }
  82. }
  83. </script>
  84. <style lang="scss">
  85. .jingpai-toast-mask{
  86. position: fixed;
  87. top: 0;
  88. left: 0;
  89. right: 0;
  90. bottom: 0;
  91. background-color: rgba($color: #000000, $alpha: .5);
  92. z-index: 200;
  93. .z100{
  94. z-index: 100;
  95. }
  96. }
  97. .jingpai-toast{
  98. position: absolute;
  99. background: url('img/jingpai-tip-bg.png') no-repeat;
  100. background-size: 100%;
  101. width: px2rem(506);
  102. height: px2rem(260);
  103. left: 50%;
  104. top: px2rem(300);
  105. margin-left: -px2rem(253);
  106. font-size: px2rem(26);
  107. color: #fff;
  108. padding: px2rem(60) 0 px2rem(40) 0;
  109. p{
  110. text-align: center;
  111. margin-bottom: px2rem(20);
  112. &:nth-child(2) {
  113. margin-bottom: px2rem(40);
  114. }
  115. }
  116. >button{
  117. display: block;
  118. background-color: #e98d2b;
  119. width: px2rem(180);
  120. height: px2rem(50);
  121. line-height: px2rem(50);
  122. margin: 0 auto;
  123. text-align: center;
  124. color: #ffffff;
  125. border: none;
  126. outline: none;
  127. border-radius: 8px;
  128. cursor: pointer;
  129. font-size: px2rem(22);
  130. &:hover{
  131. background-color: #dd9c56;
  132. }
  133. }
  134. }
  135. </style>