jfhz.vue 2.8 KB

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