index.vue 13 KB

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