wallet.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <view class="content">
  3. <view class="content-money">
  4. <view class="flex">
  5. <view class="buttom">
  6. <view class="icon">{{ money | getMoneyStyle }}</view>
  7. <text class="text">可转数量</text>
  8. </view>
  9. </view>
  10. </view>
  11. <view class="row-box">
  12. <view class="title">收款人手机号</view>
  13. <view class="row"><input class="input" type="number" v-model="card" placeholder="请输入收款人手机号"
  14. placeholder-class="placeholder" /></view>
  15. </view>
  16. <!-- <view class="row-box">
  17. <view class="title">交易密码</view>
  18. <view class="row"><input class="input" type="password" v-model="password" placeholder="请输入交易密码" placeholder-class="placeholder" /></view>
  19. </view> -->
  20. <view class="row-box">
  21. <view class="title">转账金额</view>
  22. <view class="row">
  23. <!-- <text class="tit">¥</text> -->
  24. <input class="input" type="number" v-model="withdrawal" placeholder="转入金额"
  25. placeholder-class="placeholder" />
  26. <view class="buttom" @click="withdrawal = money">全部转账</view>
  27. </view>
  28. </view>
  29. <button class="add-btn up" :class="{ action: loding }" @click="!loding ? confirm() : ''">提交</button>
  30. </view>
  31. </template>
  32. <script>
  33. import {
  34. getMoneyStyle
  35. } from '@/utils/rocessor.js';
  36. import {
  37. getUserInfo,
  38. transfer_accounts
  39. } from '@/api/user.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. password: '', //支付密码
  53. card: '', //转账卡号
  54. name: '',
  55. // #ifdef H5
  56. weichatBsrowser: false,
  57. // #endif
  58. loding: false,
  59. type: ''
  60. };
  61. },
  62. onLoad(options) {
  63. // #ifdef H5
  64. this.weichatBsrowser = uni.getStorageSync('weichatBrowser');
  65. // #endif
  66. this.type = options.type;
  67. this.dataUp();
  68. },
  69. computed: {
  70. ...mapState('user', ['userInfo'])
  71. },
  72. methods: {
  73. ...mapMutations('user', ['setUserInfo', 'login']),
  74. // 更新数据
  75. dataUp() {
  76. let obj = this;
  77. getUserInfo({})
  78. .then(e => {
  79. // 保存返回用户数据
  80. obj.setUserInfo(e.data);
  81. this.money = this.userInfo.now_money;
  82. })
  83. .catch(e => {
  84. console.log(e);
  85. });
  86. },
  87. // 切换选中对象
  88. tabRadio(e) {
  89. this.type = e.detail.value;
  90. },
  91. // 提交
  92. confirm() {
  93. let obj = this;
  94. if (obj.loding) {
  95. return;
  96. }
  97. if (!obj.card) {
  98. return obj.$api.msg('请输入转入人的账户');
  99. }
  100. if (obj.withdrawal * 1 <= 0) {
  101. return obj.$api.msg('请输入转入数量');
  102. }
  103. obj.loding = true;
  104. let data = {
  105. num: obj.withdrawal * 1, //金额
  106. uid: obj.card * 1
  107. };
  108. transfer_accounts(data)
  109. .then(e => {
  110. // 允许按钮点击
  111. obj.loding = false;
  112. // 初始化提现金额
  113. obj.withdrawal = '';
  114. uni.showToast({
  115. title: '转账成功',
  116. duration: 2000,
  117. position: 'top'
  118. });
  119. obj.dataUp();
  120. })
  121. .catch(e => {
  122. obj.$api.msg(e.msg);
  123. obj.loding = false;
  124. });
  125. }
  126. }
  127. };
  128. </script>
  129. <style lang="scss">
  130. page {
  131. height: 100%;
  132. }
  133. .content-money {
  134. padding: 30rpx 0;
  135. background: #ffffff;
  136. }
  137. .item {
  138. padding: 0 $page-row-spacing;
  139. background-color: #ffffff;
  140. }
  141. .flex {
  142. background-color: #ffffff;
  143. text-align: center;
  144. margin: 0 30rpx;
  145. border-radius: $border-radius-sm;
  146. justify-content: center;
  147. .buttom {
  148. font-size: $font-lg;
  149. width: 50%;
  150. }
  151. .interval {
  152. width: 2px;
  153. height: 60rpx;
  154. background-color: #eeeeee;
  155. }
  156. .icon {
  157. background-size: 100%;
  158. font-size: 42rpx;
  159. color: $font-color-dark;
  160. font-weight: bold;
  161. background-repeat: no-repeat;
  162. background-position: center;
  163. }
  164. .text {
  165. color: $font-color-light;
  166. }
  167. }
  168. .row-box {
  169. margin-top: 30rpx;
  170. padding: 20rpx 30rpx;
  171. background: #fff;
  172. .title {
  173. font-size: $font-base + 2rpx;
  174. color: $font-color-dark;
  175. }
  176. .row {
  177. display: flex;
  178. align-items: center;
  179. position: relative;
  180. height: 80rpx;
  181. .tit {
  182. flex-shrink: 0;
  183. width: 40rpx;
  184. font-size: 30rpx;
  185. color: $font-color-dark;
  186. }
  187. .input {
  188. flex: 1;
  189. font-size: 30rpx;
  190. color: $font-color-dark;
  191. }
  192. .iconlocation {
  193. font-size: 36rpx;
  194. color: $font-color-light;
  195. }
  196. .buttom {
  197. color: #ff4c4c;
  198. font-size: $font-base;
  199. }
  200. }
  201. }
  202. .add-btn {
  203. width: 630rpx;
  204. height: 90rpx;
  205. margin: 140rpx auto;
  206. font-family: PingFang SC;
  207. font-weight: bold;
  208. background: linear-gradient(90deg, #CA57DC, #65B2E9);
  209. color: #fff;
  210. line-height: 90rpx;
  211. }
  212. .name {
  213. background: #fff;
  214. padding: 30rpx;
  215. }
  216. .list {
  217. padding-left: 30rpx;
  218. margin-top: 30rpx;
  219. background-color: #ffffff;
  220. .box {
  221. display: flex;
  222. align-items: center;
  223. width: 100%;
  224. height: 120rpx;
  225. border-bottom: 1px solid $border-color-light;
  226. .icon {
  227. font-size: 48rpx;
  228. padding-right: 20rpx;
  229. .icon-img {
  230. height: 50rpx;
  231. width: 50rpx;
  232. }
  233. }
  234. .iconweixin1 {
  235. color: #18bf16;
  236. }
  237. .iconzhifubao {
  238. color: #08aaec;
  239. }
  240. .title-box {
  241. flex-grow: 1;
  242. text-align: left;
  243. .title {
  244. font-size: $font-base + 2rpx;
  245. color: $font-color-base;
  246. }
  247. .node {
  248. font-size: $font-sm;
  249. color: $font-color-light;
  250. }
  251. }
  252. }
  253. }
  254. .tip {
  255. padding: 20rpx;
  256. color: #ff0000;
  257. }
  258. /deep/ .uni-radio-input {
  259. width: 45rpx;
  260. height: 45rpx;
  261. }
  262. </style>