index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  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 @finish="marketPersons" dot v-model="password" :focus="true"></u-code-input>
  70. </view>
  71. <text @click="clearOverlay"><u-icon name="close-circle" size="30"></u-icon></text>
  72. </view>
  73. </view>
  74. </u-overlay>
  75. </view>
  76. <u-modal :show="showModel" @confirm="confirmModel" :confirmText="confirmText" ref="uModal" :asyncClose="true">
  77. <view class="slot-content">
  78. <view style="display: flex;justify-content: center;padding-bottom: 20rpx;">
  79. <image style="width: 100rpx;height: 100rpx;" :src="showStatus == 0 ? suImage : errorImage"
  80. mode="scaleToFill" />
  81. </view>
  82. <view>
  83. <rich-text :nodes="contentModel"></rich-text>
  84. </view>
  85. </view>
  86. </u-modal>
  87. </view>
  88. </template>
  89. <script>
  90. import {
  91. Decimal
  92. } 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. console.log(res, 'res111')
  248. if (res && res.code === 200 && res.data?.bankNo) {
  249. this.showModal = true
  250. // #ifdef H5
  251. window.history.replaceState(null, null, document.URL)
  252. // #endif
  253. } else {
  254. navigateTo('/pages/bankCard/index')
  255. }
  256. } catch (e) {
  257. //TODO handle the exception
  258. console.error("e===", e)
  259. // uni.showToast({
  260. // title: "绑定成功!!!",
  261. // duration: 2000
  262. // })
  263. uni.hideLoading()
  264. }
  265. },
  266. /** 关闭 */
  267. clearOverlay() {
  268. this.showModal = false
  269. },
  270. /**
  271. * 密码校验
  272. */
  273. async marketPersons() {
  274. try {
  275. let res = await this.$u.api.marketPersons({
  276. noSign: 1,
  277. userid: this.distribution_user_info.userId,
  278. oldPassword: this.password
  279. })
  280. if (res && res.code === 200) {
  281. this.orderWithdraw()
  282. } else {
  283. this.password = ''
  284. }
  285. } catch (e) {
  286. //TODO handle the exception
  287. console.error("e===", e)
  288. this.password = ''
  289. }
  290. },
  291. /**
  292. * 提交申请
  293. */
  294. async orderWithdraw() {
  295. try {
  296. let list = []
  297. this.personList.forEach((item, index) => {
  298. list.push(item.personsId)
  299. })
  300. this.contentModel = "提现申请提交失败!"
  301. this.confirmText = '关闭'
  302. this.showStatus = 1
  303. let res = await this.$u.api.withdrawApply({
  304. noSign: 1,
  305. userid: this.distribution_user_info.userId,
  306. // "withdrawType": "wechat",
  307. // "withdrawTotal": this.moneyAccount,
  308. // "serviceAmount": this.withdrawInfo.serviceCharge,
  309. // "bankId": null,
  310. //personList:this.personList
  311. withdrawList: list,
  312. withdrawAmount: this.withdrawInfo.totalAmount,
  313. serviceCharge: this.withdrawInfo.serviceCharge
  314. })
  315. if (res && res.code == 200) {
  316. this.contentModel = "提现申请提交成功,佣金将会在5个工作日内发放到银行卡,请耐心等待!"
  317. this.confirmText = '返回'
  318. this.showStatus = 0
  319. this.showModel = true
  320. // navigateTo('/pages/cashPrompt/index',{
  321. // id: res.data.orderId,
  322. // serviceMoney: this.serviceMoney,
  323. // // ...res.data.bankInfo,
  324. // // moneyValue: this.moneyValue,
  325. // // withdrawType: 'wechat',
  326. // // serviceType: this.withdrawInfo.serviceType,
  327. // // serviceCharge: this.withdrawInfo.serviceCharge
  328. // })
  329. } else {
  330. this.showModel = true
  331. this.password = ''
  332. }
  333. this.showModal = false
  334. } catch (e) {
  335. //TODO handle the exception
  336. console.error("e===", e)
  337. this.password = ''
  338. this.showModal = false
  339. this.showModel = true
  340. }
  341. },
  342. /**
  343. * 设置服务费显示
  344. */
  345. setServiceType(data) {
  346. if (data && data.serviceType) {
  347. if (data.serviceType == 1) {
  348. this.serviceMoney = data.serviceCharge
  349. return ('¥' + data.serviceCharge)
  350. } else {
  351. let num1 = this.withdrawInfo.serviceCharge;
  352. let num = isNaN(num1) ? 0 : (Number(num1) / 100)
  353. let money = num ? new Decimal(this.moneyValue).mul(new Decimal(num)) : 0
  354. this.serviceMoney = money
  355. return '¥' + money
  356. }
  357. }
  358. },
  359. /**
  360. * 设置到账金额
  361. */
  362. moneyAccountFun() {
  363. let money = ''
  364. if (this.withdrawInfo.serviceType == 1) {
  365. money = (isNaN(this.withdrawInfo.serviceCharge) ? 0 : this.withdrawInfo
  366. .serviceCharge)
  367. } else if (this.withdrawInfo.serviceType == 2) {
  368. let num1 = this.withdrawInfo.serviceCharge;
  369. let num = isNaN(num1) ? 0 : (Number(num1) / 100)
  370. money = num ? new Decimal(this.moneyValue).mul(new Decimal(num)) : 0
  371. }
  372. this.moneyAccount = money < 0 ? '金额小于零' : new Decimal(this.moneyValue).sub(new Decimal(money.toFixed(2)))
  373. },
  374. browserBack() {
  375. console.log(1);
  376. // 在这里写弹框
  377. uni.showModal({
  378. title: '提示',
  379. content: '返回后此页面的操作将不作保留!',
  380. cancelText: '确定返回',
  381. confirmText: '留在此页',
  382. success: (res) => {
  383. if (res.confirm) {
  384. // 用户选择留在此页,不进行任何操作
  385. } else if (res.cancel) {
  386. //window.history.back(); // 使用window.history.back()返回上一页
  387. }
  388. }
  389. });
  390. //window.history.replaceState(null, null, document.URL); // 保留此行代码
  391. },
  392. /** */
  393. confirmModel() {
  394. this.showModel = false
  395. if (this.showStatus == 0) {
  396. uni.navigateBack({
  397. delta: 2
  398. })
  399. }
  400. }
  401. }
  402. }
  403. </script>
  404. <style lang="scss" scoped>
  405. .cash-content {
  406. display: flex;
  407. flex-direction: column;
  408. align-items: center;
  409. justify-content: center;
  410. --header-h: 420rpx;
  411. .cash-content-info {
  412. width: 100%;
  413. box-sizing: border-box;
  414. }
  415. }
  416. /** 头部主要内容 开始 */
  417. .cash-content-header {
  418. width: 100%;
  419. height: var(--header-h);
  420. box-sizing: border-box;
  421. background: var(--gd-bgm-lg-color);
  422. position: relative;
  423. ::v-deep .u-search {
  424. padding: 0 30rpx !important;
  425. }
  426. ::v-deep .u-search__action {
  427. color: #fff !important;
  428. }
  429. /** 余额 开始 */
  430. .cash-content-money {
  431. width: 100%;
  432. box-sizing: border-box;
  433. margin-top: 50rpx;
  434. padding-left: 66rpx;
  435. color: #fff;
  436. >text {
  437. font-size: 24rpx;
  438. }
  439. .cash-content-money-num {
  440. display: flex;
  441. justify-content: center;
  442. align-items: flex-start;
  443. flex-direction: column;
  444. margin-top: 24rpx;
  445. >text:nth-child(1) {
  446. .balance-userinfo-util {
  447. font-size: 24rpx;
  448. margin-left: 5rpx;
  449. }
  450. ::v-deep .u-count-num {
  451. font-weight: bold !important;
  452. font-size: 48rpx !important;
  453. }
  454. }
  455. >text:nth-child(2) {
  456. margin-top: 20rpx;
  457. font-size: 24rpx;
  458. }
  459. }
  460. }
  461. /** 余额 结束 */
  462. /** 提现 开始 */
  463. .cash-content-cash {
  464. width: 100%;
  465. box-sizing: border-box;
  466. position: absolute;
  467. top: 100%;
  468. transform: translateY(-50%);
  469. padding: 0 12rpx;
  470. .cash-content-cash-box {
  471. width: 100%;
  472. height: 100%;
  473. background-color: #fff;
  474. box-shadow: 0rpx 2rpx 12rpx 0rpx rgba(221, 221, 221, 0.5);
  475. border-radius: 20rpx;
  476. box-sizing: border-box;
  477. padding: 34rpx 30rpx 38rpx;
  478. >text {
  479. font-size: 36rpx;
  480. color: #222222;
  481. font-weight: 600;
  482. }
  483. .cash-content-cash-money {
  484. width: 100%;
  485. display: flex;
  486. align-items: center;
  487. padding: 40rpx 0 20rpx;
  488. border-bottom: 2rpx solid #EEEEEE;
  489. ::v-deep .u-cell__body {
  490. padding: 20rpx 0 !important;
  491. }
  492. .cash-content-cash-input {
  493. width: 100%;
  494. padding: 0 10rpx;
  495. }
  496. .cash-content-cash-input text {
  497. font-size: 60rpx !important;
  498. }
  499. >text {
  500. flex-shrink: 0;
  501. flex-wrap: nowrap;
  502. white-space: nowrap;
  503. }
  504. .cash-content-cash-money-icon {
  505. font-size: 32rpx;
  506. }
  507. .cash-content-cash-money-all {
  508. color: var(--gd-but-color);
  509. font-size: 24rpx;
  510. cursor: pointer;
  511. }
  512. }
  513. .cash-content-cash-service {
  514. width: 100%;
  515. box-sizing: border-box;
  516. padding: 20rpx 0;
  517. //border-bottom: 2rpx solid #EEEEEE;
  518. >view {
  519. width: 100%;
  520. display: flex;
  521. justify-content: space-between;
  522. align-items: center;
  523. color: #606060;
  524. padding: 5rpx 0 10rpx;
  525. font-size: 24rpx;
  526. >text {
  527. font-size: 28rpx;
  528. }
  529. }
  530. }
  531. .cash-content-cash-card {
  532. width: 100%;
  533. ::v-deep .u-cell__body {
  534. padding: 20rpx 0 !important;
  535. }
  536. }
  537. .cash-content-cash-submit {
  538. width: 100%;
  539. height: 92rpx;
  540. display: flex;
  541. align-items: center;
  542. justify-content: center;
  543. box-sizing: border-box;
  544. padding: 0 80rpx 0;
  545. margin-top: 70rpx;
  546. >view {
  547. width: 100%;
  548. height: 100%;
  549. border-radius: 46rpx;
  550. color: #fff;
  551. background-color: var(--gd-but-color);
  552. font-size: 28rpx;
  553. font-family: SourceHanSansCN, SourceHanSansCN;
  554. display: flex;
  555. align-items: center;
  556. justify-content: center;
  557. }
  558. }
  559. }
  560. }
  561. /** 提现 结束 */
  562. }
  563. /** 头部主要内容 结束 **/
  564. /** 密码弹窗 */
  565. .password-model {
  566. width: 100%;
  567. height: 100%;
  568. display: flex;
  569. justify-content: center;
  570. align-items: center;
  571. box-sizing: border-box;
  572. padding: 0 40rpx;
  573. >view {
  574. width: 100%;
  575. display: flex;
  576. justify-content: center;
  577. align-items: center;
  578. flex-direction: column;
  579. background-color: #fff;
  580. color: #000;
  581. padding: 50rpx 10rpx;
  582. box-sizing: border-box;
  583. position: relative;
  584. border-radius: 20rpx;
  585. >view {
  586. font-size: 32rpx;
  587. padding: 10rpx 0;
  588. box-sizing: border-box;
  589. }
  590. >view:nth-child(3) {
  591. width: 100%;
  592. display: flex;
  593. justify-content: center;
  594. align-items: center;
  595. font-size: 52rpx;
  596. border-bottom: 2rpx solid #ccc;
  597. padding: 10rpx 0 20rpx;
  598. color: var(--gd-bgm-color);
  599. }
  600. >view:nth-child(4) {
  601. margin-top: 30rpx;
  602. }
  603. >text {
  604. position: absolute;
  605. top: 0;
  606. right: 0;
  607. }
  608. }
  609. }
  610. </style>