buling.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <view class="container">
  3. <navBar :show-title="true" :title="$t('user.闪兑')" url="/pages/index/index"></navBar>
  4. <view class="content">
  5. <view class="title">
  6. {{$t('user.兑换')}}
  7. </view>
  8. <view class="item">
  9. <view class="flex">
  10. <view class="flex">
  11. <image class="topIcon" src="../../static/img/nav01.png" mode="scaleToFill"></image>
  12. <view class="text">
  13. BCMM
  14. </view>
  15. </view>
  16. <view class="money">
  17. {{$t('user.余额')}}:{{userInfo.BCMM*1}}
  18. </view>
  19. </view>
  20. <view class="flex input">
  21. <input placeholder-class="placeholder" placeholder="请填写花费数量" class="num" v-model="bcmm"
  22. type="number" />
  23. <view class="tipText" @click="bcmm = userInfo.BCMM*1">
  24. MAX
  25. </view>
  26. </view>
  27. </view>
  28. <view class="imageTab">
  29. <image class="tabIcon" src="../../static/img/tarIcon.png" mode="scaleToFill"></image>
  30. </view>
  31. <view class="item">
  32. <view class="flex">
  33. <view class="flex">
  34. <image class="topIcon" src="../../static/img/homeUSDT.png" mode="scaleToFill"></image>
  35. <view class="text">
  36. USDT
  37. </view>
  38. </view>
  39. <view class="money">
  40. {{$t('user.余额')}}:{{userInfo.USDT*1}}
  41. </view>
  42. </view>
  43. <view class="flex input">
  44. <input disabled placeholder-class="placeholder" placeholder="填写BCMM自动计算" v-model="usdt" class="num"
  45. type="number" />
  46. <view class="tipText">
  47. MAX
  48. </view>
  49. </view>
  50. </view>
  51. <view class="bottomText">
  52. {{$t('user.兑换比率')}}:1BCMM≈{{bl}}USDT
  53. </view>
  54. <view class="buttomBtn" @click="buttomBtn">
  55. {{$t('user.立即兑换')}}
  56. </view>
  57. </view>
  58. </view>
  59. </template>
  60. <script>
  61. import {
  62. mapState,
  63. mapMutations
  64. } from "vuex";
  65. import {
  66. loadIndexs,
  67. exchange
  68. } from '@/api/index.js';
  69. import {
  70. getUserInfo
  71. } from '@/api/user.js';
  72. import navBar from "@/components/nav/nav.vue"
  73. export default {
  74. data() {
  75. return {
  76. usdt: '',
  77. bcmm: '',
  78. bl: 0,
  79. }
  80. },
  81. watch: {
  82. bcmm(newValue, oldValue) {
  83. this.usdt = newValue * this.bl;
  84. }
  85. },
  86. components: {
  87. navBar
  88. },
  89. computed: {
  90. ...mapState("user", ['userInfo']),
  91. },
  92. onLoad(option) {
  93. this.getUserInfo();
  94. this.loadData();
  95. },
  96. methods: {
  97. ...mapMutations('user', ['setUserInfo']),
  98. buttomBtn() {
  99. if(this.bcmm>this.userInfo.BCMM*1){
  100. uni.showToast({
  101. title: this.$t('home.BCMM余额不足'),
  102. icon: 'error'
  103. })
  104. return
  105. }
  106. uni.showLoading({
  107. mask: true
  108. });
  109. exchange({
  110. num: this.bcmm
  111. }).then((res) => {
  112. this.bl = res.data.price;
  113. uni.showToast({
  114. title: this.$t('user.兑换成功'),
  115. })
  116. }).catch((res) => {
  117. uni.showToast({
  118. title: this.$t('user.兑换失败'),
  119. icon: 'error'
  120. })
  121. console.log(res);
  122. })
  123. },
  124. loadData() {
  125. loadIndexs().then((res) => {
  126. this.bl = res.data.price;
  127. }).catch((res) => {
  128. console.log(res);
  129. })
  130. },
  131. // 获取更新用户信息
  132. getUserInfo() {
  133. getUserInfo().then((res) => {
  134. this.setUserInfo(res.data);
  135. }).catch((res) => {
  136. console.log(res);
  137. })
  138. },
  139. },
  140. }
  141. </script>
  142. <style lang="scss">
  143. .container {
  144. width: 100%;
  145. line-height: 1;
  146. background-color: rgb(12, 8, 21);
  147. min-height: 100vh;
  148. }
  149. .content {
  150. margin: 25rpx;
  151. border-radius: 20px;
  152. border: 2px solid transparent;
  153. background-clip: padding-box, border-box;
  154. background-origin: padding-box, border-box;
  155. background-image: linear-gradient(270deg, #0c0815, #0c0815), linear-gradient(to right, #7D32FF, #3EE0FF);
  156. padding: 56rpx;
  157. .bottomText {
  158. font-weight: 500;
  159. font-size: 30rpx;
  160. color: #FFFFFF;
  161. padding: 50rpx 0;
  162. }
  163. .title {
  164. color: #FFF;
  165. font-weight: bold;
  166. font-size: 34rpx;
  167. padding-bottom: 30rpx;
  168. }
  169. .buttomBtn {
  170. background: linear-gradient(90deg, #7D32FF, #3EE0FF);
  171. border-radius: 10rpx;
  172. font-weight: bold;
  173. font-size: 32rpx;
  174. color: #FFFFFF;
  175. text-align: center;
  176. width: 100%;
  177. padding: 26rpx;
  178. }
  179. .item {
  180. color: #FFF;
  181. font-size: 30rpx;
  182. font-weight: 500;
  183. background-color: #2A2C39;
  184. padding: 50rpx 30rpx;
  185. border-radius: 30rpx;
  186. .topIcon {
  187. width: 50rpx;
  188. height: 50rpx;
  189. margin-right: 10rpx;
  190. }
  191. .input {
  192. margin-top: 100rpx;
  193. .num {
  194. text-align: center;
  195. }
  196. }
  197. }
  198. }
  199. .tipText {
  200. font-weight: bold;
  201. font-size: 28rpx;
  202. background: linear-gradient(to right, #7D32FF 0%, #3EE0FF 100%);
  203. background-clip: text;
  204. color: rgba(0, 0, 0, 0);
  205. }
  206. .imageTab {
  207. text-align: center;
  208. margin-top: -30rpx;
  209. margin-bottom: -30rpx;
  210. .tabIcon {
  211. width: 85rpx;
  212. height: 85rpx;
  213. }
  214. }
  215. </style>