index.vue 15 KB

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