index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. <template>
  2. <view class="cash-content" :style="{'--status-bar-': statusBarHeight}">
  3. <view class="cash-content-info">
  4. <!-- 头部主要内容 开始 -->
  5. <view class="cash-content-header">
  6. <customNavbar title="余额提现" bgColor="rgba(0,0,0,0)" :customNavbarInfo="{}" :contentStyle="{}"
  7. :leftStyle="{color: '#fff'}"></customNavbar>
  8. <!-- 余额 开始 -->
  9. <view class="cash-content-money">
  10. <!-- <text>可提现余额(元)</text>
  11. <view class="cash-content-money-num">
  12. <text>
  13. <text class="inspage-userinfo-util">¥</text>
  14. <u-count-to :decimals="2" :startVal="0" :endVal="monry" color="#fff" />
  15. <text class="balance-userinfo-util">元</text>
  16. </text>
  17. </view> -->
  18. </view>
  19. <!-- 余额 结束 -->
  20. <!-- 提现 开始 -->
  21. <view class="cash-content-cash">
  22. <view class="cash-content-cash-box">
  23. <text>提现金额</text>
  24. <view class="cash-content-cash-money">
  25. <text class="cash-content-cash-money-icon">¥</text>
  26. <view class="cash-content-cash-input">
  27. <!-- <u--input :readonly="true" placeholder="请输入内容" border="none" clearable type="number" v-model="moneyValue"
  28. @change="moneyAccountFun"></u--input> -->
  29. <text>{{ moneyValue }}</text>
  30. </view>
  31. <!-- <text class="cash-content-cash-money-all" @click="cashAll()">全部提现</text> -->
  32. </view>
  33. <view class="cash-content-cash-service">
  34. <view>
  35. <text>提现手续费</text>
  36. <!-- <text>{{ setServiceType(withdrawInfo)}}</text> -->
  37. <text>¥{{ this.withdrawInfo.serviceCharge }}</text>
  38. </view>
  39. <view>
  40. <text>合计提现</text>
  41. <!-- <text>¥ {{ moneyAccount }}</text> -->
  42. <text>¥{{ this.withdrawInfo.realAmount }}</text>
  43. </view>
  44. </view>
  45. <view class="cash-content-cash-card">
  46. <u-cell-group :border="false">
  47. <u-cell :border="false" title="提现至" :isLink="false" :value="'银行卡'"></u-cell>
  48. </u-cell-group>
  49. </view>
  50. <view class="cash-content-cash-submit">
  51. <view @click="openModal">提现</view>
  52. </view>
  53. </view>
  54. </view>
  55. <!-- 提现 结束 -->
  56. <!-- 选择银行卡 -->
  57. <u-picker :show="show" keyName="label" :columns="columns" @cancel="cancelPicker"
  58. @confirm="confirmPicker"></u-picker>
  59. </view>
  60. <!-- 头部主要内容 结束 -->
  61. <!-- 输入密码 -->
  62. <u-overlay :show="showModal">
  63. <view class="password-model">
  64. <view>
  65. <view>请输入支付密码</view>
  66. <view>提现</view>
  67. <view>¥{{ this.withdrawInfo.realAmount }}</view>
  68. <view>
  69. <u-code-input
  70. @finish="marketPersons"
  71. dot
  72. v-model="password" :focus="true"></u-code-input>
  73. </view>
  74. <text @click="clearOverlay"><u-icon name="close-circle" size="30"></u-icon></text>
  75. </view>
  76. </view>
  77. </u-overlay>
  78. </view>
  79. <u-modal :show="showModel" @confirm="confirmModel" :confirmText="confirmText" ref="uModal" :asyncClose="true" >
  80. <view class="slot-content">
  81. <view style="display: flex;justify-content: center;padding-bottom: 20rpx;">
  82. <image style="width: 100rpx;height: 100rpx;" :src="showStatus == 0 ? suImage : errorImage" mode="scaleToFill" />
  83. </view>
  84. <view>
  85. <rich-text :nodes="contentModel"></rich-text>
  86. </view>
  87. </view>
  88. </u-modal>
  89. </view>
  90. </template>
  91. <script>
  92. import { Decimal } from 'decimal.js';//引入
  93. import {
  94. navigateTo
  95. } from "@/utils/util.js"
  96. export default {
  97. data() {
  98. return {
  99. title: '这是我的',
  100. statusBarHeight: 0, // 状态栏安全距离
  101. monry: 0,
  102. moneyValue: null,
  103. moneyAccount: '',
  104. show: false,
  105. columns: [
  106. [{
  107. label: '雪月夜',
  108. // 其他属性值
  109. id: 2021
  110. // ...
  111. }, {
  112. label: '冷夜雨',
  113. id: 804
  114. }]
  115. ],
  116. withdrawInfo: {},
  117. showModal: false,
  118. password: '',
  119. personList:[],
  120. serviceMoney: null,
  121. showModel: false,
  122. contentModel: '提交申请提交成功,佣金将会在1-2个工作日内发放到银行卡,请耐心等待!',
  123. errorImage: this.$commonConfig.staticUrl + 'cash/shiban.png',
  124. suImage: this.$commonConfig.staticUrl + 'cash/chenggong.png',
  125. showStatus: null,
  126. confirmText: '关闭',
  127. }
  128. },
  129. onLoad(page) {
  130. this.moneyValue = Number(page.withdrawTotal);
  131. this.personList = JSON.parse(page.personList);
  132. // #ifdef H5
  133. //window.addEventListener('popstate', this.browserBack)
  134. // #endif
  135. },
  136. onUnload() {
  137. // #ifdef H5
  138. //window.removeEventListener("popstate", this.browserBack);
  139. // #endif
  140. },
  141. onShow() {
  142. //this.statusBarHeight = getApp().globalData.statusBarHeight
  143. this.showModel = false
  144. this.getWithdrawInfo()
  145. },
  146. methods: {
  147. /**
  148. * @author ygh
  149. * @data 2023-12-20
  150. */
  151. navigateToFun() {
  152. navigateTo('/pages/cash/index')
  153. },
  154. /**
  155. * 数字显示格式化
  156. *
  157. */
  158. numFormat(num = 0) {
  159. if (num < 100000) {
  160. return num
  161. } else if (num > 100000) {
  162. return (num / 10000).toFixed(2)
  163. }
  164. },
  165. /** 全部提现 */
  166. cashAll() {
  167. this.moneyValue = this.monry
  168. },
  169. /**
  170. * 打开选择器
  171. */
  172. openPopup() {
  173. return
  174. this.show = true
  175. },
  176. /** 取消选择器 */
  177. cancelPicker() {
  178. this.show = false
  179. },
  180. /** 确认选择器 */
  181. confirmPicker() {
  182. this.show = false
  183. },
  184. /**
  185. * 获取数据
  186. */
  187. async getWithdrawInfo() {
  188. try {
  189. let list = []
  190. this.personList.forEach((item,index)=> {
  191. list.push(item.personsId)
  192. })
  193. let res = await this.$u.api.getSettlement({
  194. noSign: 1,
  195. userid: this.distribution_user_info.userId,
  196. withdrawAmount: this.moneyValue,
  197. withdrawList: list
  198. })
  199. if (res && res.code === 200) {
  200. this.withdrawInfo = res.data
  201. // this.withdrawInfo.serviceType = 1
  202. // this.withdrawInfo.serviceCharge = 0
  203. this.moneyValue = this.withdrawInfo.totalAmount
  204. // this.monry = res.data.withdrawTotal;
  205. // this.moneyAccountFun();
  206. }
  207. } catch (e) {
  208. //TODO handle the exception
  209. console.error("e===", e)
  210. }
  211. },
  212. async openModal() {
  213. // if (!this.moneyValue || this.moneyValue < this.withdrawInfo.minAmount) {
  214. // uni.showToast({
  215. // title: '最小提现金额' + this.withdrawInfo.minAmount,
  216. // icon: 'none'
  217. // });
  218. // return
  219. // }
  220. // if(this.moneyValue > this.monry) {
  221. // uni.showToast({
  222. // title: '总金额不能大于用户可提现金额',
  223. // icon: 'none'
  224. // });
  225. // return
  226. // }
  227. // uni.showModal({
  228. // title: '提示',
  229. // content: '确定提现余额吗?',
  230. // success: res => {
  231. // this.orderWithdraw()
  232. // },
  233. // complete() {
  234. // }
  235. // })
  236. /**
  237. * 获取 我的银行卡
  238. */
  239. try {
  240. uni.showLoading({
  241. title: "获取银行卡中..."
  242. })
  243. let res = await this.$u.api.getPersonsBankApi({
  244. userid: this.distribution_user_info.userId
  245. })
  246. uni.hideLoading()
  247. if (res && res.code === 200 && res.data.bankNo) {
  248. this.showModal = true
  249. // #ifdef H5
  250. window.history.replaceState(null, null, document.URL)
  251. // #endif
  252. }else {
  253. navigateTo('/pages/bankCard/index')
  254. }
  255. } catch (e) {
  256. //TODO handle the exception
  257. console.error("e===", e)
  258. uni.showToast({
  259. title: "绑定成功!!!",
  260. duration: 2000
  261. })
  262. uni.hideLoading()
  263. }
  264. },
  265. /** 关闭 */
  266. clearOverlay() {
  267. this.showModal = false
  268. },
  269. /**
  270. * 密码校验
  271. */
  272. async marketPersons() {
  273. try {
  274. let res = await this.$u.api.marketPersons({
  275. noSign: 1,
  276. userid: this.distribution_user_info.userId,
  277. oldPassword: this.password
  278. })
  279. if (res && res.code === 200) {
  280. this.orderWithdraw()
  281. } else {
  282. this.password = ''
  283. }
  284. } catch (e) {
  285. //TODO handle the exception
  286. console.error("e===", e)
  287. this.password = ''
  288. }
  289. },
  290. /**
  291. * 提交申请
  292. */
  293. async orderWithdraw() {
  294. try {
  295. let list = []
  296. this.personList.forEach((item,index)=> {
  297. list.push(item.personsId)
  298. })
  299. this.contentModel = "提现申请提交失败!"
  300. this.confirmText = '关闭'
  301. this.showStatus = 1
  302. let res = await this.$u.api.withdrawApply({
  303. noSign: 1,
  304. userid: this.distribution_user_info.userId,
  305. // "withdrawType": "wechat",
  306. // "withdrawTotal": this.moneyAccount,
  307. // "serviceAmount": this.withdrawInfo.serviceCharge,
  308. // "bankId": null,
  309. //personList:this.personList
  310. withdrawList: list,
  311. withdrawAmount: this.withdrawInfo.totalAmount,
  312. serviceCharge: this.withdrawInfo.serviceCharge
  313. })
  314. if (res && res.code == 200) {
  315. this.contentModel = "提现申请提交成功,佣金将会在5个工作日内发放到银行卡,请耐心等待!"
  316. this.confirmText = '返回'
  317. this.showStatus = 0
  318. this.showModel = true
  319. // navigateTo('/pages/cashPrompt/index',{
  320. // id: res.data.orderId,
  321. // serviceMoney: this.serviceMoney,
  322. // // ...res.data.bankInfo,
  323. // // moneyValue: this.moneyValue,
  324. // // withdrawType: 'wechat',
  325. // // serviceType: this.withdrawInfo.serviceType,
  326. // // serviceCharge: this.withdrawInfo.serviceCharge
  327. // })
  328. } else {
  329. this.showModel = true
  330. this.password = ''
  331. }
  332. this.showModal = false
  333. } catch (e) {
  334. //TODO handle the exception
  335. console.error("e===", e)
  336. this.password = ''
  337. this.showModal = false
  338. this.showModel = true
  339. }
  340. },
  341. /**
  342. * 设置服务费显示
  343. */
  344. setServiceType(data) {
  345. if (data && data.serviceType) {
  346. if(data.serviceType == 1){
  347. this.serviceMoney = data.serviceCharge
  348. return ('¥' + data.serviceCharge)
  349. }else {
  350. let num1 = this.withdrawInfo.serviceCharge;
  351. let num = isNaN(num1) ? 0 : (Number(num1) / 100)
  352. let money = num ? new Decimal(this.moneyValue).mul(new Decimal(num)) : 0
  353. this.serviceMoney = money
  354. return '¥' + money
  355. }
  356. }
  357. },
  358. /**
  359. * 设置到账金额
  360. */
  361. moneyAccountFun() {
  362. let money = ''
  363. if (this.withdrawInfo.serviceType == 1) {
  364. money = (isNaN(this.withdrawInfo.serviceCharge) ? 0 : this.withdrawInfo
  365. .serviceCharge)
  366. } else if (this.withdrawInfo.serviceType == 2) {
  367. let num1 = this.withdrawInfo.serviceCharge;
  368. let num = isNaN(num1) ? 0 : (Number(num1) / 100)
  369. money = num ? new Decimal(this.moneyValue).mul(new Decimal(num)) : 0
  370. }
  371. this.moneyAccount = money < 0 ? '金额小于零' : new Decimal(this.moneyValue).sub(new Decimal(money.toFixed(2)))
  372. },
  373. browserBack() {
  374. console.log(1);
  375. // 在这里写弹框
  376. uni.showModal({
  377. title: '提示',
  378. content: '返回后此页面的操作将不作保留!',
  379. cancelText: '确定返回',
  380. confirmText: '留在此页',
  381. success: (res) => {
  382. if (res.confirm) {
  383. // 用户选择留在此页,不进行任何操作
  384. } else if (res.cancel) {
  385. //window.history.back(); // 使用window.history.back()返回上一页
  386. }
  387. }
  388. });
  389. //window.history.replaceState(null, null, document.URL); // 保留此行代码
  390. },
  391. /** */
  392. confirmModel() {
  393. this.showModel = false
  394. if(this.showStatus == 0) {
  395. uni.navigateBack({
  396. delta: 2
  397. })
  398. }
  399. }
  400. }
  401. }
  402. </script>
  403. <style lang="scss" scoped>
  404. .cash-content {
  405. display: flex;
  406. flex-direction: column;
  407. align-items: center;
  408. justify-content: center;
  409. --header-h: 420rpx;
  410. .cash-content-info {
  411. width: 100%;
  412. box-sizing: border-box;
  413. }
  414. }
  415. /** 头部主要内容 开始 */
  416. .cash-content-header {
  417. width: 100%;
  418. height: var(--header-h);
  419. box-sizing: border-box;
  420. background: var(--gd-bgm-lg-color);
  421. position: relative;
  422. ::v-deep .u-search {
  423. padding: 0 30rpx !important;
  424. }
  425. ::v-deep .u-search__action {
  426. color: #fff !important;
  427. }
  428. /** 余额 开始 */
  429. .cash-content-money {
  430. width: 100%;
  431. box-sizing: border-box;
  432. margin-top: 50rpx;
  433. padding-left: 66rpx;
  434. color: #fff;
  435. >text {
  436. font-size: 24rpx;
  437. }
  438. .cash-content-money-num {
  439. display: flex;
  440. justify-content: center;
  441. align-items: flex-start;
  442. flex-direction: column;
  443. margin-top: 24rpx;
  444. >text:nth-child(1) {
  445. .balance-userinfo-util {
  446. font-size: 24rpx;
  447. margin-left: 5rpx;
  448. }
  449. ::v-deep .u-count-num {
  450. font-weight: bold !important;
  451. font-size: 48rpx !important;
  452. }
  453. }
  454. >text:nth-child(2) {
  455. margin-top: 20rpx;
  456. font-size: 24rpx;
  457. }
  458. }
  459. }
  460. /** 余额 结束 */
  461. /** 提现 开始 */
  462. .cash-content-cash {
  463. width: 100%;
  464. box-sizing: border-box;
  465. position: absolute;
  466. top: 100%;
  467. transform: translateY(-50%);
  468. padding: 0 12rpx;
  469. .cash-content-cash-box {
  470. width: 100%;
  471. height: 100%;
  472. background-color: #fff;
  473. box-shadow: 0rpx 2rpx 12rpx 0rpx rgba(221, 221, 221, 0.5);
  474. border-radius: 20rpx;
  475. box-sizing: border-box;
  476. padding: 34rpx 30rpx 38rpx;
  477. >text {
  478. font-size: 36rpx;
  479. color: #222222;
  480. font-weight: 600;
  481. }
  482. .cash-content-cash-money {
  483. width: 100%;
  484. display: flex;
  485. align-items: center;
  486. padding: 40rpx 0 20rpx;
  487. border-bottom: 2rpx solid #EEEEEE;
  488. ::v-deep .u-cell__body {
  489. padding: 20rpx 0 !important;
  490. }
  491. .cash-content-cash-input {
  492. width: 100%;
  493. padding: 0 10rpx;
  494. }
  495. .cash-content-cash-input text {
  496. font-size: 60rpx !important;
  497. }
  498. >text {
  499. flex-shrink: 0;
  500. flex-wrap: nowrap;
  501. white-space: nowrap;
  502. }
  503. .cash-content-cash-money-icon {
  504. font-size: 32rpx;
  505. }
  506. .cash-content-cash-money-all {
  507. color: var(--gd-but-color);
  508. font-size: 24rpx;
  509. cursor: pointer;
  510. }
  511. }
  512. .cash-content-cash-service {
  513. width: 100%;
  514. box-sizing: border-box;
  515. padding: 20rpx 0;
  516. //border-bottom: 2rpx solid #EEEEEE;
  517. >view {
  518. width: 100%;
  519. display: flex;
  520. justify-content: space-between;
  521. align-items: center;
  522. color: #606060;
  523. padding: 5rpx 0 10rpx;
  524. font-size: 24rpx;
  525. >text {
  526. font-size: 28rpx;
  527. }
  528. }
  529. }
  530. .cash-content-cash-card {
  531. width: 100%;
  532. ::v-deep .u-cell__body {
  533. padding: 20rpx 0 !important;
  534. }
  535. }
  536. .cash-content-cash-submit {
  537. width: 100%;
  538. height: 92rpx;
  539. display: flex;
  540. align-items: center;
  541. justify-content: center;
  542. box-sizing: border-box;
  543. padding: 0 80rpx 0;
  544. margin-top: 70rpx;
  545. >view {
  546. width: 100%;
  547. height: 100%;
  548. border-radius: 46rpx;
  549. color: #fff;
  550. background-color: var(--gd-but-color);
  551. font-size: 28rpx;
  552. font-family: SourceHanSansCN, SourceHanSansCN;
  553. display: flex;
  554. align-items: center;
  555. justify-content: center;
  556. }
  557. }
  558. }
  559. }
  560. /** 提现 结束 */
  561. }
  562. /** 头部主要内容 结束 **/
  563. /** 密码弹窗 */
  564. .password-model {
  565. width: 100%;
  566. height: 100%;
  567. display: flex;
  568. justify-content: center;
  569. align-items: center;
  570. box-sizing: border-box;
  571. padding: 0 40rpx;
  572. >view {
  573. width: 100%;
  574. display: flex;
  575. justify-content: center;
  576. align-items: center;
  577. flex-direction: column;
  578. background-color: #fff;
  579. color: #000;
  580. padding: 50rpx 10rpx;
  581. box-sizing: border-box;
  582. position: relative;
  583. border-radius: 20rpx;
  584. >view {
  585. font-size: 32rpx;
  586. padding: 10rpx 0;
  587. box-sizing: border-box;
  588. }
  589. >view:nth-child(3) {
  590. width: 100%;
  591. display: flex;
  592. justify-content: center;
  593. align-items: center;
  594. font-size: 52rpx;
  595. border-bottom: 2rpx solid #ccc;
  596. padding: 10rpx 0 20rpx;
  597. color: var(--gd-bgm-color);
  598. }
  599. >view:nth-child(4) {
  600. margin-top: 30rpx;
  601. }
  602. >text {
  603. position: absolute;
  604. top: 0;
  605. right: 0;
  606. }
  607. }
  608. }
  609. </style>