withdraw.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. <template>
  2. <view class="margin-30">
  3. <navigator v-if="$isEmpty(bank)" url="/pages/userBank/add" class="card_add" hover-class="none">
  4. <view class="margin-bottom-10">
  5. <u-icon name="plus-circle-fill" color="#F5A85B" size="70"></u-icon>
  6. </view>
  7. <view class="" style="color: #666666;">
  8. 添加银行卡
  9. </view>
  10. </navigator>
  11. <navigator url="select-bank" class="bank" v-else hover-class="none">
  12. <view class="left center">
  13. <image :src="bank.bankCode?'/static/bank/'+bank.bankCode+'.png':''" mode=""></image>
  14. <view class="content">
  15. <text>{{bank.bankName}}</text>
  16. <text>{{dealAccountNo(bank.accountNo)}}</text>
  17. </view>
  18. </view>
  19. <view class="center">
  20. <text class="cuIcon-right" style="font-size: 36rpx;color: #888888;"></text>
  21. </view>
  22. </navigator>
  23. <view class="card">
  24. <text class="title" v-if="type==withdrawType.BALANCE_WITHDRAW">结算金额</text>
  25. <text class="title" v-else>提现金额</text>
  26. <view class="input">
  27. <text class="text-price center text-bold" style="font-size: 60rpx;"></text>
  28. <view @click="show" class="margin-left-20 center"
  29. style="width: 60%;justify-content: flex-start;color: #ff9900;">
  30. <text class="text-xl" v-text="withdrawAmount"></text>
  31. <view class="cusor" v-if="type==withdrawType.POINT_WITHDRAW"></view>
  32. </view>
  33. <view v-if="type==withdrawType.POINT_WITHDRAW" @click="allWithdraw" class="center margin-bottom-10 margin-left-20">
  34. <view class="cu-btn withdraw-btn sm round center">
  35. <text>全部提现</text>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="canWithdraw">
  40. <text class="text-base text-sm " style="margin-bottom: 20rpx;">* 到账金额以实际为准</text>
  41. <view class="" style="font-weight: 300;">
  42. <text v-if="type==withdrawType.BALANCE_WITHDRAW">可结算金额</text>
  43. <text v-else >可提现金额</text>
  44. <text class="price margin-left-20" style="font-size: 32rpx;">{{canWithDraw}}</text>
  45. </view>
  46. <view class="margin-top-10" style="font-weight: 300;" v-if="type=='withdraw'">
  47. <text>费率</text>
  48. <text @click="rateShow=true" class="cuIcon-question margin-left-10 text-lg"></text>
  49. </view>
  50. </view>
  51. </view>
  52. <u-popup v-model="rateShow" :mask-close-able="false" mode="center" height="40%" width="76%" borderRadius="20"
  53. negative-top="100">
  54. <view class="popup-content" style="height: 98%;">
  55. <view class="">
  56. <text class="popup-title">费率说明</text>
  57. <view class="popup-desc">
  58. <text>累计营收0-1000元,费率为0.5%;</text>
  59. <text>1001-10000元,费率为0.38%;</text>
  60. <text>10000-100000元,费率0.3%;</text>
  61. <text>100000元起申请更低费率。</text>
  62. </view>
  63. </view>
  64. <view class="center">
  65. <view class="cu-btn btn-bg-color round" style="height: 80rpx;font-size: 30rpx;width: 80%;"
  66. @click="rateShow=false">
  67. 确认
  68. </view>
  69. </view>
  70. </view>
  71. </u-popup>
  72. <amountInput :maxNumber="canWithDraw" ref="amountInput" :confirmText="type==withdrawType.BALANCE_WITHDRAW?'确认结算':'确认提现'" btnColor="#ff9900" @change="change"
  73. @confirm="debounceWithdraw"></amountInput>
  74. <u-modal :mask-close-able="true" confirm-text="确定提现" @confirm="doWithdraw" v-model="passwordShow" title="提示">
  75. <view class="slot-content" style="padding: 20rpx;">
  76. <u-input v-model="withdrawPassword" placeholder="请填写提现密码" type="password" />
  77. </view>
  78. </u-modal>
  79. <toast ref="toast"></toast>
  80. <loading ref="loading" type="3"/>
  81. </view>
  82. </template>
  83. <script>
  84. import md5Libs from "uview-ui/libs/function/md5";
  85. import amountInput from '@/components/amountInput/amountInput.vue';
  86. export default {
  87. components: {
  88. amountInput
  89. },
  90. data() {
  91. return {
  92. //提现的id
  93. withdrawId:'',
  94. //默认积分提现
  95. withdrawType:this.$global.WITHDRAW_TYPE,
  96. type:this.$global.WITHDRAW_TYPE.POINT_WITHDRAW,
  97. rateShow: false,
  98. bank: {},
  99. //可提现
  100. canWithDraw: '',
  101. //提现金额
  102. withdrawAmount: 0,
  103. //提现密码
  104. withdrawPassword: '',
  105. passwordShow: false,
  106. count:0,
  107. };
  108. },
  109. onLoad(options) {
  110. this.fetchCardList()
  111. this.init(options)
  112. this.fetchBillsInfo()
  113. },
  114. onShow() {
  115. if (this.canReset) {
  116. this.bank = this.$util.getBackParams('bank')
  117. if (this.$isEmpty(this.bank)) {
  118. this.fetchCardList()
  119. }
  120. }
  121. this.canReset = true
  122. },
  123. computed: {
  124. dealAccountNo() {
  125. return data => {
  126. return this.$util.dealAccountNo(data)
  127. }
  128. },
  129. dealBankCodeType() {
  130. return data => {
  131. return this.$getBankCodeType(data)
  132. }
  133. }
  134. },
  135. methods: {
  136. async fetchBillsInfo() {
  137. let params = {
  138. shopId: this.vuex_shopId
  139. }
  140. let res=await this.$api.shop.shopBillsInfo(params)
  141. let dataInfo = res.data
  142. if (this.type==this.$global.WITHDRAW_TYPE.BALANCE_WITHDRAW) {
  143. this.canWithDraw=dataInfo.balance
  144. this.withdrawAmount=this.canWithDraw
  145. this.$refs.amountInput.initialMoney(this.withdrawAmount)
  146. }else if (this.type==this.$global.WITHDRAW_TYPE.POINT_WITHDRAW) {
  147. this.canWithDraw=dataInfo.point
  148. }
  149. },
  150. init(options){
  151. this.type=options.type
  152. if (this.type==this.$global.WITHDRAW_TYPE.BALANCE_WITHDRAW) {
  153. uni.setNavigationBarTitle({
  154. title:'余额结算'
  155. })
  156. return
  157. }
  158. if (this.type==this.$global.WITHDRAW_TYPE.POINT_WITHDRAW) {
  159. uni.setNavigationBarTitle({
  160. title:'积分提现'
  161. })
  162. return
  163. }
  164. },
  165. async fetchShopDetail() {
  166. let params = {
  167. id: this.vuex_shopId
  168. }
  169. let data = (await this.$api.shop.detail(params)).data
  170. this.canWithDraw = data.balance
  171. },
  172. fetchCardList() {
  173. let params = {
  174. merchantNo: this.vuex_merchantNo
  175. }
  176. this.$api.yeepay.withdrawCardQuery(params).then(res => {
  177. let result = JSON.parse(res.data.result)
  178. this.bank = result.bankCardAccountList[0]
  179. })
  180. },
  181. change(e) {
  182. if (!e) {
  183. this.withdrawAmount = 0
  184. } else {
  185. this.withdrawAmount = e
  186. }
  187. },
  188. show() {
  189. if (this.type==this.$global.WITHDRAW_TYPE.POINT_WITHDRAW) {
  190. this.$refs.amountInput.show()
  191. }else{
  192. this.$refs.toast.info('不可修改结算金额')
  193. }
  194. },
  195. //全部提现
  196. allWithdraw() {
  197. this.withdrawAmount = this.canWithDraw
  198. this.$refs.amountInput.initialMoney(this.withdrawAmount)
  199. },
  200. //防抖提现
  201. debounceWithdraw() {
  202. if (this.isFirst) {
  203. this.withdrawConfirm()
  204. this.isFirst = false
  205. } else {
  206. this.$u.debounce(this.withdrawConfirm, 500)
  207. }
  208. },
  209. async withdrawConfirm() {
  210. if (this.$isEmpty(this.bank)) {
  211. this.$u.toast('请选择银行')
  212. return
  213. }
  214. let params={
  215. ownerType:'商户',
  216. ownerId:this.vuex_shopId,
  217. price:this.withdrawAmount,
  218. bankAccountType:this.bank.bankCardType,
  219. bankCode:this.bank.bankCode,
  220. receiverAccountName:this.bank.accountName,
  221. receiverAccountNo:this.bank.accountNo,
  222. userBankId:this.bank.bindCardId,
  223. receiveType:'REAL_TIME'
  224. }
  225. let res={}
  226. if (this.type==this.$global.WITHDRAW_TYPE.POINT_WITHDRAW) {
  227. res=await this.$api.withdraw.userPointWithdraw(params)
  228. }
  229. if (this.type==this.$global.WITHDRAW_TYPE.BALANCE_WITHDRAW) {
  230. res=await this.$api.withdraw.userBalanceWithdraw(params)
  231. }
  232. if (this.$isEmpty(res.data)) {
  233. this.$refs.toast.error('操作失败')
  234. }
  235. let payOrderParams={
  236. orderId:res.data,
  237. orderType:'orderType'
  238. }
  239. let resp={}
  240. if (this.type==this.$global.WITHDRAW_TYPE.POINT_WITHDRAW) {
  241. resp=await this.$api.withdraw.pointPayOrder(payOrderParams)
  242. }
  243. if (this.type==this.$global.WITHDRAW_TYPE.BALANCE_WITHDRAW) {
  244. resp=await this.$api.withdraw.balancePayOrder(payOrderParams)
  245. }
  246. if (resp.success && this.$isNotEmpty(resp.data)) {
  247. this.withdrawId=resp.data
  248. this.$refs.toast.info('已提交申请,请耐心等待')
  249. // this.$refs.loading.showLoading('处理中')
  250. // this.check()
  251. }
  252. },
  253. doWithdraw() {
  254. if (this.$isEmpty(this.withdrawPassword)) {
  255. this.$u.toast('请输入提现密码')
  256. this.passwordShow = true
  257. return
  258. }
  259. console.log(md5Libs.md5(this.withdrawPassword));
  260. },
  261. check(){
  262. let _this=this
  263. let timer= setInterval(async ()=>{
  264. _this.count++
  265. let params={
  266. id:_this.withdrawId
  267. }
  268. let res=await _this.$api.withdraw.detail(params)
  269. if (res.data && res.data.withdrawStatus == 'DONE') {
  270. this.fetchBillsInfo()
  271. this.$refs.toast.info('操作成功')
  272. _this.$refs.loading.hide()
  273. clearInterval(timer)
  274. }
  275. if (_this.count == 5) {
  276. this.$refs.toast.info('已提交申请,请耐心等待')
  277. _this.$refs.loading.hide()
  278. clearInterval(timer)
  279. }
  280. },1000)
  281. },
  282. }
  283. };
  284. </script>
  285. <style lang="scss" scoped>
  286. .bank {
  287. border-radius: 20rpx;
  288. background-color: #FFFFFF;
  289. padding: 44rpx;
  290. display: flex;
  291. justify-content: space-between;
  292. .left {
  293. display: flex;
  294. image {
  295. width: 90rpx;
  296. height: 90rpx;
  297. margin-right: 20rpx;
  298. }
  299. .content {
  300. display: flex;
  301. flex-direction: column;
  302. text:first-child {
  303. color: #252525;
  304. font-weight: 800;
  305. font-size: 34rpx;
  306. }
  307. text:last-child {
  308. margin-top: 15rpx;
  309. color: #888888;
  310. font-size: 26rpx;
  311. }
  312. }
  313. }
  314. }
  315. .card_add {
  316. border-radius: 20rpx;
  317. padding: 40rpx 0;
  318. background-color: #FFFFFF;
  319. display: flex;
  320. justify-content: center;
  321. align-items: center;
  322. flex-direction: column;
  323. }
  324. .btn-withdraw {
  325. position: absolute;
  326. right: -30rpx;
  327. top: 26rpx;
  328. .btn {
  329. padding: 16rpx 38rpx;
  330. background-color: #FFE6CD;
  331. color: $base-color;
  332. }
  333. }
  334. .card {
  335. overflow: hidden;
  336. position: relative;
  337. border-radius: 20rpx;
  338. margin-top: 30rpx;
  339. padding: 40rpx;
  340. background-color: #FFFFFF;
  341. display: flex;
  342. flex-direction: column;
  343. .title {
  344. font-size: 36rpx;
  345. font-weight: 800;
  346. margin-bottom: 30rpx;
  347. }
  348. .input {
  349. display: flex;
  350. border-bottom: 1rpx solid #DFDFDF;
  351. .withdraw-btn {
  352. background-color: #FFFFFF;
  353. color: $base-color;
  354. border: 1rpx solid $base-color;
  355. height: 52rpx;
  356. width: 170rpx;
  357. font-size: 28rpx;
  358. line-height: 54rpx;
  359. }
  360. }
  361. .canWithdraw {
  362. flex-direction: column;
  363. display: flex;
  364. margin-top: 24rpx;
  365. color: #252525;
  366. }
  367. .rate {
  368. margin-top: 40rpx;
  369. .item {
  370. margin-bottom: 20rpx;
  371. display: flex;
  372. justify-content: space-between;
  373. text:first-child {
  374. color: #252525;
  375. }
  376. text:last-child {
  377. color: #999999;
  378. }
  379. }
  380. }
  381. }
  382. .submit-btn {
  383. background-color: $base-color;
  384. color: #FFFFFF;
  385. border-radius: 10rpx;
  386. }
  387. .popup-content {
  388. height: 100%;
  389. padding: 50rpx 60rpx;
  390. display: flex;
  391. flex-direction: column;
  392. justify-content: space-between;
  393. .popup-title {
  394. font-size: 38rpx;
  395. font-weight: 800;
  396. }
  397. .popup-desc {
  398. margin-top: 50rpx;
  399. color: #666666;
  400. display: flex;
  401. flex-direction: column;
  402. text {
  403. line-height: 40rpx;
  404. margin-bottom: 10rpx;
  405. }
  406. }
  407. }
  408. .cusor {
  409. margin-left: 10rpx;
  410. width: 6rpx;
  411. border-radius: 20rpx;
  412. height: 60%;
  413. background-color: $base-color;
  414. animation: blink 1200ms infinite ease-in-out;
  415. }
  416. @keyframes blink {
  417. from {
  418. opacity: 0;
  419. }
  420. }
  421. </style>