withdrawal.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. <template>
  2. <view class="content">
  3. <!-- <uni-notice-bar single="true" text="每月25号到月底可提现上月结算余额"></uni-notice-bar> -->
  4. <view class="content-money">
  5. <view class="flex">
  6. <view class="buttom1">
  7. <view class="icon">{{ money | getMoneyStyle }}</view>
  8. <text class="text">可兑换余额</text>
  9. </view>
  10. </view>
  11. </view>
  12. <view class="row-box">
  13. <view class="title">兑换金额</view>
  14. <view class="row">
  15. <text class="tit">¥</text>
  16. <input class="input" type="number" v-model="withdrawal" placeholder="请输入兑换金额"
  17. placeholder-class="placeholder" />
  18. <view class="buttom" @click="withdrawal = money">全部兑换</view>
  19. </view>
  20. </view>
  21. <view class="tip" v-if="withdrawal != 0">
  22. 实际到账{{ (withdrawal * (1 - sxfl) * 1).toFixed(2) }}元,手续费{{ (withdrawal * sxfl * 1).toFixed(2) }}元</view>
  23. <!-- <view class="row-box">
  24. <view class="title">手续费</view>
  25. <view class="row">
  26. <text class="tit">¥</text>
  27. <view class="placeholder">{{ withdrawal * 0.01*charge }}</view>
  28. </view>
  29. </view> -->
  30. <!-- #ifndef MP-WEIXIN -->
  31. <view class="list">
  32. <radio-group @change="tabRadio">
  33. <label>
  34. <view class="box">
  35. <view class="icon iconfont iconweixin1"></view>
  36. <view class="title-box">
  37. <view class="title"><text>兑换至微信</text></view>
  38. </view>
  39. <view class="right">
  40. <radio value="weixin" color="#5dbc7c" :checked="type == 'weixin'" />
  41. </view>
  42. </view>
  43. </label>
  44. <label>
  45. <view class="box">
  46. <view class="icon iconfont iconzhifubao"></view>
  47. <view class="title-box">
  48. <view class="title">
  49. <text v-if="aliData.fullname">兑换至支付宝</text>
  50. <text v-else>请创建支付宝账号</text>
  51. </view>
  52. <view class="node">
  53. <text v-if="aliData.fullname">真实姓名({{ aliData.fullname }})</text>
  54. </view>
  55. </view>
  56. <view class="right">
  57. <radio value="alipay" color="#5dbc7c" :checked="type == 'alipay'" />
  58. </view>
  59. </view>
  60. </label>
  61. <label>
  62. <view class="box">
  63. <view class="icon iconfont">
  64. <image class="icon-img" src="/static/icon/i8.png" mode="aspectFit"></image>
  65. </view>
  66. <view class="title-box">
  67. <view class="title">
  68. <text v-if="bankData.bankno">{{ bankData.bank + ' ' + bankData.bankno }}</text>
  69. <text v-else>请创建银行账号</text>
  70. </view>
  71. <view class="node">
  72. <text v-if="bankData.fullname">真实姓名({{ bankData.fullname }})</text>
  73. </view>
  74. </view>
  75. <view class="right">
  76. <radio value="bank" color="#5dbc7c" :checked="type == 'bank'" />
  77. </view>
  78. </view>
  79. </label>
  80. </radio-group>
  81. </view>
  82. <!-- #endif -->
  83. <!-- <view class="row b-b" v-if="type == 'weixin'">
  84. <text class="tit">输入微信账号</text>
  85. <input class="input" type="text" v-model="weixin" placeholder="请输入微信账号" placeholder-class="placeholder" />
  86. </view> -->
  87. <button class="add-btn up" @click="confirm">提交申请</button>
  88. <button class="add-btn modified" @click="navTo('/pages/wallet/account')">账号管理</button>
  89. </view>
  90. </template>
  91. <script>
  92. import {
  93. mapState,
  94. mapMutations
  95. } from 'vuex';
  96. import {
  97. getMoneyStyle
  98. } from '@/utils/rocessor.js';
  99. import {
  100. extractCash,
  101. extractBank,
  102. aliInfo,
  103. bankInfo,
  104. userBalance
  105. } from '@/api/wallet.js';
  106. import {
  107. extract,
  108. storeIndex
  109. } from '@/api/merchant.js';
  110. import uniNoticeBar from '@/components/uni-notice-bar/uni-notice-bar.vue';
  111. export default {
  112. filters: {
  113. getMoneyStyle
  114. },
  115. components: {
  116. uniNoticeBar
  117. },
  118. data() {
  119. return {
  120. isTing: false,
  121. type: 'alipay', //提现方式
  122. money: '0.00', //可提现余额
  123. withdrawal: '', //提现金额
  124. reall: '', //实际到账
  125. sxfl: '', //手续费率
  126. aliData: {},
  127. bankData: {},
  128. weixin: '',
  129. charge: 0,
  130. // #ifdef H5
  131. weichatBsrowser: false
  132. // #endif
  133. };
  134. },
  135. onLoad(options) {
  136. // #ifdef H5
  137. this.weichatBsrowser = uni.getStorageSync('weichatBrowser');
  138. // #endif
  139. //加载提现信息
  140. this.loadData();
  141. // 加载提款账号信息
  142. this.loadAli();
  143. this.loadBank();
  144. },
  145. computed: {
  146. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  147. },
  148. methods: {
  149. // 更新数据
  150. dataUp() {
  151. this.loadAli();
  152. this.loadBank();
  153. },
  154. //加载数据
  155. async loadAli(source) {
  156. aliInfo({}).then(e => {
  157. this.aliData = e.data;
  158. });
  159. },
  160. // 加载银行卡信息
  161. async loadBank() {
  162. bankInfo({}).then(e => {
  163. this.bankData = e.data;
  164. });
  165. },
  166. // 加载余额信息
  167. async loadData() {
  168. storeIndex({}).then(({
  169. data
  170. }) => {
  171. this.money = data.balance;
  172. this.sxfl = ((data.store_info.commission * 1) / 100).toFixed(2);
  173. });
  174. },
  175. // 跳转
  176. navTo(url) {
  177. uni.navigateTo({
  178. url: url
  179. });
  180. },
  181. // 切换选中对象
  182. tabRadio(e) {
  183. this.type = e.detail.value;
  184. },
  185. // 提交
  186. confirm() {
  187. let obj = this;
  188. if (obj.isTing) {
  189. console.log('jing');
  190. return;
  191. }
  192. let data;
  193. if (obj.type1 == 'brokerage_price') {
  194. data = {
  195. extract_type: obj.type, //bank -银行卡 alipay-支付宝 weixin-微信
  196. money: obj.withdrawal //金额
  197. };
  198. } else {
  199. data = {
  200. extract_type: obj.type, //bank -银行卡 alipay-支付宝 weixin-微信
  201. money: obj.withdrawal //金额
  202. };
  203. }
  204. if (+obj.withdrawal < +obj.minPrice) {
  205. uni.showToast({
  206. title: '兑换金额不可少于' + obj.minPrice,
  207. duration: 2000,
  208. mask: false,
  209. icon: 'none'
  210. });
  211. return;
  212. }
  213. if (obj.type == 'alipay') {
  214. data.name = obj.aliData.fullname;
  215. data.alipay_code = obj.aliData.alino;
  216. }
  217. if (obj.type == 'weixin') {
  218. data.weixin = '123456';
  219. }
  220. if (obj.type == 'bank') {
  221. data.name = obj.bankData.fullname;
  222. data.bankname = obj.bankData.bank;
  223. data.cardnum = obj.bankData.bankno;
  224. }
  225. obj.isTing = true;
  226. extract(data)
  227. .then(e => {
  228. uni.showToast({
  229. title: '提交成功',
  230. duration: 2000,
  231. position: 'top'
  232. });
  233. obj.isTing = false;
  234. // 清空提现金额
  235. obj.withdrawal = '';
  236. })
  237. .catch(e => {
  238. obj.isTing = false;
  239. console.log();
  240. });
  241. }
  242. }
  243. };
  244. </script>
  245. <style lang="scss">
  246. page {
  247. height: 100%;
  248. }
  249. .content-money {
  250. padding: 30rpx 0;
  251. background: #ffffff;
  252. }
  253. .flex {
  254. background-color: #ffffff;
  255. text-align: center;
  256. margin: 0 30rpx;
  257. border-radius: $border-radius-sm;
  258. .buttom {
  259. font-size: $font-lg;
  260. width: 50%;
  261. }
  262. .buttom1 {
  263. font-size: $font-lg;
  264. width: 100%;
  265. }
  266. .interval {
  267. width: 2px;
  268. height: 60rpx;
  269. background-color: #eeeeee;
  270. }
  271. .icon {
  272. background-size: 100%;
  273. font-size: 42rpx;
  274. color: $font-color-dark;
  275. font-weight: bold;
  276. background-repeat: no-repeat;
  277. background-position: center;
  278. }
  279. .text {
  280. font-size: 30rpx;
  281. color: $font-color-light;
  282. }
  283. }
  284. .row-box {
  285. margin-top: 30rpx;
  286. padding: 20rpx 30rpx;
  287. background: #fff;
  288. .title {
  289. font-size: $font-base + 2rpx;
  290. color: $font-color-dark;
  291. }
  292. .row {
  293. display: flex;
  294. align-items: center;
  295. position: relative;
  296. height: 80rpx;
  297. .tit {
  298. flex-shrink: 0;
  299. width: 40rpx;
  300. font-size: 30rpx;
  301. color: $font-color-dark;
  302. }
  303. .input {
  304. flex: 1;
  305. font-size: 30rpx;
  306. color: $font-color-dark;
  307. }
  308. .iconlocation {
  309. font-size: 36rpx;
  310. color: $font-color-light;
  311. }
  312. .buttom {
  313. color: $font-color-spec;
  314. font-size: $font-base;
  315. }
  316. }
  317. }
  318. .tip {
  319. padding: 20rpx;
  320. color: #e51c23;
  321. }
  322. .add-btn {
  323. &.modified {
  324. color: $base-color;
  325. }
  326. &.up {
  327. background-color: $base-color;
  328. color: #fff;
  329. }
  330. display: flex;
  331. align-items: center;
  332. justify-content: center;
  333. width: 690rpx;
  334. height: 80rpx;
  335. margin: 0 auto;
  336. margin-top: 30rpx;
  337. font-size: $font-lg;
  338. border-radius: 10rpx;
  339. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  340. }
  341. .list {
  342. padding-left: 30rpx;
  343. margin-top: 30rpx;
  344. background-color: #ffffff;
  345. .box {
  346. display: flex;
  347. align-items: center;
  348. width: 100%;
  349. height: 120rpx;
  350. border-bottom: 1px solid $border-color-light;
  351. .icon {
  352. font-size: 48rpx;
  353. padding-right: 20rpx;
  354. .icon-img {
  355. height: 50rpx;
  356. width: 50rpx;
  357. }
  358. }
  359. .iconweixin1 {
  360. color: #18bf16;
  361. }
  362. .iconzhifubao {
  363. color: #08aaec;
  364. }
  365. .title-box {
  366. flex-grow: 1;
  367. text-align: left;
  368. .title {
  369. font-size: $font-base + 2rpx;
  370. color: $font-color-base;
  371. }
  372. .node {
  373. font-size: $font-sm;
  374. color: $font-color-light;
  375. }
  376. }
  377. }
  378. }
  379. /deep/ .uni-radio-input {
  380. width: 45rpx;
  381. height: 45rpx;
  382. }
  383. .row {
  384. display: flex;
  385. align-items: center;
  386. position: relative;
  387. padding: 0 30upx;
  388. height: 110upx;
  389. background: #fff;
  390. .tit {
  391. flex-shrink: 0;
  392. width: 250upx;
  393. font-size: 30upx;
  394. color: $font-color-dark;
  395. }
  396. .input {
  397. flex: 1;
  398. font-size: 30upx;
  399. color: $font-color-dark;
  400. }
  401. .iconlocation {
  402. font-size: 36upx;
  403. color: $font-color-light;
  404. }
  405. }
  406. </style>