wallet.vue 6.3 KB

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