index.vue 13 KB

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