withdraw.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <view class="margin-30">
  3. <navigator v-if="$isEmpty(bank)" url="/pagesB/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.bankType?'/pagesB/static/bank/'+bank.bankType+'.png':''" mode=""></image>
  14. <view class="content">
  15. <text>{{bank.bankTypeLabel}}</text>
  16. <text>{{bank.cardNo}}</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">提现金额</text>
  25. <view class="input">
  26. <text class="text-price center text-bold" style="font-size: 60rpx;"></text>
  27. <view @click="show" class="margin-left-20 center"
  28. style="width: 60%;justify-content: flex-start;color: #ff9900;">
  29. <text class="text-xl" v-text="withdrawAmount"></text>
  30. <view class="cusor"></view>
  31. </view>
  32. <view @click="allWithdraw" class="center margin-bottom-10 margin-left-20">
  33. <view class="cu-btn withdraw-btn sm round center">
  34. <text>全部提现</text>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="canWithdraw">
  39. 可提现金额
  40. <text class="text-price margin-left-20" style="font-size: 34rpx;">{{canWithDraw}}</text>
  41. </view>
  42. <view class="rate">
  43. <view class="item">
  44. <text>服务费</text>
  45. <text class="text-price">0.10</text>
  46. </view>
  47. <view class="item">
  48. <view class="">
  49. <text>费率</text>
  50. <text @click="rateShow=true" class="cuIcon-question margin-left-10 text-lg"></text>
  51. </view>
  52. <text class="">0.05%</text>
  53. </view>
  54. </view>
  55. </view>
  56. <u-popup v-model="rateShow" :mask-close-able="false" mode="center" height="40%" width="76%" borderRadius="20"
  57. negative-top="100">
  58. <view class="popup-content" style="height: 98%;">
  59. <view class="">
  60. <text class="popup-title">费率说明</text>
  61. <view class="popup-desc">
  62. <text>累计提现0-1000元,费率为0.5%;</text>
  63. <text>1001-10000元,费率为0.38%;</text>
  64. <text>10000-100000元,费率0.3%;</text>
  65. <text>100000元起申请更低费率。</text>
  66. </view>
  67. </view>
  68. <view class="center">
  69. <view class="cu-btn btn-bg-color round" style="height: 80rpx;font-size: 30rpx;width: 80%;"
  70. @click="rateShow=false">
  71. 确认
  72. </view>
  73. </view>
  74. </view>
  75. </u-popup>
  76. <amountInput :maxNumber="canWithDraw" ref="amountInput" confirmText="确认提现" btnColor="#ff9900" @change="change"
  77. @confirm="withdrawConfirm"></amountInput>
  78. <u-modal :mask-close-able="true" confirm-text="确定提现" @confirm="doWithdraw" v-model="passwordShow" title="提示">
  79. <view class="slot-content" style="padding: 20rpx;">
  80. <u-input v-model="withdrawPassword" placeholder="请填写提现密码" type="password" />
  81. </view>
  82. </u-modal>
  83. <toast ref="toast" ></toast>
  84. </view>
  85. </template>
  86. <script>
  87. import amountInput from '../../comps/amountInput/amountInput.vue';
  88. export default {
  89. components: {
  90. amountInput
  91. },
  92. data() {
  93. return {
  94. rateShow: false,
  95. bank: {},
  96. //可提现
  97. canWithDraw: 0,
  98. //提现金额
  99. withdrawAmount: 0,
  100. //提现密码
  101. withdrawPassword:'',
  102. passwordShow:false,
  103. };
  104. },
  105. onLoad() {
  106. this.fetchCardList()
  107. this.fetchUserDetail()
  108. },
  109. onShow() {
  110. if (this.canReset) {
  111. this.bank = this.$util.getBackParams('bank')
  112. if (this.$isEmpty(this.bank)) {
  113. this.fetchCardList()
  114. }
  115. }
  116. this.canReset = true
  117. },
  118. methods: {
  119. fetchUserDetail(){
  120. this.$api.loginUser.detail({id:this.vuex_userId}).then(res=>{
  121. this.canWithDraw=res.data.availableBalance
  122. })
  123. },
  124. fetchCardList() {
  125. let params = {
  126. userId: this.vuex_shopId,
  127. size: 10
  128. }
  129. this.$api.userBank.appList(params).then(res => {
  130. this.bank = res.data.records[0]
  131. })
  132. },
  133. change(e) {
  134. if (!e) {
  135. this.withdrawAmount = 0
  136. } else {
  137. this.withdrawAmount = e
  138. }
  139. },
  140. show() {
  141. this.$refs.amountInput.show()
  142. },
  143. //全部提现
  144. allWithdraw(){
  145. this.withdrawAmount=this.canWithDraw
  146. this.$refs.amountInput.initialMoney(this.withdrawAmount)
  147. },
  148. withdrawConfirm(){
  149. if (this.$isEmpty(this.bank)) {
  150. this.$refs.toast.error('请选择银行')
  151. return
  152. }
  153. this.doWithdraw()
  154. },
  155. async doWithdraw(){
  156. let params={
  157. ownerId:this.vuex_userId,
  158. ownerType:this.$global.userType.CHANNEL,
  159. price:this.withdrawAmount,
  160. bankId:this.bank.id
  161. }
  162. let res=await this.$api.withdraw.submit(params)
  163. if (this.$isEmpty(res.data)) {
  164. this.$refs.toast.error('提现失败')
  165. return
  166. }
  167. let payParam={
  168. orderType:'USER_WITHDRAW',
  169. orderId:res.data
  170. }
  171. this.$api.withdraw.payOrder(payParam).then(res=>{
  172. console.log(res);
  173. })
  174. }
  175. }
  176. };
  177. </script>
  178. <style lang="scss" scoped>
  179. .bank {
  180. border-radius: 20rpx;
  181. background-color: #FFFFFF;
  182. padding: 44rpx;
  183. display: flex;
  184. justify-content: space-between;
  185. .left {
  186. display: flex;
  187. image {
  188. width: 90rpx;
  189. height: 90rpx;
  190. margin-right: 20rpx;
  191. }
  192. .content {
  193. display: flex;
  194. flex-direction: column;
  195. text:first-child {
  196. color: #252525;
  197. font-weight: 800;
  198. font-size: 34rpx;
  199. }
  200. text:last-child {
  201. margin-top: 15rpx;
  202. color: #888888;
  203. font-size: 26rpx;
  204. }
  205. }
  206. }
  207. }
  208. .card_add {
  209. border-radius: 20rpx;
  210. padding: 40rpx 0;
  211. background-color: #FFFFFF;
  212. display: flex;
  213. justify-content: center;
  214. align-items: center;
  215. flex-direction: column;
  216. }
  217. .card {
  218. border-radius: 20rpx;
  219. margin-top: 30rpx;
  220. padding: 40rpx;
  221. background-color: #FFFFFF;
  222. display: flex;
  223. flex-direction: column;
  224. .title {
  225. font-size: 36rpx;
  226. font-weight: 800;
  227. margin-bottom: 30rpx;
  228. }
  229. .input {
  230. display: flex;
  231. border-bottom: 1rpx solid #DFDFDF;
  232. .withdraw-btn {
  233. background-color: #FFFFFF;
  234. color: #EE9230;
  235. border: 1rpx solid #EE9230;
  236. height: 54rpx;
  237. width: 180rpx;
  238. font-size: 28rpx;
  239. line-height: 54rpx;
  240. }
  241. }
  242. .canWithdraw {
  243. margin-top: 24rpx;
  244. color: #252525;
  245. }
  246. .rate {
  247. margin-top: 40rpx;
  248. .item {
  249. margin-bottom: 20rpx;
  250. display: flex;
  251. justify-content: space-between;
  252. text:first-child {
  253. color: #252525;
  254. }
  255. text:last-child {
  256. color: #999999;
  257. }
  258. }
  259. }
  260. }
  261. .submit-btn {
  262. background-color: #EE9230;
  263. color: #FFFFFF;
  264. border-radius: 10rpx;
  265. }
  266. .popup-content {
  267. height: 100%;
  268. padding: 50rpx 60rpx;
  269. display: flex;
  270. flex-direction: column;
  271. justify-content: space-between;
  272. .popup-title {
  273. font-size: 38rpx;
  274. font-weight: 800;
  275. }
  276. .popup-desc {
  277. margin-top: 50rpx;
  278. color: #666666;
  279. display: flex;
  280. flex-direction: column;
  281. text {
  282. line-height: 40rpx;
  283. margin-bottom: 10rpx;
  284. }
  285. }
  286. }
  287. .cusor {
  288. margin-left: 10rpx;
  289. width: 6rpx;
  290. border-radius: 20rpx;
  291. height: 60%;
  292. background-color: #ff9900;
  293. animation: blink 1200ms infinite ease-in-out;
  294. }
  295. @keyframes blink {
  296. from {
  297. opacity: 0;
  298. }
  299. }
  300. </style>