index.vue 15 KB

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