withdrawal.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <view class="center">
  3. <view class="formData">
  4. <view class="formData_top">
  5. <view class="flex row">
  6. <view class="left-text">提现金额</view>
  7. <view class="flex right-text">
  8. <u--input placeholder="输入提现金额" inputAlign='right' border="none" clearable
  9. v-model="formInfo.amountMoney" type="number">
  10. </u--input>
  11. </view>
  12. </view>
  13. <view class="tips flex">
  14. <view style="width: 60%;">
  15. <span class="qian">¥</span>
  16. 可提现{{usableMoney}}元
  17. </view>
  18. <view style="color: #007AFF;text-align: right;width: 40%;margin-top: 30rpx;" @click="writeIn">全部提现</view>
  19. </view>
  20. </view>
  21. <view class="formData_bottom">
  22. <view class="flex row">
  23. <view class="left-text">提现到银行卡</view>
  24. <view class="flex right-text" @click="bankChange">
  25. {{formInfo.bankDeposit?formInfo.bankDeposit:"请选择收款账户"}} {{bankNo}}
  26. <image src="../../../static/images/myimg/gengduo1@3x.png" mode=""
  27. style="width: 20rpx;height: 30rpx;top: 10rpx;margin-left: 10rpx;"></image>
  28. </view>
  29. </view>
  30. <view class="flex row">
  31. <view class="left-text">开户行</view>
  32. <view class="flex right-text">
  33. <u--input placeholder="自动获取" inputAlign='right' border="none" clearable
  34. v-model="formInfo.bankDeposit">
  35. </u--input>
  36. </view>
  37. </view>
  38. <view class="flex row">
  39. <view class="left-text">开户支行</view>
  40. <view class="flex right-text">
  41. <u--input placeholder="自动获取" inputAlign='right' border="none" clearable
  42. v-model="formInfo.bankDepositBranch">
  43. </u--input>
  44. </view>
  45. </view>
  46. <view class="flex row ">
  47. <view class="left-text">账号</view>
  48. <view class="flex right-text">
  49. <u--input placeholder="自动获取" inputAlign='right' border="none" clearable v-model="formInfo.bankCard">
  50. </u--input>
  51. </view>
  52. </view>
  53. <view class="flex row">
  54. <view class="left-text">收款方</view>
  55. <view class="flex right-text">
  56. <u--input placeholder="自动获取" inputAlign='right' border="none" clearable
  57. v-model="formInfo.payeeName">
  58. </u--input>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <u-toast ref="uToast"></u-toast>
  64. <u-modal :show="isShowAlert" :title="alertTitle" :content='alertContent' :closeOnClickOverlay='true'
  65. :showCancelButton='showCancelButton' confirmColor='#F5BA3C' @confirm="$u.throttle(confirmClick(), 1000)" @close="cancelClick"
  66. @cancel="cancelClick"></u-modal>
  67. <view @click="$u.throttle(submit, 1000)" class='newlyIncreased'>提交</view>
  68. <!-- <u-button type="primary" text="提交" @click="submit" class="btn_css"></u-button> -->
  69. </view>
  70. </template>
  71. <script>
  72. import {
  73. mapState
  74. } from 'vuex';
  75. export default {
  76. data() {
  77. return {
  78. formInfo: {},
  79. bankNo: "",
  80. flag: "", //1个人2公司
  81. id: "",
  82. usableMoney: 0, //可提现的
  83. isShowAlert: false,
  84. alertTitle: "",
  85. alertContent: "",
  86. showCancelButton: true,
  87. enterprise:""//企业名称
  88. }
  89. },
  90. onLoad(options) {
  91. this.flag = options.flag
  92. this.id = options.id
  93. this.getList()
  94. },
  95. onShow() {
  96. if (uni.getStorageSync("bankInfo")) {
  97. let obj = uni.getStorageSync("bankInfo")
  98. this.formInfo.bankDeposit = obj.bankDeposit
  99. this.formInfo.bankDepositBranch = obj.bankDepositBranch
  100. this.formInfo.bankCard = obj.bankCard
  101. this.formInfo.payeeName = obj.cardholderName
  102. this.bankNo = obj.bankCard.substring(obj.bankCard.length - 4)
  103. } else {
  104. this.defaultBank()
  105. }
  106. },
  107. computed: {
  108. ...mapState(['hasLogin', 'userInfo']),
  109. },
  110. methods: {
  111. defaultBank() { //查询默认银行卡
  112. this.$request.baseRequest('get', '/hyCargoOwnerPayeeInfo/getPayee', {
  113. commonId: this.userInfo.id
  114. }).then(res => {
  115. if (res.data) {
  116. this.formInfo.bankDeposit = res.data.bankDeposit
  117. this.formInfo.bankDepositBranch = res.data.bankDepositBranch
  118. this.formInfo.bankCard = res.data.bankCard
  119. this.formInfo.payeeName = res.data.cardholderName
  120. this.bankNo = res.data.bankCard.substring(res.data.bankCard.length - 4)
  121. }
  122. this.$forceUpdate()
  123. })
  124. },
  125. bankChange() { //选择银行卡
  126. uni.$u.route("/pages/mine/myAccount/bankList?enterprise=" + this.enterprise)
  127. },
  128. getList() {
  129. this.$request.baseRequest('get', '/cargoOwnerInfo/selectAccountBalance', {
  130. id: this.id,
  131. flag: this.flag
  132. }).then(res => {
  133. if(res.data){
  134. this.usableMoney = Number(res.data.accountBalance)
  135. this.enterprise = res.data.companyName
  136. }
  137. })
  138. },
  139. writeIn() {
  140. this.formInfo.amountMoney = this.usableMoney
  141. this.$forceUpdate()
  142. },
  143. validate() {
  144. if (uni.$u.test.isEmpty(this.formInfo.amountMoney)) {
  145. this.$refs.uToast.show({
  146. type: 'error',
  147. message: "提现金额不能为空!",
  148. })
  149. return true
  150. }
  151. if (this.formInfo.amountMoney <= 0) {
  152. this.$refs.uToast.show({
  153. type: 'error',
  154. message: "请输入提现金额!",
  155. })
  156. return true
  157. }
  158. if (Number(this.usableMoney) < Number(this.formInfo.amountMoney)) {
  159. this.$refs.uToast.show({
  160. type: 'error',
  161. message: "提现金额超出可用余额!",
  162. })
  163. return true
  164. }
  165. if (uni.$u.test.isEmpty(this.formInfo.bankDeposit)) {
  166. this.$refs.uToast.show({
  167. type: 'error',
  168. message: "收款开户行不能为空!",
  169. })
  170. return true
  171. }
  172. if (uni.$u.test.isEmpty(this.formInfo.bankDepositBranch)) {
  173. this.$refs.uToast.show({
  174. type: 'error',
  175. message: "收款开户支行不能为空!",
  176. })
  177. return true
  178. }
  179. if (uni.$u.test.isEmpty(this.formInfo.bankCard)) {
  180. this.$refs.uToast.show({
  181. type: 'error',
  182. message: "收款卡号不能为空!",
  183. })
  184. return true
  185. }
  186. if (uni.$u.test.isEmpty(this.formInfo.payeeName)) {
  187. this.$refs.uToast.show({
  188. type: 'error',
  189. message: "收款人姓名不能为空!",
  190. })
  191. return true
  192. }
  193. },
  194. cancelClick() {
  195. this.isShowAlert = false
  196. },
  197. submit() {
  198. if (this.validate()) return
  199. this.formInfo.flag = this.flag //个人1 企业2
  200. this.isShowAlert = true
  201. this.alertTitle = "确定提现?"
  202. },
  203. confirmClick() {
  204. if (this.flag == 1) {
  205. this.formInfo.commonId = this.userInfo.id //用户id
  206. this.formInfo.accountId = this.id //个人 个人信息id
  207. } else if (this.flag == 2) {
  208. this.formInfo.companyId = this.id //公司id
  209. this.formInfo.accountId = this.id //公司id
  210. }
  211. this.$request.baseRequest('post', '/hyCargoOwnerCapitalInfo/api/withdrawal', this.formInfo).then(res => {
  212. if (res.code == 200) {
  213. this.isShowAlert = false
  214. this.$refs.uToast.show({
  215. type: 'success',
  216. message: "提现成功!",
  217. complete() {
  218. uni.navigateBack({
  219. delta: 1
  220. })
  221. }
  222. })
  223. }
  224. })
  225. }
  226. }
  227. }
  228. </script>
  229. <style lang="scss" scoped>
  230. .center {
  231. padding: 20rpx;
  232. background: #F5F6FA;
  233. height: calc(100vh - 9.9vh);
  234. .btn_css{
  235. margin-top: 45rpx;
  236. }
  237. .formData {
  238. .formData_top {
  239. background: #ffffff;
  240. height: 200rpx;
  241. padding: 10rpx 30rpx;
  242. border-radius: 20rpx;
  243. .tips {
  244. width: 100%;
  245. height: 60rpx;
  246. color: #C6CBD5 ;
  247. .qian {
  248. font-size: 62rpx;
  249. color: #333333 ;
  250. }
  251. }
  252. }
  253. .formData_bottom{
  254. background: #ffffff;
  255. padding: 10rpx 30rpx;
  256. border-radius: 20rpx;
  257. margin-top: 20rpx;
  258. }
  259. .row {
  260. margin: 30rpx 0;
  261. }
  262. .left-text {
  263. // background: red;
  264. width: 40%;
  265. color: #333333;
  266. display: flex;
  267. align-items: center;
  268. }
  269. .right-text {
  270. width: 60%;
  271. justify-content: flex-end;
  272. }
  273. }
  274. }
  275. .newlyIncreased {
  276. width: 100%;
  277. height: 80rpx;
  278. margin: 20px auto;
  279. text-align: center;
  280. color: #fff;
  281. background: #F5BA3C;
  282. background-size: 100%;
  283. border-radius: 50rpx;
  284. display: flex;
  285. align-items: center;
  286. justify-content: center;
  287. }
  288. </style>