changeWallet.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view class="content">
  3. <view class="listBox">
  4. <view class="list">
  5. <view class="flex listItem" @click="navTo('/pages/set/userinfo')">
  6. <view class="flex titleBox">
  7. <text class="title">可兑换金额</text>
  8. </view>
  9. <view class="right flex">
  10. <text>{{ userInfo.brokerage_price | getMoneyStyle}}</text>
  11. <!-- <image class="img" src="../../static/icon/next1.png" mode="widthFix"></image> -->
  12. </view>
  13. </view>
  14. <view class="flex listItem">
  15. <view class="flex titleBox">
  16. <text class="title">申请转换金额</text>
  17. </view>
  18. <view class="right flex">
  19. <input class="input" type="text" v-model="withdrawal" placeholder="请输入金额" placeholder-class="placeholder" />
  20. </view>
  21. </view>
  22. <view class="all" @click="withdrawal=userInfo.brokerage_price">
  23. 全部转换
  24. </view>
  25. </view>
  26. </view>
  27. <button class="base-buttom" :class="{ action: loding }" @click="!loding ? confirm() : ''">提交申请</button>
  28. </view>
  29. </template>
  30. <script>
  31. import {
  32. getMoneyStyle
  33. } from '@/utils/rocessor.js';
  34. import {
  35. getUserInfo,
  36. } from '@/api/user.js';
  37. import {
  38. rechargeWechat
  39. } from '@/api/wallet.js'
  40. import {
  41. mapMutations,
  42. mapState
  43. } from 'vuex';
  44. export default {
  45. filters: {
  46. getMoneyStyle
  47. },
  48. data() {
  49. return {
  50. money: '0.00', //可提现金额
  51. withdrawal: '', //提现金额
  52. // #ifdef H5
  53. weichatBsrowser: false,
  54. // #endif
  55. loding: false,
  56. type: 0
  57. };
  58. },
  59. onLoad(options) {
  60. // #ifdef H5
  61. this.weichatBsrowser = uni.getStorageSync('weichatBrowser');
  62. // #endif
  63. this.dataUp();
  64. if (options.type) {
  65. this.type = options.type;
  66. }
  67. },
  68. computed: {
  69. ...mapState('user', ['userInfo'])
  70. },
  71. methods: {
  72. ...mapMutations('user', ['setUserInfo', 'login']),
  73. // 更新数据
  74. dataUp() {
  75. let obj = this;
  76. getUserInfo({})
  77. .then(e => {
  78. obj.login();
  79. // 保存返回用户数据
  80. obj.setUserInfo(e.data);
  81. })
  82. .catch(e => {
  83. console.log(e);
  84. });
  85. },
  86. // 切换选中对象
  87. tabRadio(e) {
  88. this.type = e.detail.value;
  89. },
  90. // 提交
  91. confirm() {
  92. let obj = this;
  93. obj.loding = true;
  94. if (obj.withdrawal == 0) {
  95. obj.loding = false;
  96. uni.showModal({
  97. title: '提示',
  98. content: '转换金额不要为0'
  99. });
  100. return;
  101. }
  102. let data = {
  103. from: 'weixinh5', //
  104. price: obj.withdrawal, //金额
  105. type: 1 //0佣金1余额
  106. };
  107. rechargeWechat(data)
  108. .then(e => {
  109. // 允许按钮点击
  110. obj.loding = false;
  111. // 初始化提现金额
  112. obj.withdrawal = '';
  113. uni.showToast({
  114. title: '转换成功',
  115. duration: 2000,
  116. position: 'top'
  117. });
  118. obj.dataUp();
  119. })
  120. .catch(e => {
  121. obj.$api.msg(e.msg);
  122. obj.loding = false;
  123. console.log();
  124. });
  125. },
  126. }
  127. };
  128. </script>
  129. <style lang="scss">
  130. page {
  131. height: 100%;
  132. }
  133. .listBox {
  134. overflow: hidden;
  135. background-color: #FFFFFF;
  136. }
  137. .list {
  138. .all{
  139. text-align: right;
  140. padding: 20rpx 30rpx;
  141. font-size: $font-base;
  142. color: $uni-color-primary;
  143. }
  144. .listItem {
  145. padding: 35rpx 40rpx;
  146. border-bottom: 1px solid $page-color-light;
  147. }
  148. .listIconImg {
  149. width: 36rpx;
  150. }
  151. .right {
  152. color: $font-color-light;
  153. font-size: $font-base;
  154. flex-grow: 1;
  155. justify-content: flex-end;
  156. .img {
  157. width: 26rpx;
  158. }
  159. }
  160. .input {
  161. flex-grow: 1;
  162. text-align: right;
  163. font-size: $font-base;
  164. color: $color-gray;
  165. }
  166. .titleBox {
  167. .title {
  168. color: $font-color-base;
  169. font-size: $font-base;
  170. }
  171. }
  172. }
  173. </style>