candy.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <view class="center">
  3. <view class="content-money">
  4. <view class="buttom">
  5. <text class="text">可兑换{{ type_name }}数量</text>
  6. <view class="icon">{{ money }}</view>
  7. </view>
  8. <view class="interval"></view>
  9. <view class="buttom">
  10. <text class="text">申请兑换{{ type_name }}数量</text>
  11. <view class=" icon"><input class="input" type="number" v-model="withdrawal" placeholder="申请兑换积分数量" placeholder-class="placeholder" /></view>
  12. </view>
  13. <view class="interval"></view>
  14. <view class="buttom">
  15. <text class="text">可兑换成</text>
  16. <view class="input">{{ moneyReta }}糖果</view>
  17. </view>
  18. <view class="interval"></view>
  19. <view class="tip">
  20. <view class=" tip-icon" @click="allbuy()">全部转换</view>
  21. </view>
  22. </view>
  23. <view class="code">
  24. </view>
  25. <view class="btn" @click="buy()">
  26. 提交申请
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import { wallet,shan } from '@/api/finance.js';
  32. export default {
  33. data(){
  34. return{
  35. money: 0,
  36. withdrawal: "",
  37. buying: false,
  38. all:'',
  39. add:'',
  40. type: '',
  41. type_name:'',
  42. }
  43. },
  44. computed: {
  45. // 转换金额
  46. moneyReta() {
  47. // 保存当前选中的对象
  48. const obj = this.all;
  49. return (this.withdrawal * +obj.usdt_price) / +this.add.usdt_price;
  50. },
  51. },
  52. onLoad(option) {
  53. if(option.type){
  54. this.type = option.type
  55. }
  56. wallet({}).then(({ data }) => {
  57. const obj = this
  58. const arr = Object.keys(data.back);
  59. arr.forEach(e => {
  60. if(e == obj.type){
  61. obj.money = (data.back[e].money.money*1)
  62. obj.type_name = data.back[e].name
  63. obj.all = data.back[e]
  64. }
  65. if(e == 'LALA'){
  66. obj.money = (data.back[e].money.money*1)
  67. obj.add = data.back[e]
  68. }
  69. });
  70. });
  71. },
  72. methods:{
  73. allbuy(){
  74. this.withdrawal = this.money
  75. },
  76. buy(){
  77. if (this.buying) {
  78. console.log(1)
  79. } else {
  80. if(this.withdrawal == 0 ){
  81. this.$api.msg('提币数量不能为0')
  82. return
  83. }
  84. this.buying = true
  85. shan({
  86. origin_money_type: this.type,
  87. money_type: this.add.code,
  88. num: this.withdrawal,
  89. }).then(({
  90. data
  91. }) => {
  92. console.log(data)
  93. this.buying = false
  94. uni.navigateTo({
  95. url:'/pages/money/success'
  96. })
  97. // this.$api.msg("闪兑成功")
  98. }).catch(e => {
  99. this.buying = false
  100. console.log(e)
  101. })
  102. }
  103. }
  104. },
  105. }
  106. </script>
  107. <style lang="scss">
  108. page,.center {
  109. height: 100%;
  110. background: #FFFFFF;
  111. }
  112. .content-money {
  113. padding: 0 20rpx;
  114. background-color: #ffffff;
  115. .buttom {
  116. display: flex;
  117. justify-content: space-between;
  118. align-items: center;
  119. height: 110rpx;
  120. }
  121. .interval {
  122. width: 100%;
  123. height: 1px;
  124. background: #E6E6E6;
  125. }
  126. .icon {
  127. text-align: right;
  128. width: 50%;
  129. font-size: 48rpx;
  130. font-family: SourceHanSansCN;
  131. font-weight: 500;
  132. color: #333333;
  133. text{
  134. font-size: 32rpx;
  135. }
  136. .input {
  137. text-align: right;
  138. flex: 1;
  139. font-size: 30rpx;
  140. color: $font-color-dark;
  141. }
  142. .iconlocation {
  143. text-align: right;
  144. font-size: 36rpx;
  145. color: $font-color-light;
  146. }
  147. }
  148. .text {
  149. font-size: 32rpx;
  150. font-family: PingFang SC;
  151. font-weight: 500;
  152. color: #333333;
  153. }
  154. .tip {
  155. height: 74rpx;
  156. display: flex;
  157. justify-content: flex-end;
  158. align-items: center;
  159. .tip-text {
  160. font-size: 24rpx;
  161. font-family: PingFang SC;
  162. font-weight: 500;
  163. color: #999999;
  164. }
  165. .tip-icon {
  166. font-size: 26rpx;
  167. font-family: SourceHanSansCN;
  168. font-weight: 400;
  169. color: #EF041F;
  170. }
  171. }
  172. }
  173. .btn {
  174. text-align: center;
  175. margin: 134rpx auto;
  176. width: 670rpx;
  177. height: 88rpx;
  178. background: linear-gradient(0deg, #2E58FF, #32C6FF);
  179. border-radius: 10px;
  180. text-align: center;
  181. line-height: 88rpx;
  182. font-size: 32rpx;
  183. font-family: SourceHanSansCN;
  184. font-weight: 500;
  185. color: #FEFEFE;
  186. }
  187. .code {
  188. width: 750rpx;
  189. height: 20rpx;
  190. background: #F7F7F7;
  191. }
  192. </style>