qdwallet.vue 5.9 KB

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