index.vue 13 KB

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