withdraw.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. <template>
  2. <view class="container">
  3. <navbar :config="config" backColor="#666666"></navbar>
  4. <view class="u-plr30">
  5. <!-- <view class="wd-bgImg">
  6. <image src="../../../static/my-top-bgImg.png"></image>
  7. <view class="moneyInfo">
  8. <view class="u-flex-center-sb" style="padding: 38rpx 22rpx;">
  9. <view class="u-FFF">
  10. <view class="u-font30">已提现:<text class="u-font24">¥</text> <text class="u-font28">102.00</text> </view>
  11. <view class="u-font30 mt40">待提现:<text class="u-font24">¥</text> <text class="u-font28">102.00</text> </view>
  12. </view>
  13. <view class="detail-btn" @click="goWdDetail">
  14. <button>
  15. <text class="iconfont">&#xe63d;</text>
  16. <text class="u-font24 u-ml10">提现明细</text>
  17. </button>
  18. </view>
  19. </view>
  20. </view>
  21. </view> -->
  22. <view class="u-bg-fff u-p30 u-mt20">
  23. <view class="u-flex-center-sb">
  24. <view>
  25. <text>可提现金额</text>
  26. <text class="u-ml20 u-FF0000 u-bold u-font36">{{walletInfo.commission_able}}</text>
  27. </view>
  28. <view @click="goWallet">
  29. <text class="iconfont">&#xe638;</text>
  30. </view>
  31. </view>
  32. <view class="u-mt30 u-flex u-999">
  33. <view>
  34. <text>待入账</text><text class="u-ml20">{{walletInfo.wait_account}}</text>
  35. </view>
  36. <view class="u-ml30">
  37. <text>冻结中</text><text class="u-ml20">{{walletInfo.freezing}}</text>
  38. </view>
  39. </view>
  40. </view>
  41. <!--提现记录-->
  42. <view class="u-bg-fff u-flex-center-sb u-p30 u-mt20" @click="goWdDetail">
  43. <view>提现记录</view>
  44. <view class="iconfont u-font24 u-666"> &#xe6c7;</view>
  45. </view>
  46. <view class="wdInput u-mt20">
  47. <view class="u-999">提现金额(最低提现佣金{{walletInfo.min_extract}}元)</view>
  48. <view class="u-mt20 input u-flex">
  49. <text>¥</text>
  50. <input class="u-ml10" maxlength="10" type="digit" @input="getMoney" v-model="dataForm.money" placeholder="提现金额" />
  51. </view>
  52. </view>
  53. <view class="bg-fff">
  54. <view class="u-flex-center-sb u-1A1A1A" v-if="dataForm.payment_term== 2" @click="openBankCard">
  55. <view class="u-flex">
  56. <text class="u-font30">提现方式</text>
  57. <view class="ml46 u-font28" v-if="bankCardList.length>0">
  58. <view>
  59. <image :src="bankIcon" class="img30"></image>
  60. <text class="u-ml20">{{dataForm.bank_name}}</text>
  61. </view>
  62. <view class="u-999 u-mt5 u-ml45 u-flex">
  63. 尾号
  64. <rich-text :nodes="$mUtil.cutOut(dataForm.withdraw_account)"></rich-text>
  65. 储蓄卡</view>
  66. </view>
  67. <view class="ml46 u-font28" v-else>
  68. 添加银行卡
  69. </view>
  70. </view>
  71. <view class="iconfont u-font24 u-666"> &#xe6c7;</view>
  72. </view>
  73. <!--支付宝,微信-->
  74. <view class="zfb-wx" v-if="dataForm.payment_term != 2">
  75. <view class="u-flex-center-sb u-1A1A1A" @click="openBankCard">
  76. <view class="u-flex">
  77. <text class="u-font30 u-bold">提现方式</text>
  78. <view class="ml46 u-font28">
  79. <view v-if="dataForm.payment_term==1"><text class="iconfont u-font40 payIcon">&#xe627;</text> <text>支付宝</text></view>
  80. <view v-if="dataForm.payment_term==0"><text class="iconfont u-font40 wxIcon">&#xe606;</text> <text>微信</text></view>
  81. </view>
  82. </view>
  83. <view class="iconfont u-font24 u-666"> &#xe6c7;</view>
  84. </view>
  85. <view class="u-mt50 zhInput">
  86. <view class="u-flex-center">
  87. <view class="wt112">姓 名:</view>
  88. <input class="ml56" maxlength="16" @input="getName" :value="dataForm.payee" placeholder="请输入姓名" />
  89. </view>
  90. <view class="u-flex-center u-mt20">
  91. <view class="wt112">手机号:</view>
  92. <input class="ml56" maxlength="11" @input="getMobile" type="number" :value="dataForm.withdraw_mobile" placeholder="请输入手机号" />
  93. </view>
  94. <view class="u-flex-center u-mt20">
  95. <view class="wt112">{{dataForm.payment_term==1?'支付宝':'微信'}} :</view>
  96. <input class="ml56" maxlength="30" @input="getWithdrawAccount" :value="dataForm.withdraw_account" placeholder="请输入账号" />
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. <view class="apply-btn" @click="requestWithdrawal">
  102. <button class="u-btn-two">提交申请</button>
  103. </view>
  104. </view>
  105. <!--弹窗选择银行卡-->
  106. <uniPopup type="bottom" ref="uniPopup">
  107. <view class="popup">
  108. <view class="bg-top">
  109. <text class="iconfont u-999" @click="close">&#xe612;</text>
  110. <text class="u-text-center ml200">选择优先付款方式</text>
  111. </view>
  112. <view class="bankCardList">
  113. <view v-for="(item,index) in bankCardList" :key="item.id">
  114. <!--index 下标,2 是类型自定义(下面支付宝,微信一样)-->
  115. <view class="item u-flex" @click="pitchOn(index,2)">
  116. <image :src="item.icon"></image>
  117. <view class="u-ml25 rh-br u-flex-sb" >
  118. <view class="u-flex">
  119. <text>{{item.bank_name}}</text>
  120. (<rich-text :nodes="$mUtil.cutOut(item.card_num)"></rich-text>)
  121. </view>
  122. <text class="iconfont pull-right" v-if="pitchOnIndex==index">&#xe63e;</text>
  123. </view>
  124. </view>
  125. </view>
  126. <!--添加银行卡-->
  127. <view class="item u-flex" @click="goAddBankCard">
  128. <text class="iconfont">&#xe81a;</text>
  129. <view class="u-ml25 rh-br">
  130. <text>添加银行卡</text>
  131. </view>
  132. </view>
  133. <!--支付宝-->
  134. <view class="item u-flex" @click="pitchOn(-1,1)">
  135. <image :src="imgUrl+'/alipay.png'"></image>
  136. <view class="u-ml25 rh-br">
  137. <text>支付宝</text>
  138. <text class="iconfont pull-right" v-if="pitchOnIndex==-1">&#xe63e;</text>
  139. </view>
  140. </view>
  141. <view class="item u-flex" @click="pitchOn(-2,0)">
  142. <image :src="imgUrl+'/weChat.png'"></image>
  143. <view class="u-ml25 rh-br">
  144. <text>微信</text>
  145. <text class="iconfont pull-right" v-if="pitchOnIndex==-2">&#xe63e;</text>
  146. </view>
  147. </view>
  148. </view>
  149. </view>
  150. </uniPopup>
  151. </view>
  152. </template>
  153. <script>
  154. import uniPopup from "../../../components/uni-popup/uni-popup.vue"
  155. export default {
  156. components: {
  157. uniPopup
  158. },
  159. data() {
  160. return {
  161. config: {
  162. back: true, //false是tolbar页面 是则不写
  163. title: '提现',
  164. color: '#1A1A1A',
  165. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  166. backgroundColor: [1, "#FFF"],
  167. statusBarFontColor: '#1A1A1A'
  168. },
  169. bankCardList: [], //银行卡列表
  170. dataForm: {
  171. money: '', //提现金额
  172. payment_term: 2, // * 收款方式: * 0微信, * 1支付宝, * 2银行线下 * 3现金支付
  173. payee: '', //收款人
  174. withdraw_account: '', //提现账户
  175. withdraw_mobile: '', //提现手机
  176. bank_name: '', //银行名称
  177. },
  178. bankIcon: '',
  179. pitchOnIndex:-3,
  180. addCard:true,
  181. walletInfo:{
  182. min_extract:0,
  183. wait_account:0,
  184. freezing:0
  185. },//账户信息
  186. imgUrl: this.$mConfig.staticUrl
  187. }
  188. },
  189. onLoad() {
  190. let that = this
  191. //获取账户信息
  192. this.getAccountMsg()
  193. //获取银行卡列表
  194. this.getBankCardList()
  195. },
  196. methods: {
  197. //获取账户信息
  198. getAccountMsg(){
  199. this.$http.get('/withdraw/getWalletInfo', {}).then(async res => {
  200. if (res && res.code == 200) {
  201. if(res.data){
  202. this.walletInfo = res.data
  203. }
  204. }
  205. })
  206. },
  207. //获取银行卡列表
  208. getBankCardList(){
  209. this.$http.get('/member/bankcard/bankCardList', {}).then(async res => {
  210. if (res && res.code == 200) {
  211. this.bankCardList = res.list
  212. //默认提方式为用户银行卡列表第一张银行卡
  213. if(res.list.length>0){
  214. this.dataForm.bank_name= res.list[0].bank_name
  215. this.dataForm.withdraw_account= res.list[0].card_num
  216. this.bankIcon = res.list[0].icon
  217. this.dataForm.payee =res.list[0].name
  218. this.dataForm.withdraw_mobile = res.list[0].mobile
  219. }
  220. }
  221. })
  222. },
  223. //打开弹窗银行卡列表
  224. openBankCard() {
  225. this.$refs.uniPopup.open();
  226. // console.log(this.pitchOnIndex)
  227. },
  228. //关闭弹窗
  229. close() {
  230. this.$refs.uniPopup.close();
  231. },
  232. //选择提现方式
  233. pitchOn(index, type) {
  234. this.pitchOnIndex = index
  235. this.dataForm.payment_term = type
  236. if (type == 2) {
  237. this.dataForm.bank_name = this.bankCardList[index].bank_name
  238. this.dataForm.withdraw_account = this.bankCardList[index].card_num
  239. this.bankIcon = this.bankCardList[index].icon
  240. } else {
  241. this.dataForm.bank_name = ''
  242. this.dataForm.withdraw_account = ''
  243. }
  244. this.$refs.uniPopup.close();
  245. },
  246. //跳转提现明细
  247. goWdDetail() {
  248. uni.navigateTo({
  249. url: "wdDetail"
  250. })
  251. },
  252. //跳到添加银行卡
  253. goAddBankCard() {
  254. uni.navigateTo({
  255. url: "../bankCard/addBankCard"
  256. })
  257. },
  258. //跳转到钱包明细
  259. goWallet(){
  260. uni.navigateTo({
  261. url: "./wallet"
  262. })
  263. },
  264. //获取输入提现金额
  265. getMoney(e) {
  266. e.target.value = (e.target.value.match(/^\d*(\.?\d{0,2})/g)[0]) || null
  267. //重新赋值给input
  268. this.$nextTick(() => {
  269. this.dataForm.money= e.target.value
  270. })
  271. },
  272. //获取提现人姓名
  273. getName(e) {
  274. // console.log(e.target.value)
  275. this.dataForm.payee = e.target.value
  276. },
  277. getMobile(e){
  278. this.dataForm.withdraw_mobile = e.target.value
  279. },
  280. //获取提现人账号
  281. getWithdrawAccount(e) {
  282. this.dataForm.withdraw_account = e.target.value
  283. },
  284. //申请提现
  285. requestWithdrawal() {
  286. if (!this.dataForm.money) {
  287. this.$mUtil.toast('请输入提现金额')
  288. return false
  289. }
  290. if (this.dataForm.money < this.walletInfo.min_extract) {
  291. this.$mUtil.toast('提现金额超出您的最低提现金额')
  292. return false
  293. }
  294. if (this.dataForm.payment_term === '') {
  295. this.$mUtil.toast('请选择提现方式')
  296. return false
  297. }
  298. if(this.dataForm.payment_term == 2){
  299. if(!this.dataForm.bank_name){
  300. this.$mUtil.toast('请先添加银行卡')
  301. return false
  302. }
  303. }
  304. if (this.dataForm.payment_term == 0 || this.dataForm.payment_term == 1) {
  305. if (!this.dataForm.payee) {
  306. this.$mUtil.toast('请输入姓名')
  307. return false
  308. }
  309. if(!this.dataForm.withdraw_mobile.match(this.$mConfig.telRegex)){
  310. this.$mUtil.toast('请输入正确手机号')
  311. return false
  312. }
  313. if (!this.dataForm.withdraw_account) {
  314. this.$mUtil.toast('请输入账户')
  315. return false
  316. }
  317. }
  318. this.$http.post('/withdraw/memberWithdraw', this.dataForm).then(async res => {
  319. if (res && res.code == 200) {
  320. this.$mUtil.toast('申请成功')
  321. setTimeout(() => {
  322. uni.navigateBack({
  323. success: () => {
  324. let page = getCurrentPages().pop(); //跳转页面成功之后
  325. if (!page) {
  326. return;
  327. } else {
  328. page.onLoad(page.options);// page自带options对象.
  329. }
  330. }
  331. })
  332. }, 2000)
  333. }else{
  334. this.$mUtil.toast(res.msg)
  335. }
  336. })
  337. }
  338. }
  339. }
  340. </script>
  341. <style lang="scss">
  342. page {
  343. background-color: #F5F5F5;
  344. }
  345. .wt112 {
  346. width: 140rpx;
  347. }
  348. .img30 {
  349. width: 30rpx;
  350. height: 30rpx;
  351. }
  352. .wd-bgImg {
  353. position: relative;
  354. padding: 25rpx 0rpx;
  355. image {
  356. width: 100%;
  357. height: 200rpx;
  358. vertical-align: bottom;
  359. }
  360. .moneyInfo {
  361. position: absolute;
  362. top: 25rpx;
  363. width: 92%;
  364. .mt40 {
  365. margin-top: 40rpx;
  366. }
  367. .detail-btn button {
  368. height: 56rpx;
  369. line-height: 30rpx;
  370. border-radius: 28px;
  371. opacity: 0.82;
  372. padding: 10rpx 30rpx;
  373. background-color: #EED9A9;
  374. color: #0B844A;
  375. }
  376. }
  377. }
  378. .wdInput {
  379. background-color: #FFFFFF;
  380. border-radius: 18rpx 18rpx 0px 0rpx;
  381. padding: 40rpx 22rpx 32rpx;
  382. .input {
  383. height: 80rpx;
  384. line-height: 80rpx;
  385. font-size: 60rpx;
  386. border-bottom: 1rpx solid #D9D9D9;
  387. padding-bottom: 25rpx;
  388. input {
  389. height: 80rpx;
  390. line-height: 80rpx;
  391. font-size: 36rpx;
  392. }
  393. }
  394. }
  395. .bg-fff {
  396. background-color: #FFFFFF;
  397. padding: 26rpx 22rpx 36rpx;
  398. border-radius: 0rpx 0rpx 18px 18rpx;
  399. }
  400. .ml46 {
  401. margin-left: 46rpx;
  402. }
  403. .apply-btn {
  404. margin-top: 80rpx;
  405. button {
  406. background: #0B844A;
  407. color: #FFFFFF;
  408. }
  409. }
  410. .zfb-wx {
  411. padding-bottom: 24rpx;
  412. .payIcon {
  413. color: #00aaef;
  414. font-size: 32rpx;
  415. margin-right: 18rpx;
  416. }
  417. .wxIcon {
  418. color: rgb(37, 171, 56);
  419. font-size: 32rpx;
  420. margin-right: 18rpx;
  421. }
  422. }
  423. .zhInput input {
  424. width: 62%;
  425. height: 70rpx;
  426. line-height: 70rpx;
  427. padding: 0rpx 20rpx;
  428. border: 1rpx solid #D9D9D9;
  429. border-radius: 6rpx;
  430. }
  431. .popup {
  432. width: 100%;
  433. .bg-top {
  434. background-color: #F5F5F5;
  435. padding: 20rpx 30rpx;
  436. border-radius: 18rpx 18rpx 0px 0px;
  437. }
  438. .bankCardList {
  439. background-color: #FFFFFF;
  440. padding: 0rpx 30rpx;
  441. padding-bottom: 185rpx;
  442. .item {
  443. height: 84rpx;
  444. line-height: 84rpx;
  445. image {
  446. width: 48rpx;
  447. height: 42rpx;
  448. margin-top: 20rpx;
  449. vertical-align: bottom;
  450. }
  451. .rh-br {
  452. width: 100%;
  453. border-bottom: 1rpx solid #E6E6E6;
  454. }
  455. .pull-right {
  456. float: right !important;
  457. }
  458. }
  459. }
  460. }
  461. .ml56 {
  462. margin-left: 56rpx;
  463. }
  464. .ml200 {
  465. margin-left: 200rpx;
  466. }
  467. </style>