buling.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  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. uni.showToast({
  113. title: this.$t('user.兑换成功'),
  114. })
  115. this.bcmm='';
  116. this.getUserInfo();
  117. }).catch((res) => {
  118. console.log(res)
  119. uni.showToast({
  120. title: this.$t('user.兑换失败'),
  121. icon: 'error'
  122. })
  123. console.log(res);
  124. })
  125. },
  126. loadData() {
  127. loadIndexs().then((res) => {
  128. this.bl = res.data.price;
  129. }).catch((res) => {
  130. console.log(res);
  131. })
  132. },
  133. // 获取更新用户信息
  134. getUserInfo() {
  135. getUserInfo().then((res) => {
  136. this.setUserInfo(res.data);
  137. }).catch((res) => {
  138. console.log(res);
  139. })
  140. },
  141. },
  142. }
  143. </script>
  144. <style lang="scss">
  145. .container {
  146. width: 100%;
  147. line-height: 1;
  148. background-color: rgb(12, 8, 21);
  149. min-height: 100vh;
  150. }
  151. .content {
  152. margin: 25rpx;
  153. border-radius: 20px;
  154. border: 2px solid transparent;
  155. background-clip: padding-box, border-box;
  156. background-origin: padding-box, border-box;
  157. background-image: linear-gradient(270deg, #0c0815, #0c0815), linear-gradient(to right, #7D32FF, #3EE0FF);
  158. padding: 56rpx;
  159. .bottomText {
  160. font-weight: 500;
  161. font-size: 30rpx;
  162. color: #FFFFFF;
  163. padding: 50rpx 0;
  164. }
  165. .title {
  166. color: #FFF;
  167. font-weight: bold;
  168. font-size: 34rpx;
  169. padding-bottom: 30rpx;
  170. }
  171. .buttomBtn {
  172. background: linear-gradient(90deg, #7D32FF, #3EE0FF);
  173. border-radius: 10rpx;
  174. font-weight: bold;
  175. font-size: 32rpx;
  176. color: #FFFFFF;
  177. text-align: center;
  178. width: 100%;
  179. padding: 26rpx;
  180. }
  181. .item {
  182. color: #FFF;
  183. font-size: 30rpx;
  184. font-weight: 500;
  185. background-color: #2A2C39;
  186. padding: 50rpx 30rpx;
  187. border-radius: 30rpx;
  188. .topIcon {
  189. width: 50rpx;
  190. height: 50rpx;
  191. margin-right: 10rpx;
  192. }
  193. .input {
  194. margin-top: 100rpx;
  195. .num {
  196. text-align: center;
  197. }
  198. }
  199. }
  200. }
  201. .tipText {
  202. font-weight: bold;
  203. font-size: 28rpx;
  204. background: linear-gradient(to right, #7D32FF 0%, #3EE0FF 100%);
  205. background-clip: text;
  206. color: rgba(0, 0, 0, 0);
  207. }
  208. .imageTab {
  209. text-align: center;
  210. margin-top: -30rpx;
  211. margin-bottom: -30rpx;
  212. .tabIcon {
  213. width: 85rpx;
  214. height: 85rpx;
  215. }
  216. }
  217. </style>