jfhz.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <view class="content">
  3. <view class="item flex">
  4. <view class="tit">
  5. 可兑换{{type == 1 ? '商城积分': '通证积分'}}
  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. }
  41. this.passUser()
  42. },
  43. onShow() {
  44. },
  45. onReachBottom() {
  46. },
  47. onReady() {
  48. },
  49. methods: {
  50. passUser() {
  51. passUser().then(res => {
  52. this.loading = false
  53. if(this.type == 1) {
  54. this.allNum = res.data.integral*1
  55. }else {
  56. this.allNum = res.data.pass ? res.data.pass:0
  57. }
  58. })
  59. },
  60. getAll() {
  61. this.num = this.allNum
  62. },
  63. tradeMoney() {
  64. //
  65. let that = this
  66. if(!that.num) {
  67. return that.$api.msg('请输入兑换数量')
  68. }
  69. if(that.num > that.allNum) {
  70. return that.$api.msg('兑换数量超出可兑换数量')
  71. }
  72. that.loading = true
  73. tradeMoney({
  74. num: that.num,
  75. type: that.type
  76. }).then(res => {
  77. uni.showToast({
  78. title:'兑换成功',
  79. duration:2000
  80. });
  81. this.num = ''
  82. this.passUser()
  83. }).catch( err => {
  84. that.loading = false
  85. })
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="scss" scoped>
  91. page {
  92. height: 100%;
  93. background-color: #fff;
  94. }
  95. .item {
  96. width: 710rpx;
  97. margin: auto;
  98. background-color: #fff;
  99. height: 110rpx;
  100. border-bottom: 1px solid #E6E6E6;
  101. .tit {
  102. line-height: 110rpx;
  103. font-size: 32rpx;
  104. }
  105. input {
  106. text-align: right;
  107. font-size: 36rpx;
  108. font-weight: bold;
  109. color: #333333;
  110. }
  111. }
  112. .all {
  113. padding: 20rpx;
  114. text-align: right;
  115. font-size: 26rpx;
  116. font-weight: 500;
  117. color: #FF4C4C;
  118. }
  119. .btn {
  120. width: 670rpx;
  121. line-height: 88rpx;
  122. background: #FF4C4C;
  123. border-radius: 10rpx;
  124. font-size: 32rpx;
  125. font-weight: bold;
  126. color: #FFFFFF;
  127. text-align: center;
  128. margin: 60rpx auto;
  129. }
  130. </style>