index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <view>
  3. <view class='cash-withdrawal'>
  4. <view class='nav acea-row'>
  5. <view v-for="(item, index) in WithdrawTypeEnum" :key="index" v-if="withdrawTypes.includes(item.type)"
  6. class='item font-color' @click="switchWithdrawType(item.type)">
  7. <view class='line bg-color' :class='withdrawType === item.type ? "on":""'></view>
  8. <view class='iconfont' :class='item.icon+" "+(withdrawType === item.type ? "on":"")'></view>
  9. <view>{{item.name}}</view>
  10. </view>
  11. </view>
  12. <view class='wrapper'>
  13. <view :hidden='withdrawType !== WithdrawTypeEnum.BANK.type' class='list'>
  14. <form @submit="subCash" report-submit='true'>
  15. <view class='item acea-row row-between-wrapper'>
  16. <view class='name'>持卡人</view>
  17. <view class='input'><input placeholder='请输入持卡人姓名' placeholder-class='placeholder' name="name"></input></view>
  18. </view>
  19. <view class='item acea-row row-between-wrapper'>
  20. <view class='name'>卡号</view>
  21. <view class='input'><input type='number' placeholder='请填写卡号' placeholder-class='placeholder' name="cardum"></input></view>
  22. </view>
  23. <view class='item acea-row row-between-wrapper'>
  24. <view class='name'>银行</view>
  25. <view class='input'>
  26. <picker @change="bindPickerChange" :value="bankIndex" range-key="label" :range="bankList">
  27. <text class='Bank'>{{bankList[bankIndex] && bankList[bankIndex].label}}</text>
  28. <text class='iconfont icon-qiepian38'></text>
  29. </picker>
  30. </view>
  31. </view>
  32. <view class='item acea-row row-between-wrapper'>
  33. <view class='name'>提现</view>
  34. <view class='input'><input :placeholder='"最低提现金额"+minPrice' placeholder-class='placeholder' name="money" type='digit'></input></view>
  35. </view>
  36. <view class='tip'>
  37. 当前可提现金额: <text class="price">¥{{ fen2yuan(commission.brokeragePrice) }},</text>冻结佣金:¥{{ fen2yuan(commission.frozenPrice) }}
  38. </view>
  39. <view class='tip'>
  40. 说明: 每笔佣金的冻结期为{{frozenDays}}天,到期后可提现
  41. </view>
  42. <button formType="submit" class='bnt bg-color'>提现</button>
  43. </form>
  44. </view>
  45. <view :hidden='withdrawType !== WithdrawTypeEnum.WECHAT.type' class='list'>
  46. <form @submit="subCash" report-submit='true'>
  47. <view class='item acea-row row-between-wrapper'>
  48. <view class='name'>账号</view>
  49. <view class='input'><input placeholder='请填写您的微信账号' placeholder-class='placeholder' name="name"></input></view>
  50. </view>
  51. <view class='item acea-row row-between-wrapper'>
  52. <view class='name'>提现</view>
  53. <view class='input'><input :placeholder='"最低提现金额" + minPrice' placeholder-class='placeholder' name="money" type='digit'></input></view>
  54. </view>
  55. <view class='item acea-row row-top row-between'>
  56. <view class='name'>收款码</view>
  57. <view class="input acea-row">
  58. <view class="picEwm" v-if="qrcodeUrlW">
  59. <image :src="qrcodeUrlW"></image>
  60. <text class='iconfont icon-guanbi1 font-color' @click='DelPicW'></text>
  61. </view>
  62. <view class='pictrue acea-row row-center-wrapper row-column' @click='uploadpic("W")' v-else>
  63. <text class='iconfont icon-icon25201'></text>
  64. <view>上传图片</view>
  65. </view>
  66. </view>
  67. </view>
  68. <view class='tip'>
  69. 当前可提现金额: <text class="price">¥{{ fen2yuan(commission.brokeragePrice) }},</text>冻结佣金:¥{{ fen2yuan(commission.frozenPrice) }}
  70. </view>
  71. <view class='tip'>
  72. 说明: 每笔佣金的冻结期为{{frozenDays}}天,到期后可提现
  73. </view>
  74. <button formType="submit" class='bnt bg-color'>提现</button>
  75. </form>
  76. </view>
  77. <view :hidden='withdrawType !== WithdrawTypeEnum.ALIPAY.type' class='list'>
  78. <form @submit="subCash" report-submit='true'>
  79. <view class='item acea-row row-between-wrapper'>
  80. <view class='name'>账号</view>
  81. <view class='input'><input placeholder='请填写您的支付宝账号' placeholder-class='placeholder' name="name"></input></view>
  82. </view>
  83. <view class='item acea-row row-between-wrapper'>
  84. <view class='name'>提现</view>
  85. <view class='input'><input :placeholder='"最低提现金额"+minPrice' placeholder-class='placeholder' name="money" type='digit'></input></view>
  86. </view>
  87. <view class='item acea-row row-top row-between'>
  88. <view class='name'>收款码</view>
  89. <view class="input acea-row">
  90. <view class="picEwm" v-if="qrcodeUrlZ">
  91. <image :src="qrcodeUrlZ"></image>
  92. <text class='iconfont icon-guanbi1 font-color' @click='DelPicZ'></text>
  93. </view>
  94. <view class='pictrue acea-row row-center-wrapper row-column' @click='uploadpic("Z")' v-else>
  95. <text class='iconfont icon-icon25201'></text>
  96. <view>上传图片</view>
  97. </view>
  98. </view>
  99. </view>
  100. <view class='tip'>
  101. 当前可提现金额: <text class="price">¥{{ fen2yuan(commission.brokeragePrice) }},</text>冻结佣金:¥{{ fen2yuan(commission.frozenPrice) }}
  102. </view>
  103. <view class='tip'>
  104. 说明: 每笔佣金的冻结期为{{frozenDays}}天,到期后可提现
  105. </view>
  106. <button formType="submit" class='bnt bg-color'>提现</button>
  107. </form>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. </template>
  113. <script>
  114. import { toLogin } from '@/libs/login.js';
  115. import { mapGetters } from "vuex";
  116. import * as TradeConfigApi from '@/api/trade/config.js';
  117. import * as BrokerageAPI from '@/api/trade/brokerage.js'
  118. import * as Util from '@/utils/util.js';
  119. import { getDicts } from "@/api/system/dict";
  120. import { DICT_TYPE, BrokerageWithdrawTypeEnum } from "@/utils/dict";
  121. export default {
  122. data() {
  123. return {
  124. WithdrawTypeEnum: BrokerageWithdrawTypeEnum,
  125. withdrawType: 0,
  126. bankIndex: 0,
  127. bankList: [], // 提现银行
  128. minPrice: 0.00, // 最低提现金额
  129. frozenDays: 0, // 佣金冻结期
  130. withdrawTypes: [], // 提现方式
  131. isClone: false,
  132. commission: {}, // 分销信息
  133. qrcodeUrlW:"",
  134. qrcodeUrlZ:"",
  135. isCommitted: false // 防止多次提交
  136. };
  137. },
  138. computed: mapGetters(['isLogin']),
  139. watch:{
  140. isLogin:{
  141. handler: function(newV,oldV) {
  142. if(newV){
  143. this.getUserExtractBank();
  144. this.getExtractUser();
  145. }
  146. },
  147. deep:true
  148. }
  149. },
  150. onLoad() {
  151. if (!this.isLogin) {
  152. toLogin();
  153. return;
  154. }
  155. this.getUserExtractBank();
  156. this.getExtractUser();
  157. },
  158. methods: {
  159. uploadpic: function (type) {
  160. this.$util.uploadImageOne({}, res => {
  161. this.newAvatar = res.data;
  162. if (type === 'W') {
  163. this.qrcodeUrlW = res.data;
  164. } else {
  165. this.qrcodeUrlZ = res.data;
  166. }
  167. });
  168. },
  169. /**
  170. * 删除图片
  171. */
  172. DelPicW: function () {
  173. this.qrcodeUrlW = "";
  174. },
  175. DelPicZ: function () {
  176. this.qrcodeUrlZ = "";
  177. },
  178. getExtractUser(){
  179. BrokerageAPI.getBrokerageUser().then(res=>{
  180. this.commission = res.data;
  181. })
  182. TradeConfigApi.getTradeConfig().then(res => {
  183. this.minPrice = Util.fen2yuan(res.data.brokerageWithdrawMinPrice || 0);
  184. this.frozenDays = res.data.brokerageFrozenDays || 0;
  185. this.withdrawTypes = res.data.brokerageWithdrawTypes || [];
  186. this.withdrawType = this.withdrawTypes[0]; // 默认选中第一个提现方式
  187. });
  188. },
  189. getUserExtractBank: function() {
  190. let that = this;
  191. getDicts(DICT_TYPE.BROKERAGE_BANK_NAME).then(res => {
  192. let bankList = res.data;
  193. bankList.unshift({ label: '请选择银行' });
  194. that.$set(that, 'bankList', bankList);
  195. });
  196. },
  197. switchWithdrawType: function(current) {
  198. this.withdrawType = current;
  199. },
  200. bindPickerChange: function(e) {
  201. this.bankIndex = e.detail.value;
  202. },
  203. moneyInput(e) {
  204. //正则表达试
  205. e.target.value = (e.target.value.match(/^\d*(\.?\d{0,2})/g)[0]) || null
  206. //重新赋值给input
  207. this.$nextTick(() => {
  208. this.money= e.target.value
  209. })
  210. },
  211. subCash: function(e) {
  212. let that = this,
  213. value = e.detail.value;
  214. const form = { type: this.withdrawType };
  215. if (this.withdrawType === this.WithdrawTypeEnum.BANK.type) { // 银行卡
  216. if (value.name.length === 0) {
  217. return this.$util.Tips({
  218. title: '请填写持卡人姓名'
  219. });
  220. }
  221. if (value.cardum.length === 0) {
  222. return this.$util.Tips({
  223. title: '请填写卡号'
  224. });
  225. }
  226. if (that.bankIndex === 0) {
  227. return this.$util.Tips({
  228. title: "请选择银行"
  229. });
  230. }
  231. form.name = value.name;
  232. form.accountNo = value.cardum;
  233. form.bankName = that.bankList[that.bankIndex].value;
  234. } else if (that.withdrawType === this.WithdrawTypeEnum.WECHAT.type) { // 微信
  235. if (value.name.length === 0) {
  236. return this.$util.Tips({
  237. title: '请填写微信号'
  238. });
  239. }
  240. form.accountNo = value.name;
  241. form.accountQrCodeUrl = this.qrcodeUrlW;
  242. } else if (that.withdrawType === this.WithdrawTypeEnum.ALIPAY.type) { // 支付宝
  243. if (value.name.length === 0) {
  244. return this.$util.Tips({
  245. title: '请填写账号'
  246. });
  247. }
  248. form.accountNo = value.name;
  249. form.accountQrCodeUrl = this.qrcodeUrlZ;
  250. }
  251. if (value.money.length === 0) {
  252. return this.$util.Tips({
  253. title: '请填写提现金额'
  254. });
  255. }
  256. if (!(/^(\d?)+(\.\d{0,2})?$/.test(value.money))) {
  257. return this.$util.Tips({
  258. title: '提现金额保留2位小数'
  259. });
  260. }
  261. if (value.money < that.minPrice) {
  262. return this.$util.Tips({
  263. title: '提现金额不能低于' + that.minPrice
  264. });
  265. }
  266. form.price = value.money * 100;
  267. if (this.isCommitted === false){
  268. this.isCommitted=true;
  269. BrokerageAPI.createBrokerageWithdraw(form).then(res => {
  270. return this.$util.Tips({
  271. title: "提现成功",
  272. icon: 'success'
  273. },{ tab: 2, url: '/pages/users/user_spread_user/index' });
  274. }).catch(err => {
  275. this.isCommitted=false;
  276. return this.$util.Tips({
  277. title: err
  278. });
  279. });
  280. }
  281. },
  282. fen2yuan(price) {
  283. return Util.fen2yuan(price)
  284. },
  285. }
  286. }
  287. </script>
  288. <style lang="scss">
  289. page {
  290. background-color: #fff !important;
  291. }
  292. .cash-withdrawal .nav {
  293. height: 130rpx;
  294. box-shadow: 0 10rpx 10rpx #f8f8f8;
  295. }
  296. .cash-withdrawal .nav .item {
  297. font-size: 26rpx;
  298. flex: 1;
  299. text-align: center;
  300. }
  301. .cash-withdrawal .nav .item~.item {
  302. border-left: 1px solid #f0f0f0;
  303. }
  304. .cash-withdrawal .nav .item .iconfont {
  305. width: 40rpx;
  306. height: 40rpx;
  307. border-radius: 50%;
  308. border: 2rpx solid $theme-color;
  309. text-align: center;
  310. line-height: 37rpx;
  311. margin: 0 auto 6rpx auto;
  312. font-size: 22rpx;
  313. box-sizing: border-box;
  314. }
  315. .cash-withdrawal .nav .item .iconfont.on {
  316. background-color: $theme-color;
  317. color: #fff;
  318. border-color: $theme-color;
  319. }
  320. .cash-withdrawal .nav .item .line {
  321. width: 2rpx;
  322. height: 20rpx;
  323. margin: 0 auto;
  324. transition: height 0.3s;
  325. }
  326. .cash-withdrawal .nav .item .line.on {
  327. height: 39rpx;
  328. }
  329. .cash-withdrawal .wrapper .list {
  330. padding: 0 30rpx;
  331. }
  332. .cash-withdrawal .wrapper .list .item {
  333. border-bottom: 1rpx solid #eee;
  334. min-height: 28rpx;
  335. font-size: 30rpx;
  336. color: #333;
  337. padding: 39rpx 0;
  338. }
  339. .cash-withdrawal .wrapper .list .item .name {
  340. width: 130rpx;
  341. }
  342. .cash-withdrawal .wrapper .list .item .input {
  343. width: 505rpx;
  344. }
  345. .cash-withdrawal .wrapper .list .item .input .placeholder {
  346. color: #bbb;
  347. }
  348. .cash-withdrawal .wrapper .list .item .picEwm,.cash-withdrawal .wrapper .list .item .pictrue{
  349. width:140rpx;
  350. height:140rpx;
  351. border-radius:3rpx;
  352. position: relative;
  353. margin-right: 23rpx;
  354. }
  355. .cash-withdrawal .wrapper .list .item .picEwm image{
  356. width:100%;
  357. height:100%;
  358. border-radius:3rpx;
  359. }
  360. .cash-withdrawal .wrapper .list .item .picEwm .icon-guanbi1{
  361. position:absolute;
  362. right: -14rpx;
  363. top: -16rpx;
  364. font-size:40rpx;
  365. }
  366. .cash-withdrawal .wrapper .list .item .pictrue{
  367. border:1px solid rgba(221,221,221,1);
  368. font-size:22rpx;
  369. color: #BBBBBB;
  370. }
  371. .cash-withdrawal .wrapper .list .item .pictrue .icon-icon25201{
  372. font-size: 47rpx;
  373. color: #DDDDDD;
  374. margin-bottom: 3px;
  375. }
  376. .cash-withdrawal .wrapper .list .tip {
  377. font-size: 26rpx;
  378. color: #999;
  379. margin-top: 25rpx;
  380. }
  381. .cash-withdrawal .wrapper .list .bnt {
  382. font-size: 32rpx;
  383. color: #fff;
  384. width: 690rpx;
  385. height: 90rpx;
  386. text-align: center;
  387. border-radius: 50rpx;
  388. line-height: 90rpx;
  389. margin: 64rpx auto;
  390. }
  391. .cash-withdrawal .wrapper .list .tip2 {
  392. font-size: 26rpx;
  393. color: #999;
  394. text-align: center;
  395. margin: 44rpx 0 20rpx 0;
  396. }
  397. .cash-withdrawal .wrapper .list .value {
  398. height: 135rpx;
  399. line-height: 135rpx;
  400. border-bottom: 1rpx solid #eee;
  401. width: 690rpx;
  402. margin: 0 auto;
  403. }
  404. .cash-withdrawal .wrapper .list .value input {
  405. font-size: 80rpx;
  406. color: #282828;
  407. height: 135rpx;
  408. text-align: center;
  409. }
  410. .cash-withdrawal .wrapper .list .value .placeholder2 {
  411. color: #bbb;
  412. }
  413. .price {
  414. color: $theme-color;
  415. }
  416. </style>