index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  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. </view>
  80. </template>
  81. <script>
  82. import { Decimal } from 'decimal.js';//引入
  83. import {
  84. navigateTo
  85. } from "@/utils/util.js"
  86. export default {
  87. data() {
  88. return {
  89. title: '这是我的',
  90. statusBarHeight: 0, // 状态栏安全距离
  91. monry: 0,
  92. moneyValue: null,
  93. moneyAccount: '',
  94. show: false,
  95. columns: [
  96. [{
  97. label: '雪月夜',
  98. // 其他属性值
  99. id: 2021
  100. // ...
  101. }, {
  102. label: '冷夜雨',
  103. id: 804
  104. }]
  105. ],
  106. withdrawInfo: {},
  107. showModal: false,
  108. password: '',
  109. personList:[],
  110. serviceMoney: null,
  111. }
  112. },
  113. onLoad(page) {
  114. this.moneyValue = Number(page.withdrawTotal);
  115. this.personList = JSON.parse(page.personList);
  116. // #ifdef H5
  117. //window.addEventListener('popstate', this.browserBack)
  118. // #endif
  119. },
  120. onUnload() {
  121. // #ifdef H5
  122. //window.removeEventListener("popstate", this.browserBack);
  123. // #endif
  124. },
  125. onShow() {
  126. //this.statusBarHeight = getApp().globalData.statusBarHeight
  127. this.getWithdrawInfo()
  128. },
  129. methods: {
  130. /**
  131. * @author ygh
  132. * @data 2023-12-20
  133. */
  134. navigateToFun() {
  135. navigateTo('/pages/cash/index')
  136. },
  137. /**
  138. * 数字显示格式化
  139. *
  140. */
  141. numFormat(num = 0) {
  142. if (num < 100000) {
  143. return num
  144. } else if (num > 100000) {
  145. return (num / 10000).toFixed(2)
  146. }
  147. },
  148. /** 全部提现 */
  149. cashAll() {
  150. this.moneyValue = this.monry
  151. },
  152. /**
  153. * 打开选择器
  154. */
  155. openPopup() {
  156. return
  157. this.show = true
  158. },
  159. /** 取消选择器 */
  160. cancelPicker() {
  161. this.show = false
  162. },
  163. /** 确认选择器 */
  164. confirmPicker() {
  165. this.show = false
  166. },
  167. /**
  168. * 获取数据
  169. */
  170. async getWithdrawInfo() {
  171. try {
  172. let list = []
  173. this.personList.forEach((item,index)=> {
  174. list.push(item.personsId)
  175. })
  176. let res = await this.$u.api.getSettlement({
  177. noSign: 1,
  178. userid: this.distribution_user_info.userId,
  179. withdrawAmount: this.moneyValue,
  180. withdrawList: list
  181. })
  182. if (res && res.code === 200) {
  183. this.withdrawInfo = res.data
  184. // this.withdrawInfo.serviceType = 1
  185. // this.withdrawInfo.serviceCharge = 0
  186. this.moneyValue = this.withdrawInfo.totalAmount
  187. // this.monry = res.data.withdrawTotal;
  188. // this.moneyAccountFun();
  189. }
  190. } catch (e) {
  191. //TODO handle the exception
  192. console.error("e===", e)
  193. }
  194. },
  195. openModal() {
  196. // if (!this.moneyValue || this.moneyValue < this.withdrawInfo.minAmount) {
  197. // uni.showToast({
  198. // title: '最小提现金额' + this.withdrawInfo.minAmount,
  199. // icon: 'none'
  200. // });
  201. // return
  202. // }
  203. // if(this.moneyValue > this.monry) {
  204. // uni.showToast({
  205. // title: '总金额不能大于用户可提现金额',
  206. // icon: 'none'
  207. // });
  208. // return
  209. // }
  210. // uni.showModal({
  211. // title: '提示',
  212. // content: '确定提现余额吗?',
  213. // success: res => {
  214. // this.orderWithdraw()
  215. // },
  216. // complete() {
  217. // }
  218. // })
  219. this.showModal = true
  220. // #ifdef H5
  221. window.history.replaceState(null, null, document.URL)
  222. // #endif
  223. },
  224. /** 关闭 */
  225. clearOverlay() {
  226. this.showModal = false
  227. },
  228. /**
  229. * 密码校验
  230. */
  231. async marketPersons() {
  232. try {
  233. let res = await this.$u.api.marketPersons({
  234. noSign: 1,
  235. userid: this.distribution_user_info.userId,
  236. oldPassword: this.password
  237. })
  238. if (res && res.code === 200) {
  239. this.orderWithdraw()
  240. } else {
  241. this.password = ''
  242. }
  243. } catch (e) {
  244. //TODO handle the exception
  245. console.error("e===", e)
  246. this.password = ''
  247. }
  248. },
  249. /**
  250. * 提交申请
  251. */
  252. async orderWithdraw() {
  253. try {
  254. let list = []
  255. this.personList.forEach((item,index)=> {
  256. list.push(item.personsId)
  257. })
  258. let res = await this.$u.api.withdrawApply({
  259. noSign: 1,
  260. userid: this.distribution_user_info.userId,
  261. // "withdrawType": "wechat",
  262. // "withdrawTotal": this.moneyAccount,
  263. // "serviceAmount": this.withdrawInfo.serviceCharge,
  264. // "bankId": null,
  265. //personList:this.personList
  266. withdrawList: list
  267. })
  268. if (res && res.code === 200) {
  269. navigateTo('/pages/cashPrompt/index',{
  270. id: res.data.orderId,
  271. serviceMoney: this.serviceMoney,
  272. // ...res.data.bankInfo,
  273. // moneyValue: this.moneyValue,
  274. // withdrawType: 'wechat',
  275. // serviceType: this.withdrawInfo.serviceType,
  276. // serviceCharge: this.withdrawInfo.serviceCharge
  277. })
  278. } else {
  279. uni.showToast({
  280. title: res.msg,
  281. icon: 'none'
  282. })
  283. this.password = ''
  284. }
  285. this.showModal = false
  286. } catch (e) {
  287. //TODO handle the exception
  288. console.error("e===", e)
  289. this.password = ''
  290. this.showModal = false
  291. uni.showToast({
  292. title: "提交失败",
  293. icon: 'none'
  294. })
  295. }
  296. },
  297. /**
  298. * 设置服务费显示
  299. */
  300. setServiceType(data) {
  301. if (data && data.serviceType) {
  302. if(data.serviceType == 1){
  303. this.serviceMoney = data.serviceCharge
  304. return ('¥' + data.serviceCharge)
  305. }else {
  306. let num1 = this.withdrawInfo.serviceCharge;
  307. let num = isNaN(num1) ? 0 : (Number(num1) / 100)
  308. let money = num ? new Decimal(this.moneyValue).mul(new Decimal(num)) : 0
  309. this.serviceMoney = money
  310. return '¥' + money
  311. }
  312. }
  313. },
  314. /**
  315. * 设置到账金额
  316. */
  317. moneyAccountFun() {
  318. let money = ''
  319. if (this.withdrawInfo.serviceType == 1) {
  320. money = (isNaN(this.withdrawInfo.serviceCharge) ? 0 : this.withdrawInfo
  321. .serviceCharge)
  322. } else if (this.withdrawInfo.serviceType == 2) {
  323. let num1 = this.withdrawInfo.serviceCharge;
  324. let num = isNaN(num1) ? 0 : (Number(num1) / 100)
  325. money = num ? new Decimal(this.moneyValue).mul(new Decimal(num)) : 0
  326. }
  327. this.moneyAccount = money < 0 ? '金额小于零' : new Decimal(this.moneyValue).sub(new Decimal(money.toFixed(2)))
  328. },
  329. browserBack() {
  330. console.log(1);
  331. // 在这里写弹框
  332. uni.showModal({
  333. title: '提示',
  334. content: '返回后此页面的操作将不作保留!',
  335. cancelText: '确定返回',
  336. confirmText: '留在此页',
  337. success: (res) => {
  338. if (res.confirm) {
  339. // 用户选择留在此页,不进行任何操作
  340. } else if (res.cancel) {
  341. //window.history.back(); // 使用window.history.back()返回上一页
  342. }
  343. }
  344. });
  345. //window.history.replaceState(null, null, document.URL); // 保留此行代码
  346. },
  347. }
  348. }
  349. </script>
  350. <style lang="scss" scoped>
  351. .cash-content {
  352. display: flex;
  353. flex-direction: column;
  354. align-items: center;
  355. justify-content: center;
  356. --header-h: 420rpx;
  357. .cash-content-info {
  358. width: 100%;
  359. box-sizing: border-box;
  360. }
  361. }
  362. /** 头部主要内容 开始 */
  363. .cash-content-header {
  364. width: 100%;
  365. height: var(--header-h);
  366. box-sizing: border-box;
  367. background: var(--gd-bgm-lg-color);
  368. position: relative;
  369. ::v-deep .u-search {
  370. padding: 0 30rpx !important;
  371. }
  372. ::v-deep .u-search__action {
  373. color: #fff !important;
  374. }
  375. /** 余额 开始 */
  376. .cash-content-money {
  377. width: 100%;
  378. box-sizing: border-box;
  379. margin-top: 50rpx;
  380. padding-left: 66rpx;
  381. color: #fff;
  382. >text {
  383. font-size: 24rpx;
  384. }
  385. .cash-content-money-num {
  386. display: flex;
  387. justify-content: center;
  388. align-items: flex-start;
  389. flex-direction: column;
  390. margin-top: 24rpx;
  391. >text:nth-child(1) {
  392. .balance-userinfo-util {
  393. font-size: 24rpx;
  394. margin-left: 5rpx;
  395. }
  396. ::v-deep .u-count-num {
  397. font-weight: bold !important;
  398. font-size: 48rpx !important;
  399. }
  400. }
  401. >text:nth-child(2) {
  402. margin-top: 20rpx;
  403. font-size: 24rpx;
  404. }
  405. }
  406. }
  407. /** 余额 结束 */
  408. /** 提现 开始 */
  409. .cash-content-cash {
  410. width: 100%;
  411. box-sizing: border-box;
  412. position: absolute;
  413. top: 100%;
  414. transform: translateY(-50%);
  415. padding: 0 12rpx;
  416. .cash-content-cash-box {
  417. width: 100%;
  418. height: 100%;
  419. background-color: #fff;
  420. box-shadow: 0rpx 2rpx 12rpx 0rpx rgba(221, 221, 221, 0.5);
  421. border-radius: 20rpx;
  422. box-sizing: border-box;
  423. padding: 34rpx 30rpx 38rpx;
  424. >text {
  425. font-size: 28rpx;
  426. color: #363636;
  427. }
  428. .cash-content-cash-money {
  429. width: 100%;
  430. display: flex;
  431. align-items: center;
  432. padding: 40rpx 0 20rpx;
  433. border-bottom: 2rpx solid #EEEEEE;
  434. ::v-deep .u-cell__body {
  435. padding: 20rpx 0 !important;
  436. }
  437. .cash-content-cash-input {
  438. width: 100%;
  439. padding: 0 10rpx;
  440. }
  441. >text {
  442. flex-shrink: 0;
  443. flex-wrap: nowrap;
  444. white-space: nowrap;
  445. }
  446. .cash-content-cash-money-icon {
  447. font-size: 32rpx;
  448. }
  449. .cash-content-cash-money-all {
  450. color: var(--gd-but-color);
  451. font-size: 24rpx;
  452. cursor: pointer;
  453. }
  454. }
  455. .cash-content-cash-service {
  456. width: 100%;
  457. box-sizing: border-box;
  458. padding: 20rpx 0;
  459. //border-bottom: 2rpx solid #EEEEEE;
  460. >view {
  461. width: 100%;
  462. display: flex;
  463. justify-content: space-between;
  464. align-items: center;
  465. color: #606060;
  466. padding: 5rpx 0 10rpx;
  467. font-size: 24rpx;
  468. }
  469. }
  470. .cash-content-cash-card {
  471. width: 100%;
  472. ::v-deep .u-cell__body {
  473. padding: 20rpx 0 !important;
  474. }
  475. }
  476. .cash-content-cash-submit {
  477. width: 100%;
  478. height: 92rpx;
  479. display: flex;
  480. align-items: center;
  481. justify-content: center;
  482. box-sizing: border-box;
  483. padding: 0 80rpx 0;
  484. margin-top: 70rpx;
  485. >view {
  486. width: 100%;
  487. height: 100%;
  488. border-radius: 46rpx;
  489. color: #fff;
  490. background-color: var(--gd-but-color);
  491. font-size: 28rpx;
  492. font-family: SourceHanSansCN, SourceHanSansCN;
  493. display: flex;
  494. align-items: center;
  495. justify-content: center;
  496. }
  497. }
  498. }
  499. }
  500. /** 提现 结束 */
  501. }
  502. /** 头部主要内容 结束 **/
  503. /** 密码弹窗 */
  504. .password-model {
  505. width: 100%;
  506. height: 100%;
  507. display: flex;
  508. justify-content: center;
  509. align-items: center;
  510. box-sizing: border-box;
  511. padding: 0 40rpx;
  512. >view {
  513. width: 100%;
  514. display: flex;
  515. justify-content: center;
  516. align-items: center;
  517. flex-direction: column;
  518. background-color: #fff;
  519. color: #000;
  520. padding: 50rpx 10rpx;
  521. box-sizing: border-box;
  522. position: relative;
  523. border-radius: 20rpx;
  524. >view {
  525. font-size: 32rpx;
  526. padding: 10rpx 0;
  527. box-sizing: border-box;
  528. }
  529. >view:nth-child(3) {
  530. width: 100%;
  531. display: flex;
  532. justify-content: center;
  533. align-items: center;
  534. font-size: 52rpx;
  535. border-bottom: 2rpx solid #ccc;
  536. padding: 10rpx 0 20rpx;
  537. color: var(--gd-bgm-color);
  538. }
  539. >view:nth-child(4) {
  540. margin-top: 30rpx;
  541. }
  542. >text {
  543. position: absolute;
  544. top: 0;
  545. right: 0;
  546. }
  547. }
  548. }
  549. </style>