index.vue 13 KB

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