applyWithdrawal.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <view class="applyWithdrawal">
  3. <view class="header">
  4. <template v-if="currentCard.bank_code" >
  5. <view class="title">到账银行卡</view>
  6. <view class="card-info" @click="handleSelectCard">
  7. <view class="left">
  8. <u--image
  9. v-if="currentCard.bank_logo"
  10. width="53rpx"
  11. height="53rpx"
  12. :src="currentCard.bank_logo"
  13. :fade="true"
  14. duration="450"
  15. ></u--image>
  16. <text class="name"
  17. >{{ currentCard.bank_name }}储蓄卡({{ bankLastCode }})</text
  18. >
  19. </view>
  20. <u-icon name="arrow-right" color="#9C9C9C" size="24rpx" bold></u-icon>
  21. </view>
  22. </template>
  23. <view class="fs16 fw600 mt10 color-2c" v-else>请添加提现账户</view>
  24. </view>
  25. <view class="body">
  26. <view class="withdrawal-box">
  27. <view class="title">提现金额</view>
  28. <view class="input-wrap">
  29. <u-input
  30. placeholder="输入提现金额,提现金额>100元"
  31. border="bottom"
  32. type="number"
  33. v-model="applyAmount"
  34. customStyle="text-align: right;"
  35. >
  36. <text class="input-prefix" slot="prefix">¥</text>
  37. </u-input>
  38. </view>
  39. <view class="bottom">
  40. <text>可提现金额:¥{{ allAmount }}</text>
  41. <text class="all-btn" @click="handleAllAmount">全部提现</text>
  42. </view>
  43. </view>
  44. <view class="submit-btn" @click="onSubmit">确认提现</view>
  45. <view class="more-action">
  46. <navigator
  47. url="/subPages/withdrawalAccountManagement/withdrawalAccountManagement"
  48. >
  49. <text>提现账户管理</text>
  50. </navigator>
  51. <navigator url="/subPages/withdrawalManagement/withdrawalManagement">
  52. <text>提现记录</text>
  53. </navigator>
  54. </view>
  55. </view>
  56. <view class="footer">
  57. <view class="title">温馨提示:</view>
  58. <view
  59. >1.提现申请通过后将在1-3个工作日内将提现金额打入您的
  60. 银行卡或支付宝账户中。</view
  61. >
  62. <view
  63. >2.工作日(周六/日法定节假日除外)16:30之前申请的提现申 请当天处理。</view
  64. >
  65. </view>
  66. <u-popup
  67. class="select-banks-popup"
  68. :show="show"
  69. mode="bottom"
  70. @close="close"
  71. :customStyle="{
  72. maxHeight: '68vh',
  73. padding: '0 20rpx',
  74. 'overflow-y': 'auto',
  75. }"
  76. >
  77. <view class="select-banks-title">
  78. <text>选择银行账户</text><u-icon name="close" @click="close"></u-icon>
  79. </view>
  80. <view
  81. v-for="b in bankCardList"
  82. :key="b.id"
  83. class="select-banks-item"
  84. @click="handleBank(b)"
  85. >
  86. <!-- :style="{ backgroundColor: b.bank_bg }" -->
  87. <view class="left">
  88. <u--image
  89. v-if="b.bank_logo"
  90. width="60rpx"
  91. height="60rpx"
  92. radius="100%"
  93. shape="circle"
  94. customStyle="border-radius:100%;"
  95. :src="b.bank_logo"
  96. :fade="true"
  97. duration="450"
  98. ></u--image>
  99. <view class="name">{{ b.bank_name }}({{getBankLastCode(b.bank_code)}})</view>
  100. </view>
  101. <u-icon
  102. v-if="currentCard.id === b.id"
  103. name="checkbox-mark"
  104. color="#f39800"
  105. ></u-icon>
  106. <u-icon v-else name="arrow-right"></u-icon>
  107. </view>
  108. </u-popup>
  109. </view>
  110. </template>
  111. <script>
  112. import { getMyBanks, addWithdrawal, getWithdrawalList } from "@/common/api/withdrawal.js";
  113. export default {
  114. data() {
  115. return {
  116. applyAmount: "",
  117. currentCard: {},
  118. bankCardList: [],
  119. show: false,
  120. allAmount: 0, //TODO: mock
  121. };
  122. },
  123. computed: {
  124. bankLastCode() {
  125. if (!this.currentCard.bank_code) return "";
  126. return this.currentCard.bank_code.slice(-4);
  127. },
  128. },
  129. onShow() {
  130. this._getMyBanks();
  131. this._getWithdrawalList();
  132. },
  133. methods: {
  134. getBankLastCode(code) {
  135. return code.slice(-4)
  136. },
  137. _getMyBanks() {
  138. getMyBanks().then(({ data = [] }) => {
  139. console.log("data=======>", data);
  140. this.bankCardList = data;
  141. this.currentCard = data[0] || {};
  142. });
  143. },
  144. _getWithdrawalList() {
  145. getWithdrawalList({
  146. page: 1,
  147. pageSize: 1,
  148. }).then(({ data = {} }) => {
  149. const { total = {} } = data;
  150. this.allAmount = +total['待提现']||0;
  151. });
  152. },
  153. onSubmit() {
  154. if (!this.currentCard.bank_code) {
  155. uni.$u.toast("提现银行卡不能为空");
  156. return
  157. }
  158. if (+this.applyAmount < 100) {
  159. uni.$u.toast("提现金额不能小于100");
  160. return;
  161. }
  162. if(+this.applyAmount > this.allAmount){
  163. uni.$u.toast("可提现金额不足");
  164. return;
  165. }
  166. addWithdrawal({
  167. amount: +this.applyAmount,
  168. bank_wseq: this.currentCard.bank_wseq,
  169. bank_name: this.currentCard.bank_name,
  170. bank_user: this.currentCard.bank_user,
  171. bank_bran: this.currentCard.bank_bran,
  172. bank_code: this.currentCard.bank_code,
  173. }).then((res) => {
  174. uni.$u.toast("提现成功");
  175. uni.reLaunch({
  176. url:'/subPages/withdrawalManagement/withdrawalManagement'
  177. })
  178. });
  179. },
  180. handleSelectCard() {
  181. this.show = true;
  182. },
  183. handleAllAmount() {
  184. this.applyAmount = this.allAmount;
  185. },
  186. close() {
  187. this.show = false;
  188. },
  189. handleBank(card) {
  190. this.currentCard = card;
  191. },
  192. },
  193. };
  194. </script>
  195. <style lang="scss" scoped>
  196. .applyWithdrawal {
  197. padding: 20rpx 20rpx 40rpx;
  198. display: flex;
  199. flex-direction: column;
  200. .header {
  201. padding: 23rpx 39rpx 0 17rpx;
  202. .title {
  203. padding-left: 10rpx;
  204. font-size: 30rpx;
  205. font-family: PingFang SC-Medium, PingFang SC;
  206. font-weight: 500;
  207. color: #1d161f;
  208. line-height: 42rpx;
  209. }
  210. .card-info {
  211. display: flex;
  212. justify-content: space-between;
  213. align-items: center;
  214. margin-top: 14rpx;
  215. .left {
  216. display: flex;
  217. align-items: center;
  218. .name {
  219. font-size: 30rpx;
  220. font-weight: 500;
  221. color: #1d161f;
  222. line-height: 35rpx;
  223. margin-left: 4rpx;
  224. }
  225. }
  226. }
  227. }
  228. .body {
  229. margin-top: 54rpx;
  230. .withdrawal-box {
  231. padding: 19rpx 26px 0 27px;
  232. height: 308rpx;
  233. background: #ffffff;
  234. border-radius: 10rpx;
  235. .title {
  236. font-size: 30rpx;
  237. font-weight: 500;
  238. color: #252525;
  239. line-height: 42rpx;
  240. }
  241. .input-wrap {
  242. margin-top: 52rpx;
  243. ::v-deep {
  244. .u-border-bottom {
  245. border-color: #efefef !important;
  246. padding: 5rpx 0 !important;
  247. }
  248. }
  249. .input-prefix {
  250. font-size: 64rpx;
  251. font-family: PingFang SC-Bold, PingFang SC;
  252. font-weight: bold;
  253. color: #252525;
  254. line-height: 90rpx;
  255. }
  256. }
  257. .bottom {
  258. padding-top: 28rpx;
  259. display: flex;
  260. justify-content: space-between;
  261. align-items: center;
  262. font-size: 30rpx;
  263. font-weight: 500;
  264. color: #929292;
  265. line-height: 1;
  266. .all-btn {
  267. font-size: 30rpx;
  268. font-weight: 500;
  269. color: #f39800;
  270. line-height: 1;
  271. }
  272. }
  273. }
  274. .submit-btn {
  275. display: flex;
  276. justify-content: center;
  277. align-items: center;
  278. width: 100%;
  279. height: 84rpx;
  280. margin-top: 55rpx;
  281. background: #f39800;
  282. border-radius: 39rpx;
  283. font-size: 32rpx;
  284. font-weight: 500;
  285. color: #ffffff;
  286. line-height: 1;
  287. }
  288. .more-action {
  289. margin-top: 50rpx;
  290. display: flex;
  291. justify-content: center;
  292. align-items: center;
  293. height: 42rpx;
  294. font-size: 30rpx;
  295. font-family: PingFang SC-Medium, PingFang SC;
  296. font-weight: 500;
  297. color: #252525;
  298. line-height: 1;
  299. text {
  300. margin: 0 55rpx;
  301. }
  302. }
  303. }
  304. .footer {
  305. margin-top: 200rpx;
  306. font-size: 26rpx;
  307. font-weight: 500;
  308. color: #929292;
  309. line-height: 30rpx;
  310. .title {
  311. font-size: 28rpx;
  312. font-weight: 500;
  313. color: #929292;
  314. line-height: 39rpx;
  315. margin-bottom: 17rpx;
  316. }
  317. }
  318. }
  319. .select-banks-popup {
  320. padding: 0 30rpx;
  321. }
  322. .select-banks-title {
  323. display: flex;
  324. justify-content: space-between;
  325. align-items: center;
  326. font-size: 32rpx;
  327. font-family: PingFangSC-Medium, PingFang SC;
  328. font-weight: 500;
  329. color: #1d161f;
  330. height: 100rpx;
  331. flex-shrink: 0;
  332. }
  333. .select-banks-item {
  334. display: flex;
  335. justify-content: space-between;
  336. height: 80rpx;
  337. padding: 25rpx 20rpx;
  338. margin-bottom: 15rpx;
  339. background-color: #f5f6f8;
  340. border-radius: 10rpx;
  341. &:last-child {
  342. margin-bottom: 30rpx;
  343. }
  344. .left {
  345. display: flex;
  346. align-items: center;
  347. align-items: center;
  348. }
  349. .name {
  350. margin-left: 23rpx;
  351. font-size: 32rpx;
  352. font-weight: bold;
  353. color: #1d161f;
  354. line-height: 1;
  355. }
  356. }
  357. </style>