index.vue 15 KB

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