index.vue 13 KB

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