jfhz.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <view class="content">
  3. <view class="tip" v-if="type == 3">
  4. 阅读积分兑换余额宝手续费为{{pUser.fee_ratio}}%
  5. </view>
  6. <view class="tip" v-if="type == 0">
  7. 通证兑换阅读积分比例为{{pUser.points_transaction}}:1
  8. </view>
  9. <view class="item flex">
  10. <view class="tit">
  11. 可兑换{{type == 1 ? '商城积分': (type== 3?'阅读积分':(type == 2? '余额宝': '通证积分'))}}
  12. </view>
  13. <input type="text" placeholder="" v-model="allNum" disabled />
  14. </view>
  15. <view class="item flex">
  16. <view class="tit">
  17. 申请兑换数量
  18. </view>
  19. <input type="text" placeholder="请输入申请兑换数量" v-model="num" />
  20. </view>
  21. <view class="all" @click="getAll">
  22. 全部兑换
  23. </view>
  24. <view class="btn" @click="tradeMoney">
  25. 立即兑换
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. // tradeMoney
  31. import {
  32. tradeMoney,
  33. passUser
  34. } from '@/api/zero.js'
  35. export default {
  36. data() {
  37. return {
  38. type: 0, // 0 通证-》阅读 1 商城-》复投
  39. num: '',
  40. allNum: 0,
  41. pUser: {}
  42. }
  43. },
  44. onLoad(opt) {
  45. this.type = opt.type
  46. if (this.type == 1) {
  47. uni.setNavigationBarTitle({
  48. title: '兑换复投积分'
  49. })
  50. } else if (this.type == 3) {
  51. uni.setNavigationBarTitle({
  52. title: '兑换余额宝'
  53. })
  54. } else if (this.type == 2) {
  55. uni.setNavigationBarTitle({
  56. title: '兑换阅读积分'
  57. })
  58. }
  59. this.passUser()
  60. },
  61. onShow() {
  62. },
  63. onReachBottom() {
  64. },
  65. onReady() {
  66. },
  67. methods: {
  68. passUser() {
  69. passUser().then(res => {
  70. this.loading = false
  71. this.pUser = res.data
  72. if (this.type == 1) {
  73. this.allNum = res.data.integral * 1
  74. } else if (this.type == 3) {
  75. this.allNum = res.data.points * 1
  76. } else if (this.type == 2) {
  77. this.allNum = res.data.freeze_points * 1
  78. } else {
  79. this.allNum = res.data.pass ? res.data.pass : 0
  80. }
  81. })
  82. },
  83. getAll() {
  84. this.num = this.allNum
  85. },
  86. tradeMoney() {
  87. //
  88. let that = this
  89. if (!that.num) {
  90. return that.$api.msg('请输入兑换数量')
  91. }
  92. if (that.num > that.allNum) {
  93. return that.$api.msg('兑换数量超出可兑换数量')
  94. }
  95. that.loading = true
  96. tradeMoney({
  97. num: that.num,
  98. type: that.type
  99. }).then(res => {
  100. uni.showToast({
  101. title: '兑换成功',
  102. duration: 2000
  103. });
  104. this.num = ''
  105. this.passUser()
  106. }).catch(err => {
  107. that.loading = false
  108. })
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. page {
  115. height: 100%;
  116. background-color: #fff;
  117. }
  118. .item {
  119. width: 710rpx;
  120. margin: auto;
  121. background-color: #fff;
  122. height: 110rpx;
  123. border-bottom: 1px solid #E6E6E6;
  124. .tit {
  125. line-height: 110rpx;
  126. font-size: 32rpx;
  127. }
  128. input {
  129. text-align: right;
  130. font-size: 36rpx;
  131. font-weight: bold;
  132. color: #333333;
  133. }
  134. }
  135. .all {
  136. padding: 20rpx;
  137. text-align: right;
  138. font-size: 26rpx;
  139. font-weight: 500;
  140. color: #FF4C4C;
  141. }
  142. .btn {
  143. width: 670rpx;
  144. line-height: 88rpx;
  145. background: #FF4C4C;
  146. border-radius: 10rpx;
  147. font-size: 32rpx;
  148. font-weight: bold;
  149. color: #FFFFFF;
  150. text-align: center;
  151. margin: 60rpx auto;
  152. }
  153. .tip {
  154. padding: 5rpx;
  155. padding-left: 20rpx;
  156. background-color: #f2c3d1;
  157. color: #f21f5d;
  158. }
  159. </style>